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[K, 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[K, V])

Return type:

None

Methods

__init__(input_dict)

Construct a Map from a Python mapping.

get()

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)

Check object identity.

values()

Return a dynamic view of the map's values.

keys()[source]#

Return a dynamic view of the map’s keys.

Return type:

KeysView[K]

values()[source]#

Return a dynamic view of the map’s values.

Return type:

ValuesView[V]

items()[source]#

Get the items from the map.

Return type:

ItemsView[K, V]

get(key: K) V | None[source]#
get(key: K, default: V | _DefaultT) V | _DefaultT

Get an element with a default value.

Parameters:
  • key (object) – The attribute key.

  • default (object) – The default object.

Returns:

value – The result value.

Return type:

object