Struct TVMFFIFieldInfo#

Inheritance Relationships#

Derived Type#

Struct Documentation#

struct TVMFFIFieldInfo#

Information support for optional object reflection.

Subclassed by tvm::ffi::reflection::FieldInfoBuilder

Public Members

TVMFFIByteArray name#

The name of the field.

TVMFFIByteArray doc#

The docstring about the field.

TVMFFIByteArray metadata#

The structured metadata of the field in JSON string.

int64_t flags#

bitmask flags of the field.

int64_t size#

The size of the field.

int64_t alignment#

The alignment of the field.

int64_t offset#

The offset of the field.

TVMFFIFieldGetter getter#

The getter to access the field.

TVMFFIFieldSetter setter#

The setter to access the field.

Note

The setter is set even if the field is readonly for serialization.

TVMFFIAny default_value_or_factory#

The default value or default factory of the field.

When flags has kTVMFFIFieldFlagBitMaskHasDefault set:

  • If kTVMFFIFieldFlagBitMaskDefaultFromFactory is NOT set, this holds the static default value as AnyView.

  • If kTVMFFIFieldFlagBitMaskDefaultFromFactory IS set, this holds a Function (() -> Any) that produces the default.

int32_t field_static_type_index#

The compile-time static type index of the field.

This reflects the type declared at compile time, which is only trustworthy for statically-inferrable types. It does NOT necessarily match the runtime type. For example, a field declared as Any will have field_static_type_index == kTVMFFIAny even if it holds an int at runtime, and Array<Any> will report kTVMFFIArray even though the elements may be Array<int> at runtime.

Note

This is used by the serializer to inline POD field values directly (avoiding node-graph overhead for None, Bool, Int, Float, DataType), while routing other types through the node graph.

Warning

Do NOT use this field to determine the actual type of a value at runtime. It is purely a compile-time hint derived from the C++ field declaration. The actual runtime type must be obtained from the value’s own type_index.

Warning

When the static type is a generic container (e.g. Array<Any>), this field only tells you it is an Array — it says nothing about the element types actually stored inside. Similarly, kTVMFFIObject only means “some ObjectRef” without any subtype information.