tvm_ffi.Map#

class tvm_ffi.Map(input_dict)[source]#

Bases: Object, Mapping[K, V]

Map container.

tvm_ffi.convert() will map python dict to this class.

Parameters:

input_dict (Mapping[TypeVar(K), TypeVar(V)]) – The dictionary of values to be stored in the map.

Examples

import tvm_ffi

amap = tvm_ffi.convert({"a": 1, "b": 2})
assert isinstance(amap, tvm_ffi.Map)
assert len(amap) == 2
assert amap["a"] == 1
assert amap["b"] == 2
__init__(input_dict)[source]#

Construct a Map from a Python mapping.

Parameters:

input_dict (Mapping[TypeVar(K), TypeVar(V)])

Return type:

None

Methods

__ffi_init__(*args)

Defined in Object as method __ffi_init__().

__init__(input_dict)

Construct a Map from a Python mapping.

get(key[, default])

Get an element with a default value.

items()

Get the items from the map.

keys()

Return a dynamic view of the map's keys.

same_as(other)

Defined in Object as method same_as().

values()

Return a dynamic view of the map's values.

keys()[source]#

Return a dynamic view of the map’s keys.

Return type:

KeysView[TypeVar(K)]

values()[source]#

Return a dynamic view of the map’s values.

Return type:

ValuesView[TypeVar(V)]

items()[source]#

Get the items from the map.

Return type:

ItemsView[TypeVar(K), TypeVar(V)]

get(key, default=None)[source]#

Get an element with a default value.

Parameters:
  • key (TypeVar(K)) – The attribute key.

  • default (TypeVar(V) | TypeVar(_DefaultT) | None, default: None) – The default object.

Return type:

TypeVar(V) | TypeVar(_DefaultT) | None

Returns:

value – The result value.