You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by gi...@apache.org on 2026/07/25 17:47:16 UTC
(tvm-site) branch asf-site updated: deploying ffi docs
This is an automated email from the ASF dual-hosted git repository.
github-actions[bot] pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/tvm-site.git
The following commit(s) were added to refs/heads/asf-site by this push:
new be067323974 deploying ffi docs
be067323974 is described below
commit be067323974149721fd4411b2bbd9c4bea290572
Author: tvm-bot <95...@users.noreply.github.com>
AuthorDate: Sat Jul 25 17:47:08 2026 +0000
deploying ffi docs
---
ffi/_modules/index.html | 125 +++-
ffi/_modules/tvm_ffi/_convert.html | 125 +++-
ffi/_modules/tvm_ffi/_dtype.html | 207 +++++-
ffi/_modules/tvm_ffi/_tensor.html | 125 +++-
ffi/_modules/tvm_ffi/access_path.html | 125 +++-
ffi/_modules/tvm_ffi/container.html | 177 +++--
ffi/_modules/tvm_ffi/cpp/extension.html | 183 ++++-
ffi/_modules/tvm_ffi/cpp/nvrtc.html | 127 +++-
ffi/_modules/tvm_ffi/error.html | 125 +++-
ffi/_modules/tvm_ffi/libinfo.html | 125 +++-
ffi/_modules/tvm_ffi/module.html | 125 +++-
ffi/_modules/tvm_ffi/registry.html | 151 ++++-
ffi/_modules/tvm_ffi/serialization.html | 125 +++-
ffi/_modules/tvm_ffi/stream.html | 125 +++-
ffi/_modules/tvm_ffi/structural.html | 153 +++--
ffi/_sources/concepts/abi_overview.rst | 2 +-
ffi/_sources/concepts/structural_eq_hash.rst | 26 +-
ffi/_sources/dev/source_build.rst | 2 +-
ffi/_sources/guides/cpp_lang_guide.md | 42 +-
ffi/_sources/guides/dataclass_reflection.rst | 78 ++-
ffi/_sources/packaging/cpp_tooling.rst | 2 +-
.../cpp/generated/classtvm_1_1ffi_1_1Arc.rst | 26 +
.../cpp/generated/classtvm_1_1ffi_1_1Enum.rst | 7 +
.../cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst | 7 +
..._1Enum.rst => classtvm_1_1ffi_1_1EnumState.rst} | 8 +-
...Obj.rst => classtvm_1_1ffi_1_1EnumStateObj.rst} | 8 +-
.../classtvm_1_1ffi_1_1Expected_3_01void_01_4.rst | 17 +
...1EnumObj.rst => classtvm_1_1ffi_1_1IntEnum.rst} | 8 +-
...1Enum.rst => classtvm_1_1ffi_1_1IntEnumObj.rst} | 10 +-
.../cpp/generated/classtvm_1_1ffi_1_1Object.rst | 1 +
.../cpp/generated/classtvm_1_1ffi_1_1ObjectPtr.rst | 9 +
.../cpp/generated/classtvm_1_1ffi_1_1ObjectRef.rst | 5 +-
...1EnumObj.rst => classtvm_1_1ffi_1_1StrEnum.rst} | 8 +-
...1Enum.rst => classtvm_1_1ffi_1_1StrEnumObj.rst} | 10 +-
.../cpp/generated/classtvm_1_1ffi_1_1Variant.rst | 9 -
...m_1_1ffi_1_1reflection_1_1OverloadObjectDef.rst | 10 +
...raits_8h_1a63cd913de4d021d2e201531d5c675a88.rst | 14 +
.../reference/cpp/generated/dir_tvm_ffi.rst | 1 +
.../reference/cpp/generated/file_tvm_ffi_any.h.rst | 4 +
.../cpp/generated/file_tvm_ffi_c_api.h.rst | 8 +
.../cpp/generated/file_tvm_ffi_cast.h.rst | 2 +
.../generated/file_tvm_ffi_container_list.h.rst | 2 +
.../generated/file_tvm_ffi_container_tensor.h.rst | 6 +-
...m_ffi_dtype.h.rst => file_tvm_ffi_device.h.rst} | 38 +-
.../cpp/generated/file_tvm_ffi_dtype.h.rst | 8 +
.../cpp/generated/file_tvm_ffi_enum.h.rst | 14 +
.../cpp/generated/file_tvm_ffi_error.h.rst | 2 -
.../cpp/generated/file_tvm_ffi_expected.h.rst | 2 +
.../cpp/generated/file_tvm_ffi_extra_base64.h.rst | 4 +-
.../cpp/generated/file_tvm_ffi_extra_json.h.rst | 2 +-
.../cpp/generated/file_tvm_ffi_memory.h.rst | 4 +
.../cpp/generated/file_tvm_ffi_object.h.rst | 23 +-
.../cpp/generated/file_tvm_ffi_optional.h.rst | 4 +-
.../file_tvm_ffi_reflection_accessor.h.rst | 8 +-
.../file_tvm_ffi_reflection_enum_def.h.rst | 2 -
.../file_tvm_ffi_reflection_overload.h.rst | 2 +
.../cpp/generated/file_tvm_ffi_string.h.rst | 2 +
.../cpp/generated/file_tvm_ffi_tvm_ffi.h.rst | 2 +
.../cpp/generated/file_tvm_ffi_type_traits.h.rst | 47 +-
...__api_8h_1a147c7c5616be4acf5a71623dbb7dd680.rst | 14 +
...__api_8h_1aa7d102c19d2ac12f730935e6fb210bf1.rst | 14 +
...dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a.rst | 14 +
...dtype_8h_1a74a70941a707682598886f8475f86848.rst | 14 +
...dtype_8h_1a89696eef7917af8ff34285cb6fae4c63.rst | 14 +
...dtype_8h_1a95190c80d6dfa260c156b00ce5336c83.rst | 14 +
...json_8h_1a0a0dc3202335cbaa265618821764fa2d.rst} | 4 +-
...emory_8h_1a6001462e18d71614c0f11a4c2e064f7e.rst | 14 +
...aits_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst} | 4 +-
.../reference/cpp/generated/namespace_tvm__ffi.rst | 48 +-
.../cpp/generated/namespace_tvm__ffi__json.rst | 2 +-
.../generated/namespace_tvm__ffi__reflection.rst | 2 +
.../namespace_tvm__ffi__reflection__type_attr.rst | 8 +-
.../program_listing_file_tvm_ffi_any.h.rst | 119 +++-
...program_listing_file_tvm_ffi_base_details.h.rst | 14 +-
.../program_listing_file_tvm_ffi_c_api.h.rst | 17 +
.../program_listing_file_tvm_ffi_cast.h.rst | 28 +-
...gram_listing_file_tvm_ffi_container_array.h.rst | 20 +-
...ogram_listing_file_tvm_ffi_container_dict.h.rst | 20 +-
...ogram_listing_file_tvm_ffi_container_list.h.rst | 20 +-
...rogram_listing_file_tvm_ffi_container_map.h.rst | 20 +-
...ram_listing_file_tvm_ffi_container_tensor.h.rst | 52 +-
...gram_listing_file_tvm_ffi_container_tuple.h.rst | 16 +-
...am_listing_file_tvm_ffi_container_variant.h.rst | 106 +--
.../program_listing_file_tvm_ffi_device.h.rst | 151 +++++
.../program_listing_file_tvm_ffi_dtype.h.rst | 126 ++++
.../program_listing_file_tvm_ffi_enum.h.rst | 110 ++-
.../program_listing_file_tvm_ffi_error.h.rst | 2 +-
.../program_listing_file_tvm_ffi_expected.h.rst | 127 +++-
.../program_listing_file_tvm_ffi_extra_json.h.rst | 2 +-
...program_listing_file_tvm_ffi_extra_module.h.rst | 2 +-
...sting_file_tvm_ffi_extra_structural_equal.h.rst | 2 +-
...sting_file_tvm_ffi_extra_structural_visit.h.rst | 91 ++-
.../program_listing_file_tvm_ffi_function.h.rst | 13 +-
.../program_listing_file_tvm_ffi_memory.h.rst | 69 +-
.../program_listing_file_tvm_ffi_object.h.rst | 477 +++++++++++--
.../program_listing_file_tvm_ffi_optional.h.rst | 380 +++++------
...sting_file_tvm_ffi_reflection_access_path.h.rst | 8 +-
..._listing_file_tvm_ffi_reflection_accessor.h.rst | 11 +-
...m_listing_file_tvm_ffi_reflection_creator.h.rst | 1 +
..._listing_file_tvm_ffi_reflection_enum_def.h.rst | 113 ++--
..._listing_file_tvm_ffi_reflection_overload.h.rst | 30 +-
..._listing_file_tvm_ffi_reflection_registry.h.rst | 78 ++-
.../program_listing_file_tvm_ffi_tvm_ffi.h.rst | 1 +
.../program_listing_file_tvm_ffi_type_traits.h.rst | 454 +++----------
.../cpp/generated/structTVMFFICustomAllocator.rst | 17 +
.../generated/structTVMFFIObjectAllocHeader.rst | 17 +
...m_1_1ffi_1_1ObjectRefWithFallbackTraitsBase.rst | 2 +-
.../structtvm_1_1ffi_1_1StaticTypeKey.rst | 2 +-
...on_1_1OverloadObjectDef_1_1RegisteredMethod.rst | 23 +
...aits_8h_1a7ba296d84188e5970ba854332a1f04a6.rst} | 4 +-
...aits_8h_1ae125f5f5a8a94c7340577c1959805295.rst} | 4 +-
.../reference/cpp/generated/unabridged_orphan.rst | 5 +
...pe__attr_1a2235b3faf38b1017a13ef6178d9a8fa8.rst | 14 -
...e__attr_1a877b4867a278823be18e6c7f7bff378e.rst} | 6 +-
...pe__attr_1ab8b34ca1b301024a7f48d226906bf5c1.rst | 14 +
...pe__attr_1aff9e02aea85ecba0ee1956f7ee2ce4a9.rst | 14 -
...bject_8h_1a31dc4b1b71941b3e4217a0e389f807a4.rst | 14 +
...bject_8h_1a5f52cb03b4b23d5d7738ff0386335845.rst | 14 +
...raits_8h_1a62ef22ceb232bddd3e9540895af38cc1.rst | 14 +
.../python/generated/tvm_ffi.StructuralVisitor.rst | 1 -
.../reference/python/generated/tvm_ffi.Tensor.rst | 1 +
.../python/generated/tvm_ffi.VisitInterrupt.rst | 1 -
.../reference/python/generated/tvm_ffi.dtype.rst | 5 +
ffi/_static/documentation_options.js | 2 +-
ffi/concepts/abi_overview.html | 10 +-
ffi/concepts/any.html | 8 +-
ffi/concepts/containers.html | 8 +-
ffi/concepts/exception_handling.html | 8 +-
ffi/concepts/func_module.html | 8 +-
ffi/concepts/object_and_class.html | 10 +-
ffi/concepts/structural_eq_hash.html | 150 ++++-
ffi/concepts/tensor.html | 8 +-
ffi/dev/ci_cd.html | 8 +-
ffi/dev/doc_build.html | 8 +-
ffi/dev/release_process.html | 8 +-
ffi/dev/source_build.html | 10 +-
ffi/genindex.html | 291 ++++++--
ffi/get_started/quickstart.html | 8 +-
ffi/get_started/stable_c_abi.html | 8 +-
ffi/guides/compiler_integration.html | 8 +-
ffi/guides/cpp_lang_guide.html | 46 +-
ffi/guides/cubin_launcher.html | 8 +-
ffi/guides/dataclass_reflection.html | 85 ++-
ffi/guides/export_func_cls.html | 8 +-
ffi/guides/kernel_library_guide.html | 8 +-
ffi/guides/python_lang_guide.html | 8 +-
ffi/guides/rust_lang_guide.html | 8 +-
ffi/index.html | 8 +-
ffi/objects.inv | Bin 188110 -> 195497 bytes
ffi/packaging/cpp_tooling.html | 10 +-
ffi/packaging/python_packaging.html | 10 +-
ffi/packaging/stubgen.html | 8 +-
ffi/py-modindex.html | 125 +++-
.../cpp/generated/classtvm_1_1ffi_1_1Any.html | 48 +-
.../cpp/generated/classtvm_1_1ffi_1_1AnyView.html | 8 +-
...ypeAttrDef.html => classtvm_1_1ffi_1_1Arc.html} | 140 ++--
.../cpp/generated/classtvm_1_1ffi_1_1Array.html | 20 +-
.../cpp/generated/classtvm_1_1ffi_1_1ArrayObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Bytes.html | 8 +-
.../generated/classtvm_1_1ffi_1_1CubinKernel.html | 8 +-
.../generated/classtvm_1_1ffi_1_1CubinModule.html | 8 +-
.../classtvm_1_1ffi_1_1DenseMapBaseObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Dict.html | 20 +-
.../cpp/generated/classtvm_1_1ffi_1_1DictObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Enum.html | 20 +-
.../cpp/generated/classtvm_1_1ffi_1_1EnumObj.html | 124 +++-
...pObj.html => classtvm_1_1ffi_1_1EnumState.html} | 42 +-
...j.html => classtvm_1_1ffi_1_1EnumStateObj.html} | 79 +--
.../cpp/generated/classtvm_1_1ffi_1_1Error.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1ErrorObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Expected.html | 16 +-
...classtvm_1_1ffi_1_1Expected_3_01void_01_4.html} | 192 +++---
.../cpp/generated/classtvm_1_1ffi_1_1Function.html | 8 +-
.../generated/classtvm_1_1ffi_1_1FunctionObj.html | 8 +-
...ictObj.html => classtvm_1_1ffi_1_1IntEnum.html} | 42 +-
...Obj.html => classtvm_1_1ffi_1_1IntEnumObj.html} | 42 +-
.../cpp/generated/classtvm_1_1ffi_1_1List.html | 20 +-
.../cpp/generated/classtvm_1_1ffi_1_1ListObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Map.html | 20 +-
.../generated/classtvm_1_1ffi_1_1MapBaseObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1MapObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Module.html | 12 +-
.../generated/classtvm_1_1ffi_1_1ModuleObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Object.html | 15 +-
.../generated/classtvm_1_1ffi_1_1ObjectPtr.html | 26 +-
.../generated/classtvm_1_1ffi_1_1ObjectRef.html | 93 ++-
.../cpp/generated/classtvm_1_1ffi_1_1Optional.html | 10 +-
.../generated/classtvm_1_1ffi_1_1PackedArgs.html | 8 +-
.../generated/classtvm_1_1ffi_1_1RValueRef.html | 8 +-
.../generated/classtvm_1_1ffi_1_1SeqBaseObj.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Shape.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1ShapeObj.html | 8 +-
.../generated/classtvm_1_1ffi_1_1ShapeView.html | 8 +-
.../classtvm_1_1ffi_1_1SmallMapBaseObj.html | 8 +-
...ictObj.html => classtvm_1_1ffi_1_1StrEnum.html} | 42 +-
...Obj.html => classtvm_1_1ffi_1_1StrEnumObj.html} | 42 +-
.../generated/classtvm_1_1ffi_1_1StrictBool.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1String.html | 8 +-
.../classtvm_1_1ffi_1_1StructuralEqual.html | 8 +-
.../classtvm_1_1ffi_1_1StructuralHash.html | 8 +-
.../classtvm_1_1ffi_1_1StructuralKey.html | 8 +-
.../classtvm_1_1ffi_1_1StructuralKeyObj.html | 8 +-
.../classtvm_1_1ffi_1_1StructuralVisitor.html | 16 +-
.../classtvm_1_1ffi_1_1StructuralVisitorObj.html | 65 +-
.../cpp/generated/classtvm_1_1ffi_1_1Tensor.html | 8 +-
.../generated/classtvm_1_1ffi_1_1TensorObj.html | 8 +-
.../generated/classtvm_1_1ffi_1_1TensorView.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Tuple.html | 23 +-
.../classtvm_1_1ffi_1_1TypedFunction.html | 8 +-
...i_1_1TypedFunction_3_01R_07Args_8_8_8_08_4.html | 8 +-
.../generated/classtvm_1_1ffi_1_1Unexpected.html | 8 +-
.../cpp/generated/classtvm_1_1ffi_1_1Variant.html | 56 +-
.../classtvm_1_1ffi_1_1VisitErrorContext.html | 8 +-
.../classtvm_1_1ffi_1_1VisitErrorContextObj.html | 8 +-
.../classtvm_1_1ffi_1_1VisitInterrupt.html | 8 +-
.../classtvm_1_1ffi_1_1VisitInterruptObj.html | 8 +-
.../generated/classtvm_1_1ffi_1_1WalkResult.html | 8 +-
.../classtvm_1_1ffi_1_1WeakObjectPtr.html | 8 +-
...lasstvm_1_1ffi_1_1reflection_1_1AccessPath.html | 8 +-
...stvm_1_1ffi_1_1reflection_1_1AccessPathObj.html | 8 +-
...lasstvm_1_1ffi_1_1reflection_1_1AccessStep.html | 8 +-
...stvm_1_1ffi_1_1reflection_1_1AccessStepObj.html | 8 +-
...vm_1_1ffi_1_1reflection_1_1AttachFieldFlag.html | 8 +-
...tvm_1_1ffi_1_1reflection_1_1DefaultFactory.html | 8 +-
...sstvm_1_1ffi_1_1reflection_1_1DefaultValue.html | 8 +-
.../classtvm_1_1ffi_1_1reflection_1_1EnumDef.html | 72 +-
...asstvm_1_1ffi_1_1reflection_1_1FieldGetter.html | 8 +-
...asstvm_1_1ffi_1_1reflection_1_1FieldSetter.html | 8 +-
...classtvm_1_1ffi_1_1reflection_1_1GlobalDef.html | 8 +-
.../classtvm_1_1ffi_1_1reflection_1_1Metadata.html | 8 +-
...stvm_1_1ffi_1_1reflection_1_1ObjectCreator.html | 8 +-
...classtvm_1_1ffi_1_1reflection_1_1ObjectDef.html | 69 +-
..._1_1ffi_1_1reflection_1_1OverloadObjectDef.html | 25 +-
...tvm_1_1ffi_1_1reflection_1_1TypeAttrColumn.html | 8 +-
...asstvm_1_1ffi_1_1reflection_1_1TypeAttrDef.html | 55 +-
.../classtvm_1_1ffi_1_1reflection_1_1compare.html | 8 +-
...tvm_1_1ffi_1_1reflection_1_1default__value.html | 8 +-
.../classtvm_1_1ffi_1_1reflection_1_1hash.html | 8 +-
.../classtvm_1_1ffi_1_1reflection_1_1kw__only.html | 8 +-
.../classtvm_1_1ffi_1_1reflection_1_1repr.html | 8 +-
...ails_8h_1ad96d0c78609aaf2660689e5408ddc40b.html | 8 +-
..._api_8h_1a01871644eed04162005df7faa5442f92.html | 8 +-
..._api_8h_1a4241f838270253b885e1de02534bc273.html | 8 +-
..._api_8h_1a42634cb2690dce4d9af6c2a402fc903c.html | 8 +-
..._api_8h_1a717daddad98d127813ba8ff5a715e929.html | 8 +-
...cher_8h_1a55832b50e83cf39108f1e306f031433d.html | 8 +-
...cher_8h_1a99736a44462543179cb434ebd4512ade.html | 8 +-
...cher_8h_1ae8d64fa1cc7db9d38632e32054df72fc.html | 8 +-
...base_8h_1a8b7e871d0d7206eacc60705f11827ee1.html | 8 +-
...dian_8h_1a2ebd9542b313b3b45b2892f2b3d4f26d.html | 8 +-
...dian_8h_1a912dbc7a68913612c723f877acaa8105.html | 8 +-
...rror_8h_1a07c8a4b3cbde3471d290fdbc73e14b0c.html | 8 +-
...rror_8h_1a0b440ab7013c78c61ab5dd5d8f27bd91.html | 8 +-
...rror_8h_1a16f0dbfb27520f4d044d82e32fd5bbec.html | 8 +-
...rror_8h_1a1a94c8b78e74adec05051abb9055e7b8.html | 8 +-
...rror_8h_1a26827bb8bc9e39255060f6be1d2a37fb.html | 8 +-
...rror_8h_1a27374a2cd94c6211ce2b754bd87e3fa3.html | 8 +-
...rror_8h_1a288653475dd42db1c715a11ab2972578.html | 8 +-
...rror_8h_1a2bce4014203aa455160771f1e8e698e5.html | 8 +-
...rror_8h_1a34350f477b8479a26ec5a2683100bc04.html | 8 +-
...rror_8h_1a386641a33bb14802830471a2442ddd7d.html | 8 +-
...rror_8h_1a394ec1781a34c49e29d47db5c3dfad9c.html | 8 +-
...rror_8h_1a4e04117882ed9f1469ec36f7979ace27.html | 8 +-
...rror_8h_1a64c939463f90816ffc2b70bc89ea3e43.html | 8 +-
...rror_8h_1a6c01470f76c6437edf93ac668ea6242a.html | 8 +-
...rror_8h_1a7205bbaef1c45e57f939af6deefb6449.html | 8 +-
...rror_8h_1a7d7a510c235963a0f1c7b7ab575c15fb.html | 8 +-
...rror_8h_1a8df4e0ff8a6195274c6f7c031a4f0db4.html | 8 +-
...rror_8h_1a927d4ae2bbf7a08723643993e780f183.html | 8 +-
...rror_8h_1a990e2467aea416d9b8b3a338df07cb32.html | 8 +-
...rror_8h_1aa7a5d2005aa58b2c7d9fa80c64f26e81.html | 8 +-
...rror_8h_1aaab66d9de933f4134006b0ad3d29e74a.html | 8 +-
...rror_8h_1aade00b2e0a9789e3e8bf33441d651455.html | 8 +-
...rror_8h_1aba8087204dace0473072f763f47ca943.html | 8 +-
...rror_8h_1aca415693e572f4602ca4e3a961fcb1f1.html | 8 +-
...rror_8h_1ad4674e1cb9c051f47127e5331a4bcadc.html | 8 +-
...rror_8h_1ae5be195e80d32413cbe5e2ad11e146f7.html | 8 +-
...rror_8h_1aeec11597fea71f1db8072324fe6d8b92.html | 8 +-
...rror_8h_1af1f84686ce5635b3a378567368e89e4d.html | 8 +-
...rror_8h_1af23d9224afd96bc1db250ab98d79ab45.html | 8 +-
...rror_8h_1af88efba89f134754f31e52c7024acda4.html | 8 +-
...rror_8h_1afcd5778e656fa2c20aa0b81fbcebc497.html | 8 +-
...tion_8h_1a01777f12f8f99771331d679a0c1d2ed4.html | 8 +-
...tion_8h_1a10bd932564c8e71a3978a061fbb82360.html | 8 +-
...tion_8h_1a14328d95ccda4b1691b9874645aef4bd.html | 8 +-
...tion_8h_1a78c6d17c063fba9ca07175f150838046.html | 8 +-
...tion_8h_1ae3c016c4bf383aa205b4485edd7ca17c.html | 8 +-
...tion_8h_1af84cdf62b6c193275db7e63e3bffc8bd.html | 8 +-
...ject_8h_1a0fc0cc2d8f4318bc41a896c117e8a15c.html | 8 +-
...ject_8h_1a438ff7ee1fc503216d35e156081280c0.html | 8 +-
...ject_8h_1a4ac33631a9b51877808ec7edf010f0d2.html | 8 +-
...ject_8h_1a6ad2a76d53c8c695743f7a275c8c0523.html | 8 +-
...ject_8h_1a9d1c42071de0440f70c7bb5e0bd0f325.html | 8 +-
...ject_8h_1ac593f4065568c8f61cf38d00d585befd.html | 8 +-
...its_8h_1a63cd913de4d021d2e201531d5c675a88.html} | 46 +-
..._api_8h_1a160bb722922e17fa17c938fcf8561732.html | 8 +-
..._api_8h_1a6dcf7c0dec497922c66282f1162ee081.html | 8 +-
..._api_8h_1a9e03c2471638d2243c3c3b79d800efe1.html | 8 +-
...text_8h_1a2c7a0445bca80cbe5572c1210ece5d9a.html | 8 +-
...text_8h_1a83081a2550b85038ac6195ee80dbc3d5.html | 8 +-
...text_8h_1a869b3127e19530e45aa7f2052dd290f7.html | 8 +-
...text_8h_1ad7a104799c7bc592fb7f7bb33b15549c.html | 8 +-
ffi/reference/cpp/generated/dir_tvm.html | 8 +-
ffi/reference/cpp/generated/dir_tvm_ffi.html | 9 +-
.../cpp/generated/dir_tvm_ffi_container.html | 8 +-
ffi/reference/cpp/generated/dir_tvm_ffi_extra.html | 8 +-
.../cpp/generated/dir_tvm_ffi_extra_cuda.html | 8 +-
.../generated/dir_tvm_ffi_extra_cuda_internal.html | 8 +-
.../cpp/generated/dir_tvm_ffi_reflection.html | 8 +-
..._api_8h_1a1925bb5d568a3f5c92a6c28934c9bcc2.html | 8 +-
..._api_8h_1a8eb3fb55f6ec3c46b6e57740af4ca58a.html | 8 +-
..._api_8h_1ad5a608f648c4f86cafdc8dc09f870bc5.html | 8 +-
..._api_8h_1ad6a441d28d4a6406418489609e975a19.html | 8 +-
..._api_8h_1aea0f30bf60e26c1322e525e246ef5be9.html | 8 +-
..._api_8h_1aff6130e5bc350339d7e71153e396cf4a.html | 8 +-
...type_8h_1a16f66b97fa44d7bd6114324c8b8e1bed.html | 8 +-
...lection_1a9c2cd4d683e7c7065942e36e628a2517.html | 8 +-
...isit_8h_1ab164fdc59c01d20b5fa07b88ef5ac09a.html | 14 +-
.../cpp/generated/file_tvm_ffi_any.h.html | 10 +-
.../cpp/generated/file_tvm_ffi_base_details.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_c_api.h.html | 12 +-
.../cpp/generated/file_tvm_ffi_cast.h.html | 9 +-
.../generated/file_tvm_ffi_container_array.h.html | 8 +-
.../generated/file_tvm_ffi_container_dict.h.html | 8 +-
.../generated/file_tvm_ffi_container_list.h.html | 9 +-
.../generated/file_tvm_ffi_container_map.h.html | 8 +-
.../file_tvm_ffi_container_map_base.h.html | 8 +-
.../file_tvm_ffi_container_seq_base.h.html | 8 +-
.../generated/file_tvm_ffi_container_shape.h.html | 8 +-
.../generated/file_tvm_ffi_container_tensor.h.html | 13 +-
.../generated/file_tvm_ffi_container_tuple.h.html | 8 +-
.../file_tvm_ffi_container_variant.h.html | 8 +-
...value_ref.h.html => file_tvm_ffi_device.h.html} | 52 +-
.../cpp/generated/file_tvm_ffi_dtype.h.html | 12 +-
.../cpp/generated/file_tvm_ffi_endian.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_enum.h.html | 15 +-
.../cpp/generated/file_tvm_ffi_error.h.html | 9 +-
.../cpp/generated/file_tvm_ffi_expected.h.html | 9 +-
.../cpp/generated/file_tvm_ffi_extra_base.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_extra_base64.h.html | 10 +-
.../generated/file_tvm_ffi_extra_c_env_api.h.html | 8 +-
.../generated/file_tvm_ffi_extra_cuda_base.h.html | 8 +-
.../file_tvm_ffi_extra_cuda_cubin_launcher.h.html | 8 +-
.../file_tvm_ffi_extra_cuda_device_guard.h.html | 8 +-
..._tvm_ffi_extra_cuda_internal_unified_api.h.html | 8 +-
.../generated/file_tvm_ffi_extra_dataclass.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_extra_dtype.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_extra_json.h.html | 10 +-
.../cpp/generated/file_tvm_ffi_extra_module.h.html | 8 +-
.../file_tvm_ffi_extra_serialization.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_extra_stl.h.html | 8 +-
.../file_tvm_ffi_extra_structural_equal.h.html | 8 +-
.../file_tvm_ffi_extra_structural_hash.h.html | 8 +-
.../file_tvm_ffi_extra_structural_key.h.html | 8 +-
.../file_tvm_ffi_extra_structural_visit.h.html | 8 +-
.../file_tvm_ffi_extra_visit_error_context.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_function.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_memory.h.html | 10 +-
.../cpp/generated/file_tvm_ffi_object.h.html | 38 +-
.../cpp/generated/file_tvm_ffi_optional.h.html | 11 +-
.../file_tvm_ffi_reflection_access_path.h.html | 8 +-
.../file_tvm_ffi_reflection_accessor.h.html | 13 +-
.../file_tvm_ffi_reflection_creator.h.html | 8 +-
.../file_tvm_ffi_reflection_enum_def.h.html | 9 +-
.../file_tvm_ffi_reflection_overload.h.html | 9 +-
.../file_tvm_ffi_reflection_registry.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_rvalue_ref.h.html | 8 +-
.../cpp/generated/file_tvm_ffi_string.h.html | 9 +-
.../cpp/generated/file_tvm_ffi_tvm_ffi.h.html | 9 +-
.../cpp/generated/file_tvm_ffi_type_traits.h.html | 54 +-
...tion_8h_1a111e2ed7444eb220e19c7624d0932d89.html | 8 +-
...rray_8h_1a3b56317c7cfb2760cf6c09c303840967.html | 8 +-
...rray_8h_1af5983fd2a31e79635307875b3a216472.html | 8 +-
...se64_8h_1a279b4ba2f4c7ea16291ef24b73e43963.html | 8 +-
...se64_8h_1aa5b2a4531449585b9f079cb170a79f0b.html | 8 +-
...se64_8h_1acb849cdb1d9b9620be10bbcda0257afa.html | 8 +-
...se64_8h_1ae1d4736f7dc56b224acd303ba7bf7a45.html | 8 +-
..._api_8h_1a0d3dcd6ceff356614a6924201c02cf97.html | 8 +-
..._api_8h_1a0ee6d2da9a72749561838bf503f62f93.html | 8 +-
..._api_8h_1a1162f2cbaf1a7628a03ed9488cff858b.html | 8 +-
..._api_8h_1a145f2694254410fd4814541e2cde99c1.html | 8 +-
...api_8h_1a147c7c5616be4acf5a71623dbb7dd680.html} | 40 +-
..._api_8h_1a177d080127ef8f3e338beb7dba4c04fd.html | 8 +-
..._api_8h_1a1a617dd18aa7dd47aa51a984611b67a1.html | 8 +-
..._api_8h_1a1a99289a314c6c3de865721bd3efb525.html | 8 +-
..._api_8h_1a1ac76d88e0d79843403ce2e0239d7fe2.html | 8 +-
..._api_8h_1a1dd5584d94f6e00a18f4cfa003dfb93a.html | 8 +-
..._api_8h_1a268d0b5dc89146020c09f77fa0eb8f67.html | 8 +-
..._api_8h_1a31a317a32bfa641180eed1bfb3d5cf01.html | 8 +-
..._api_8h_1a3253bbf35e2ad1361b2ce1de13d2c9b2.html | 8 +-
..._api_8h_1a3479c144d165e717d1464b7b4df84897.html | 8 +-
..._api_8h_1a3bf47f6e1229627902c80217d674ed29.html | 8 +-
..._api_8h_1a3f859b60d99c85f43fce8226c69f3c5e.html | 14 +-
..._api_8h_1a402f64dec7a665f281e55cf946a7481b.html | 8 +-
..._api_8h_1a4152d18590b7967eca4a528cbe33a84e.html | 8 +-
..._api_8h_1a44604b1d0db208ed82cbc7cf0fd0f47c.html | 8 +-
..._api_8h_1a4ce84fc667040bba425664c78b5f2c69.html | 8 +-
..._api_8h_1a4e8b3caff4da72205ec1ac9a811748e5.html | 8 +-
..._api_8h_1a53c5ec2971806966ed96a6add32b5238.html | 8 +-
..._api_8h_1a56ce10d1e6fc2d34a1a496bdace4af33.html | 8 +-
..._api_8h_1a5a7e3fe8a94e066bc1bf897fbf736651.html | 8 +-
..._api_8h_1a63149ed43a6ecffa2146f92914c0bc7b.html | 8 +-
..._api_8h_1a6415c088928d62af8749f3dc57dcf23b.html | 8 +-
..._api_8h_1a724b0d386cf3d50c7d141ca37be19092.html | 8 +-
..._api_8h_1a74c26efdd74840abc3e1581c73a38bfa.html | 8 +-
..._api_8h_1a762fc5c881dc5f66066eb45b65a5781f.html | 8 +-
..._api_8h_1aa26fa16c024c6f2fa15e46aa1333fdb9.html | 8 +-
..._api_8h_1aa2a81275b69ba0f61ce556df85517ef9.html | 8 +-
...api_8h_1aa7d102c19d2ac12f730935e6fb210bf1.html} | 39 +-
..._api_8h_1ab15b1e535d645969fde869a5e515a885.html | 8 +-
..._api_8h_1ab31a093c3633c793dc2b4ffed0825c31.html | 8 +-
..._api_8h_1ab691fd5bc4442c631c1f70985a962f50.html | 8 +-
..._api_8h_1aba50ba2cee84b1ef7a718211ab349031.html | 8 +-
..._api_8h_1ac0e2d59d3a8ba7f2b32eac47b1c6fc5d.html | 8 +-
..._api_8h_1ac5a4f48eacde3c69ad3154b6aa39fa3c.html | 8 +-
..._api_8h_1ac64df2793c84fc8ba5d24968d60bcada.html | 8 +-
..._api_8h_1ac66c1d142240be0cdf65c8ba38770eb6.html | 8 +-
..._api_8h_1adaf9a5ab3d30bb3eca58b430f2592fc0.html | 8 +-
..._api_8h_1adec9f8a8f0683caeb9dd194d9a3c62d5.html | 8 +-
..._api_8h_1aedd89f80f73d54dd5904d943dd0690c6.html | 8 +-
..._api_8h_1aeee9dab8873b5b2f327f4dfe50f802ab.html | 8 +-
..._api_8h_1af108ca4da596c634b4cb9e82c8bec1ce.html | 8 +-
..._api_8h_1af1b8a29eb3f9405982c344f5e572dd65.html | 8 +-
..._api_8h_1afee5a803e22f9baf5ee2ff1f0ace6429.html | 8 +-
..._api_8h_1a0e01ad3ed44c0240f1b76dbed7014234.html | 8 +-
..._api_8h_1a36c15024744584acceaf0233947f9505.html | 8 +-
..._api_8h_1a683191d48d3fdebc98b68f3b717baf6a.html | 8 +-
..._api_8h_1a7451ab18593d70d30a6214d622e200d2.html | 8 +-
..._api_8h_1a8ce2ba89ca1d010a084b4c36ed6b2965.html | 8 +-
..._api_8h_1a9b142b59ab84bc06e4a0f66a3510e8f7.html | 8 +-
..._api_8h_1aaf8960c33546788950b8e35ac18efe39.html | 8 +-
..._api_8h_1abcbbccfc02c57418e757033afce42ece.html | 8 +-
..._api_8h_1ac8f7894c4f205756b7aee01108ab8e84.html | 8 +-
..._api_8h_1ae24b47945440d1c0aca13af13bdaf916.html | 8 +-
...cast_8h_1a3c5fed9bb23b4804b61037c8ac4874f1.html | 8 +-
...cast_8h_1a4dba749dd934d8a7891ad126a8fdcc1f.html | 8 +-
...ator_8h_1a9f39a70dd0c30ef28f11b745a6753222.html | 8 +-
...ator_8h_1ad292023f85eb05de65c40b53a8126b0c.html | 8 +-
...lass_8h_1a0f53d4334768d5c1c11ace3013a40c48.html | 8 +-
...lass_8h_1a2ca288baccb3a4e2305a4f0e20e43b54.html | 8 +-
...lass_8h_1a35400e2a96bcc305d505add70359b77f.html | 8 +-
...lass_8h_1a5a1645610efa2f94feb1b0653839eb7d.html | 8 +-
...lass_8h_1aa2c22b4f25336e2bc4326d08c6654080.html | 8 +-
...lass_8h_1ac0c56b2059600296bc93a03d340d3637.html | 8 +-
...lass_8h_1ae661fadd13fbc7aef6e15cddba7607e8.html | 10 +-
...lass_8h_1af7642a00508a88b93e7103a109529a79.html | 8 +-
...ype_8h_1a16f5ec0ba28cdd73f61247f4a662115a.html} | 36 +-
...ype_8h_1a74a70941a707682598886f8475f86848.html} | 34 +-
...ype_8h_1a89696eef7917af8ff34285cb6fae4c63.html} | 32 +-
...type_8h_1a8a71c64237efaa13a8d40dfacd6c3165.html | 8 +-
...type_8h_1a94787950883e5a7e97b764ddd342afc3.html | 8 +-
...ype_8h_1a95190c80d6dfa260c156b00ce5336c83.html} | 36 +-
...dian_8h_1ab4e0ed8000c632cd2c7cd089c0a0d1af.html | 8 +-
...rror_8h_1af4cf9e94df0f183e9c5c0a3ccb05fda5.html | 8 +-
...son_8h_1a0a0dc3202335cbaa265618821764fa2d.html} | 22 +-
...json_8h_1a86217bda8bfebd85f8265878bc8a59b8.html | 8 +-
..._map_8h_1a611844db41026b7a95846dd316b435af.html | 8 +-
...ory_8h_1a6001462e18d71614c0f11a4c2e064f7e.html} | 36 +-
...mory_8h_1a801e8ecc2e3adbc1dac52c714e7cef11.html | 8 +-
...mory_8h_1a8892f2a3cad8dbc51930c464f2ab863b.html | 8 +-
...lection_1a32d91001c82e10566c69e237ab0de50a.html | 10 +-
...lection_1a441e2af5c0ecf1cfa2860cc2fb672dc6.html | 8 +-
...lection_1a4d5446d7f6ef60852e177084e3d57743.html | 8 +-
...lection_1a6b1f837cf822ded72a31f343ce987f4c.html | 8 +-
...lection_1a735285a70c7c4308816450a5b27f03f2.html | 8 +-
...lection_1a80c4984a43d14113b20a67c966833709.html | 8 +-
...lection_1a9321975ab375d35fcf6beb55f1d7d52a.html | 8 +-
...lection_1aba4d7fd771bea88a32803dda191b7044.html | 8 +-
...lection_1ac902a725008e348254ee7a2d07c8a95a.html | 8 +-
...lection_1acc0ded3ead1cc6ffc836005d3bb2cc9c.html | 10 +-
...tion_8h_1a24d1febeb5c1026e7fd66dee9dd9915f.html | 8 +-
...tion_8h_1a56baa5d1ca415dbdebf19ac1f54bd5b7.html | 8 +-
...ring_8h_1a462b67a1ca03cb444893ec950bf5e916.html | 8 +-
...ring_8h_1a88e8350835739df34d48ab4e9d776535.html | 8 +-
...ring_8h_1aa190eed2516ff9a633009cc62f660502.html | 8 +-
...ring_8h_1ad045700080c053c50d68cde298b2b4b2.html | 8 +-
...isit_8h_1a22c788e5e785d50c51b588526601f9cb.html | 8 +-
...isit_8h_1ab94d5197b2b27e397f0bcdef5a63048b.html | 8 +-
...nsor_8h_1a011d0a2dcbe5702156124d7a7223b3dd.html | 8 +-
...nsor_8h_1a226723176642cde5996498e7da6a6368.html | 8 +-
...nsor_8h_1a65b3a61c540c72d9410150a3a7a76dde.html | 8 +-
...nsor_8h_1a71e4a492b5a03a19a95087771a7e9ed1.html | 8 +-
...nsor_8h_1a93094b6b3f20c2cd5aa1c1c2522bc3e4.html | 8 +-
...nsor_8h_1aa79cf4e1e3873d8947050b3cee41153a.html | 8 +-
...nsor_8h_1aab70a15ca1dde710bc3052c5ce1f6fbd.html | 8 +-
...its_8h_1a0d6e075f219808c4ff7adebd99210a7b.html} | 18 +-
..._api_8h_1a08e79db6318f80253199c3eb6c3a61d9.html | 8 +-
..._api_8h_1a1d6ae21c397f551f1f2f12d5d7cdb88a.html | 8 +-
..._api_8h_1a3016d84c6ad28cc7213440c0e2513737.html | 8 +-
..._api_8h_1a309be0e2b6f41e8f602d16931cc4ca38.html | 8 +-
..._api_8h_1a4d4f73e984897c9a4da2d0dccc11e1a1.html | 8 +-
..._api_8h_1a8d6ac296b5142517449c57c387ec8c21.html | 8 +-
..._api_8h_1a8dfc6904c4424309f4a490daaec7ed3e.html | 8 +-
..._api_8h_1a9d158620f8ae2da73b9d5d53eb6151de.html | 8 +-
..._api_8h_1a9f15e6a91d49c1a9d373b9f031edfe69.html | 8 +-
..._api_8h_1aaf09051ae19acf959b1521f9495f1beb.html | 8 +-
..._api_8h_1aaf633b14f4acc686a2f0dc23f6b3367e.html | 8 +-
..._api_8h_1afe299c48605bbb76772042acae7dc6de.html | 8 +-
ffi/reference/cpp/generated/index.html | 434 ++++++++++--
ffi/reference/cpp/generated/namespace_tvm.html | 8 +-
.../cpp/generated/namespace_tvm__ffi.html | 36 +-
.../generated/namespace_tvm__ffi__cuda_api.html | 8 +-
.../cpp/generated/namespace_tvm__ffi__json.html | 10 +-
.../generated/namespace_tvm__ffi__reflection.html | 9 +-
.../namespace_tvm__ffi__reflection__type_attr.html | 13 +-
.../cpp/generated/namespace_tvm__ffi__symbol.html | 8 +-
ffi/reference/cpp/generated/namespace_tvm_ffi.html | 8 +-
ffi/reference/cpp/generated/page_deprecated.html | 8 +-
.../program_listing_file_tvm_ffi_any.h.html | 127 +++-
...rogram_listing_file_tvm_ffi_base_details.h.html | 22 +-
.../program_listing_file_tvm_ffi_c_api.h.html | 25 +-
.../program_listing_file_tvm_ffi_cast.h.html | 36 +-
...ram_listing_file_tvm_ffi_container_array.h.html | 28 +-
...gram_listing_file_tvm_ffi_container_dict.h.html | 28 +-
...gram_listing_file_tvm_ffi_container_list.h.html | 28 +-
...ogram_listing_file_tvm_ffi_container_map.h.html | 28 +-
..._listing_file_tvm_ffi_container_map_base.h.html | 8 +-
..._listing_file_tvm_ffi_container_seq_base.h.html | 8 +-
...ram_listing_file_tvm_ffi_container_shape.h.html | 8 +-
...am_listing_file_tvm_ffi_container_tensor.h.html | 60 +-
...ram_listing_file_tvm_ffi_container_tuple.h.html | 24 +-
...m_listing_file_tvm_ffi_container_variant.h.html | 114 +---
... => program_listing_file_tvm_ffi_device.h.html} | 219 +++---
.../program_listing_file_tvm_ffi_dtype.h.html | 134 +++-
.../program_listing_file_tvm_ffi_endian.h.html | 8 +-
.../program_listing_file_tvm_ffi_enum.h.html | 118 +++-
.../program_listing_file_tvm_ffi_error.h.html | 10 +-
.../program_listing_file_tvm_ffi_expected.h.html | 135 +++-
.../program_listing_file_tvm_ffi_extra_base.h.html | 8 +-
...rogram_listing_file_tvm_ffi_extra_base64.h.html | 8 +-
...ram_listing_file_tvm_ffi_extra_c_env_api.h.html | 8 +-
...ram_listing_file_tvm_ffi_extra_cuda_base.h.html | 8 +-
...g_file_tvm_ffi_extra_cuda_cubin_launcher.h.html | 8 +-
...ing_file_tvm_ffi_extra_cuda_device_guard.h.html | 8 +-
..._tvm_ffi_extra_cuda_internal_unified_api.h.html | 8 +-
...ram_listing_file_tvm_ffi_extra_dataclass.h.html | 8 +-
...program_listing_file_tvm_ffi_extra_dtype.h.html | 8 +-
.../program_listing_file_tvm_ffi_extra_json.h.html | 10 +-
...rogram_listing_file_tvm_ffi_extra_module.h.html | 10 +-
...listing_file_tvm_ffi_extra_serialization.h.html | 8 +-
.../program_listing_file_tvm_ffi_extra_stl.h.html | 8 +-
...ting_file_tvm_ffi_extra_structural_equal.h.html | 10 +-
...sting_file_tvm_ffi_extra_structural_hash.h.html | 8 +-
...isting_file_tvm_ffi_extra_structural_key.h.html | 8 +-
...ting_file_tvm_ffi_extra_structural_visit.h.html | 99 ++-
...g_file_tvm_ffi_extra_visit_error_context.h.html | 8 +-
.../program_listing_file_tvm_ffi_function.h.html | 21 +-
.../program_listing_file_tvm_ffi_memory.h.html | 77 ++-
.../program_listing_file_tvm_ffi_object.h.html | 489 ++++++++++++--
.../program_listing_file_tvm_ffi_optional.h.html | 388 +++++------
...ting_file_tvm_ffi_reflection_access_path.h.html | 16 +-
...listing_file_tvm_ffi_reflection_accessor.h.html | 19 +-
..._listing_file_tvm_ffi_reflection_creator.h.html | 9 +-
...listing_file_tvm_ffi_reflection_enum_def.h.html | 121 ++--
...listing_file_tvm_ffi_reflection_overload.h.html | 38 +-
...listing_file_tvm_ffi_reflection_registry.h.html | 86 ++-
.../program_listing_file_tvm_ffi_rvalue_ref.h.html | 8 +-
.../program_listing_file_tvm_ffi_string.h.html | 8 +-
.../program_listing_file_tvm_ffi_tvm_ffi.h.html | 9 +-
...program_listing_file_tvm_ffi_type_traits.h.html | 464 +++----------
ffi/reference/cpp/generated/structTVMFFIAny.html | 8 +-
.../cpp/generated/structTVMFFIByteArray.html | 8 +-
...adata.html => structTVMFFICustomAllocator.html} | 103 +--
.../cpp/generated/structTVMFFIErrorCell.html | 8 +-
.../cpp/generated/structTVMFFIFieldInfo.html | 8 +-
.../cpp/generated/structTVMFFIFunctionCell.html | 8 +-
.../cpp/generated/structTVMFFIMethodInfo.html | 8 +-
.../cpp/generated/structTVMFFIObject.html | 8 +-
...ray.html => structTVMFFIObjectAllocHeader.html} | 88 +--
.../generated/structTVMFFIOpaqueObjectCell.html | 8 +-
.../cpp/generated/structTVMFFISeqCell.html | 8 +-
.../cpp/generated/structTVMFFIShapeCell.html | 8 +-
.../cpp/generated/structTVMFFITypeAttrColumn.html | 8 +-
.../cpp/generated/structTVMFFITypeInfo.html | 8 +-
.../cpp/generated/structTVMFFITypeMetadata.html | 8 +-
.../cpp/generated/structTVMFFIVersion.html | 8 +-
.../generated/structtvm_1_1ffi_1_1AnyEqual.html | 8 +-
.../cpp/generated/structtvm_1_1ffi_1_1AnyHash.html | 8 +-
.../structtvm_1_1ffi_1_1CUDADeviceGuard.html | 8 +-
...ructtvm_1_1ffi_1_1DenseMapBaseObj_1_1Block.html | 8 +-
...ttvm_1_1ffi_1_1DenseMapBaseObj_1_1ItemType.html | 8 +-
...ttvm_1_1ffi_1_1DenseMapBaseObj_1_1ListNode.html | 8 +-
...structtvm_1_1ffi_1_1FallbackOnlyTraitsBase.html | 8 +-
.../structtvm_1_1ffi_1_1ObjectPtrEqual.html | 8 +-
.../structtvm_1_1ffi_1_1ObjectPtrHash.html | 8 +-
..._1_1ffi_1_1ObjectRefWithFallbackTraitsBase.html | 10 +-
.../structtvm_1_1ffi_1_1StaticTypeKey.html | 10 +-
...tructtvm_1_1ffi_1_1StructuralVisitorVTable.html | 8 +-
...cttvm_1_1ffi_1_1TypeToFieldStaticTypeIndex.html | 10 +-
...structtvm_1_1ffi_1_1TypeToRuntimeTypeIndex.html | 8 +-
.../generated/structtvm_1_1ffi_1_1UnsafeInit.html | 8 +-
.../cpp/generated/structtvm_1_1ffi_1_1dim3.html | 8 +-
.../structtvm_1_1ffi_1_1is__valid__iterator.html | 8 +-
...valid__iterator_3_01Any_00_01IterType_01_4.html | 8 +-
...3_01Optional_3_01T_01_4_00_01IterType_01_4.html | 8 +-
...m_1_1ffi_1_1reflection_1_1FieldInfoBuilder.html | 8 +-
...tructtvm_1_1ffi_1_1reflection_1_1InfoTrait.html | 8 +-
..._1_1ffi_1_1reflection_1_1MethodInfoBuilder.html | 8 +-
..._1_1OverloadObjectDef_1_1RegisteredMethod.html} | 50 +-
.../structtvm_1_1ffi_1_1reflection_1_1init.html | 8 +-
...structtvm_1_1ffi_1_1reflection_1_1init_3_4.html | 8 +-
..._api_8h_1a19fdd3c500a70abb3def842c73694548.html | 8 +-
..._api_8h_1a9eee5afddb1b39723847d67d109c03fe.html | 8 +-
..._api_8h_1aa0abef2444fde82d76337218e5c13b3f.html | 8 +-
..._api_8h_1aba6bf585b03799369fb535db4a5d2e79.html | 8 +-
..._api_8h_1ae22f1a87cbaf7f744d9201948c05d2a5.html | 8 +-
..._api_8h_1aa7abccefa41ac9d3040df689c0c72fa4.html | 8 +-
...json_8h_1a74ca72d0b686c114af683d63e96f2998.html | 8 +-
...json_8h_1a8e808548bb6a99d0a6093ab3e2229ad3.html | 8 +-
...json_8h_1aeb9cdccfbc28034e94e46f9f6bd8d92a.html | 8 +-
...mory_8h_1a65bf625279df21dec5c8097264415113.html | 8 +-
...lection_1a32b044a71a094de492867144ca299c15.html | 8 +-
...lection_1a96513314d45b43eada132d9b96653d9a.html | 8 +-
...isit_8h_1a745d053678181bd38e0fee17b772656b.html | 8 +-
...its_8h_1a7ba296d84188e5970ba854332a1f04a6.html} | 18 +-
...its_8h_1ae125f5f5a8a94c7340577c1959805295.html} | 18 +-
..._api_8h_1a17eed3020dde14e09827a83036143d07.html | 8 +-
..._api_8h_1a3a921bfefc753492061768fced304aa7.html | 8 +-
..._api_8h_1a630f9293b2557ea7cf02fc5dc8975608.html | 8 +-
..._api_8h_1a6378bff570cca29703bf0a888e62c2e1.html | 8 +-
..._api_8h_1a6c2e323543c694ac2fc8e68c40a5fa3d.html | 8 +-
..._api_8h_1a92973dc82316f80c6ad935aafba39418.html | 8 +-
..._api_8h_1ab6a530cbc289dbb52b705f00c8095fc7.html | 8 +-
..._api_8h_1ae60e2c3b6b2591a181c9b0ff8905c2fb.html | 8 +-
ffi/reference/cpp/generated/unabridged_orphan.html | 29 +-
...rray_8h_1a3bbf4c2bf19b72b026ad9e19a23143d5.html | 8 +-
...dule_8h_1a07576e172e0788da4982148edcf53b05.html | 8 +-
...dule_8h_1a5a3a8ad10620c05ded5876f8e607e0eb.html | 8 +-
...dule_8h_1a76f8a8fd1e38fd98cc501623d959ee58.html | 8 +-
...dule_8h_1aae0405c7615139afd4f68b72a862cffe.html | 8 +-
...dule_8h_1ac261d9ce6ffb49dd9878610ce217075e.html | 8 +-
...dule_8h_1ad9c186f1359987cef9278993037b3f66.html | 8 +-
...e__attr_1a096d266d5a2b4523f98f044de310489d.html | 8 +-
...e__attr_1a121b81bcda7ce56913cd5cee586ab85f.html | 8 +-
...e__attr_1a18dd88667c1998578f7fdbbf25c9a33d.html | 8 +-
...e__attr_1a214da76aef89b240bf763409cc7ce8f4.html | 12 +-
...e__attr_1a2235b3faf38b1017a13ef6178d9a8fa8.html | 551 ---------------
...e__attr_1a23d22935800d0c4ccefe7a3a0b9a44c0.html | 14 +-
...e__attr_1a3a4fa9be3e1bd6c285c731f0b805fdd2.html | 8 +-
...e__attr_1a4e67838e846b587f2f82127c53b6ef86.html | 8 +-
...e__attr_1a8473fde721d924e9ffb48fc818f6b609.html | 8 +-
...__attr_1a877b4867a278823be18e6c7f7bff378e.html} | 32 +-
...e__attr_1a8ad904131880910d82adfd8e695fe259.html | 12 +-
...e__attr_1a9a2230acd6ebfab403460ad574a1c53b.html | 8 +-
...__attr_1ab8b34ca1b301024a7f48d226906bf5c1.html} | 33 +-
...e__attr_1abfb8210e9d25dea8ac19ae403e4d09f7.html | 8 +-
...e__attr_1ac49c0e8607e2a8fe80b5a02250330955.html | 8 +-
...e__attr_1ac92fdfe731cfda2d51324cea574c7e08.html | 8 +-
...e__attr_1ade6e6dd8a1abc985d20d7e855a30b7ea.html | 8 +-
...e__attr_1ae970768fd777e6c1dd312de67bfba39c.html | 8 +-
...lection_1aab5d2ed0a499b8237fedeead671a3fa0.html | 8 +-
...ect_8h_1a31dc4b1b71941b3e4217a0e389f807a4.html} | 37 +-
...ect_8h_1a5f52cb03b4b23d5d7738ff0386335845.html} | 37 +-
...its_8h_1a62ef22ceb232bddd3e9540895af38cc1.html} | 37 +-
..._api_8h_1acd118a980ee3e7e77dd76858652255a3.html | 8 +-
ffi/reference/cpp/index.html | 8 +-
.../python/cpp/generated/tvm_ffi.cpp.build.html | 8 +-
.../cpp/generated/tvm_ffi.cpp.build_inline.html | 8 +-
.../python/cpp/generated/tvm_ffi.cpp.load.html | 8 +-
.../cpp/generated/tvm_ffi.cpp.load_inline.html | 8 +-
.../generated/tvm_ffi.cpp.nvrtc.nvrtc_compile.html | 8 +-
.../generated/tvm_ffi.libinfo.load_lib_module.html | 8 +-
ffi/reference/python/generated/tvm_ffi.Array.html | 8 +-
.../python/generated/tvm_ffi.DLDeviceType.html | 8 +-
.../python/generated/tvm_ffi.Device_class.html | 8 +-
.../python/generated/tvm_ffi.Function.html | 8 +-
ffi/reference/python/generated/tvm_ffi.Map.html | 8 +-
ffi/reference/python/generated/tvm_ffi.Module.html | 8 +-
ffi/reference/python/generated/tvm_ffi.Object.html | 8 +-
.../generated/tvm_ffi.ObjectConvertible.html | 8 +-
ffi/reference/python/generated/tvm_ffi.Shape.html | 8 +-
.../python/generated/tvm_ffi.StreamContext.html | 8 +-
.../python/generated/tvm_ffi.StructuralKey.html | 8 +-
.../generated/tvm_ffi.StructuralVisitor.html | 76 +--
ffi/reference/python/generated/tvm_ffi.Tensor.html | 37 +-
.../python/generated/tvm_ffi.VisitInterrupt.html | 42 +-
.../python/generated/tvm_ffi.WalkOrder.html | 8 +-
.../python/generated/tvm_ffi.WalkResult.html | 8 +-
.../generated/tvm_ffi.access_path.AccessKind.html | 8 +-
.../generated/tvm_ffi.access_path.AccessPath.html | 8 +-
.../generated/tvm_ffi.access_path.AccessStep.html | 8 +-
.../python/generated/tvm_ffi.convert.html | 8 +-
.../python/generated/tvm_ffi.convert_func.html | 8 +-
.../python/generated/tvm_ffi.device_function.html | 8 +-
ffi/reference/python/generated/tvm_ffi.dtype.html | 83 ++-
.../python/generated/tvm_ffi.from_dlpack.html | 8 +-
.../tvm_ffi.get_first_structural_mismatch.html | 8 +-
.../python/generated/tvm_ffi.get_global_func.html | 8 +-
.../tvm_ffi.get_global_func_metadata.html | 8 +-
.../python/generated/tvm_ffi.get_raw_stream.html | 8 +-
.../python/generated/tvm_ffi.init_ffi_api.html | 8 +-
.../python/generated/tvm_ffi.load_module.html | 8 +-
.../python/generated/tvm_ffi.register_error.html | 8 +-
.../generated/tvm_ffi.register_global_func.html | 8 +-
.../python/generated/tvm_ffi.register_object.html | 8 +-
.../generated/tvm_ffi.remove_global_func.html | 8 +-
.../tvm_ffi.serialization.from_json_graph_str.html | 8 +-
.../tvm_ffi.serialization.to_json_graph_str.html | 8 +-
.../python/generated/tvm_ffi.structural_equal.html | 8 +-
.../python/generated/tvm_ffi.structural_hash.html | 8 +-
.../python/generated/tvm_ffi.structural_walk.html | 8 +-
.../python/generated/tvm_ffi.system_lib.html | 8 +-
.../python/generated/tvm_ffi.use_raw_stream.html | 8 +-
.../python/generated/tvm_ffi.use_torch_stream.html | 8 +-
ffi/reference/python/index.html | 10 +-
ffi/reference/rust/generated/help.html | 2 +-
.../rust/generated/search.index/012ad86275.js | 1 -
.../rust/generated/search.index/014ad42df5.js | 1 +
.../rust/generated/search.index/02abae5593.js | 1 +
.../rust/generated/search.index/02b3daffb7.js | 1 +
.../rust/generated/search.index/03880ffc1f.js | 1 +
.../rust/generated/search.index/04da9583bf.js | 1 +
.../rust/generated/search.index/057cfc5ba5.js | 1 -
.../rust/generated/search.index/0608efeea5.js | 1 -
.../rust/generated/search.index/06c5065640.js | 1 +
.../rust/generated/search.index/0767ec2da8.js | 1 -
.../rust/generated/search.index/08c5e90b58.js | 1 +
.../rust/generated/search.index/090638f50b.js | 1 +
.../rust/generated/search.index/09608c20f0.js | 1 +
.../rust/generated/search.index/0c99e4a013.js | 1 -
.../rust/generated/search.index/0cb25fd403.js | 1 -
.../rust/generated/search.index/0cfcef2d4c.js | 1 -
.../rust/generated/search.index/0de02830c7.js | 1 +
.../rust/generated/search.index/0e2e56bc85.js | 1 +
.../rust/generated/search.index/0ed8b1796c.js | 1 -
.../rust/generated/search.index/1066cc8132.js | 1 -
.../rust/generated/search.index/13cac0fcb4.js | 1 -
.../rust/generated/search.index/14ada96ae9.js | 1 +
.../rust/generated/search.index/1517b5f660.js | 1 -
.../rust/generated/search.index/1526b464d0.js | 1 +
.../rust/generated/search.index/1640365aad.js | 1 +
.../rust/generated/search.index/16d2701400.js | 1 +
.../rust/generated/search.index/1874fa6599.js | 1 -
.../rust/generated/search.index/194b0a2523.js | 1 -
.../rust/generated/search.index/1a760ccfdd.js | 1 +
.../rust/generated/search.index/1a7e5588ab.js | 1 -
.../rust/generated/search.index/1b3dabf362.js | 1 -
.../rust/generated/search.index/1b6f3c8f45.js | 1 +
.../rust/generated/search.index/20250b02ab.js | 1 -
.../rust/generated/search.index/2079b546aa.js | 1 -
.../rust/generated/search.index/20ae23d0d7.js | 1 +
.../rust/generated/search.index/213b091e60.js | 1 +
.../rust/generated/search.index/2211e1f188.js | 1 +
.../rust/generated/search.index/2261dfbe6c.js | 1 -
.../rust/generated/search.index/22bb56afb4.js | 1 -
.../rust/generated/search.index/23248e4482.js | 1 +
.../rust/generated/search.index/2390369a15.js | 1 +
.../rust/generated/search.index/24c5a6e24c.js | 1 +
.../rust/generated/search.index/2558a89e59.js | 1 +
.../rust/generated/search.index/25678b095e.js | 1 -
.../rust/generated/search.index/25ef0bc7c2.js | 1 +
.../rust/generated/search.index/264721b38f.js | 1 -
.../rust/generated/search.index/26675ee0db.js | 1 -
.../rust/generated/search.index/27ed5aa176.js | 1 +
.../rust/generated/search.index/2a61e6f784.js | 1 -
.../rust/generated/search.index/2b24a0996a.js | 1 -
.../rust/generated/search.index/2cc30a1e1c.js | 1 +
.../rust/generated/search.index/2e1b5ef6d1.js | 1 +
.../rust/generated/search.index/2e83926317.js | 1 -
.../rust/generated/search.index/3288422d55.js | 1 +
.../rust/generated/search.index/3300796c1e.js | 1 +
.../rust/generated/search.index/33cfad308e.js | 1 -
.../rust/generated/search.index/349a7cc4a2.js | 1 +
.../rust/generated/search.index/366b70d816.js | 1 +
.../rust/generated/search.index/367cd93e88.js | 1 +
.../rust/generated/search.index/36f75f7628.js | 1 -
.../rust/generated/search.index/3713965681.js | 1 -
.../rust/generated/search.index/37c59e9c13.js | 1 -
.../rust/generated/search.index/3a28bf184b.js | 1 +
.../rust/generated/search.index/3abe0165b0.js | 1 -
.../rust/generated/search.index/3ae44ed4f8.js | 1 +
.../rust/generated/search.index/3b8a8d10f6.js | 1 -
.../rust/generated/search.index/3c4bd39487.js | 1 +
.../rust/generated/search.index/3d1c8d2044.js | 1 -
.../rust/generated/search.index/40a121933f.js | 1 -
.../rust/generated/search.index/40a2d5e797.js | 1 +
.../rust/generated/search.index/40d2b8b6c9.js | 1 -
.../rust/generated/search.index/439e7c4ef8.js | 1 +
.../rust/generated/search.index/43a7cedd4c.js | 1 -
.../rust/generated/search.index/46b139edc1.js | 1 +
.../rust/generated/search.index/4795a1b3e5.js | 1 -
.../rust/generated/search.index/47be53b38a.js | 1 -
.../rust/generated/search.index/498f1f2759.js | 1 +
.../rust/generated/search.index/49e50cdbf7.js | 1 +
.../rust/generated/search.index/4a526b93df.js | 1 +
.../rust/generated/search.index/4c16e16bb9.js | 1 -
.../rust/generated/search.index/4c5fa0db30.js | 1 -
.../rust/generated/search.index/4c7034cf06.js | 1 +
.../rust/generated/search.index/4d0bc21d47.js | 1 -
.../rust/generated/search.index/4dcfe70f9c.js | 1 +
.../rust/generated/search.index/4e8d8b47b6.js | 1 +
.../rust/generated/search.index/4eb12ccd4e.js | 1 +
.../rust/generated/search.index/4ebfbf9f8a.js | 1 +
.../rust/generated/search.index/4f18ab411f.js | 1 +
.../rust/generated/search.index/4f6fe8899f.js | 1 -
.../rust/generated/search.index/50bae02804.js | 1 +
.../rust/generated/search.index/519b306788.js | 1 +
.../rust/generated/search.index/5223bbe402.js | 1 -
.../rust/generated/search.index/528d1bbf10.js | 1 -
.../rust/generated/search.index/53011583d1.js | 1 +
.../rust/generated/search.index/556db50e6e.js | 1 -
.../rust/generated/search.index/5674ded209.js | 1 +
.../rust/generated/search.index/5a8a41f10e.js | 1 +
.../rust/generated/search.index/5ae3325ff3.js | 1 -
.../rust/generated/search.index/5c545dac50.js | 1 +
.../rust/generated/search.index/5c9ad87aaa.js | 1 -
.../rust/generated/search.index/5ce75ba522.js | 1 -
.../rust/generated/search.index/5dacdb81f3.js | 1 -
.../rust/generated/search.index/5e0e43c8ab.js | 1 -
.../rust/generated/search.index/5e4104fa76.js | 1 +
.../rust/generated/search.index/5f6110eda3.js | 1 -
.../rust/generated/search.index/5fb7eb2b7f.js | 1 -
.../rust/generated/search.index/6065565ba5.js | 1 -
.../rust/generated/search.index/60e2df7318.js | 1 -
.../rust/generated/search.index/613cf6fa79.js | 1 +
.../rust/generated/search.index/615dbbf8de.js | 1 +
.../rust/generated/search.index/62c9e44dc5.js | 1 -
.../rust/generated/search.index/635478f9a6.js | 1 +
.../rust/generated/search.index/64593ded55.js | 1 +
.../rust/generated/search.index/647df28775.js | 1 -
.../rust/generated/search.index/64b24a88f3.js | 1 -
.../rust/generated/search.index/6652151f16.js | 1 -
.../rust/generated/search.index/6808adbc5d.js | 1 +
.../rust/generated/search.index/6946ce6eae.js | 1 +
.../rust/generated/search.index/6b4046140c.js | 1 +
.../rust/generated/search.index/6bb1d0fa68.js | 1 +
.../rust/generated/search.index/6bb6494666.js | 1 -
.../rust/generated/search.index/6d505ec01a.js | 1 -
.../rust/generated/search.index/6d6137551d.js | 1 +
.../rust/generated/search.index/6f5c25335b.js | 1 +
.../rust/generated/search.index/70b6bb09e3.js | 1 -
.../rust/generated/search.index/7135246e23.js | 1 +
.../rust/generated/search.index/71e6794cf3.js | 1 -
.../rust/generated/search.index/72892d891f.js | 1 -
.../rust/generated/search.index/741c0611ab.js | 1 -
.../rust/generated/search.index/74d391209c.js | 1 +
.../rust/generated/search.index/759ac4704d.js | 1 +
.../rust/generated/search.index/7600693289.js | 1 -
.../rust/generated/search.index/762fc66810.js | 1 -
.../rust/generated/search.index/76713e928e.js | 1 +
.../rust/generated/search.index/76a574ef6f.js | 1 +
.../rust/generated/search.index/7821fd8857.js | 1 +
.../rust/generated/search.index/78ce13a1b0.js | 1 +
.../rust/generated/search.index/79189d35e4.js | 1 +
.../rust/generated/search.index/79264ff393.js | 1 +
.../rust/generated/search.index/7b40ac4ecc.js | 1 -
.../rust/generated/search.index/7ba3f70ae8.js | 1 -
.../rust/generated/search.index/7bad74fb42.js | 1 +
.../rust/generated/search.index/7bb2da08d5.js | 1 -
.../rust/generated/search.index/7e2edbb657.js | 1 +
.../rust/generated/search.index/7ee2a3bd8e.js | 1 -
.../rust/generated/search.index/7f47f44c24.js | 1 +
.../rust/generated/search.index/desc/3678570e24.js | 1 -
.../rust/generated/search.index/desc/85e20af3c7.js | 1 +
.../generated/search.index/entry/0bfeb5108c.js | 1 -
.../generated/search.index/entry/64934a3512.js | 1 +
.../generated/search.index/function/55b0253df3.js | 1 -
.../generated/search.index/function/f73cc72bed.js | 1 +
.../generic_inverted_index/4e48fe7413.js | 1 -
.../generic_inverted_index/e7c6afe569.js | 1 +
.../rust/generated/search.index/name/76a0c7776c.js | 1 -
.../rust/generated/search.index/name/86dab72096.js | 1 +
.../search.index/normalizedName/d5636e96ab.js | 1 -
.../search.index/normalizedName/d6a98e06c8.js | 1 +
.../rust/generated/search.index/path/76924cc47b.js | 1 -
.../rust/generated/search.index/path/ce90a8ab06.js | 1 +
ffi/reference/rust/generated/search.index/root.js | 2 +-
.../rust/generated/search.index/type/0b1830dbb3.js | 1 -
.../rust/generated/search.index/type/a0106e3604.js | 1 +
ffi/reference/rust/generated/settings.html | 2 +-
ffi/reference/rust/generated/src-files.js | 4 +-
.../rust/generated/src/tvm_ffi/any.rs.html | 519 +++++++-------
.../src/tvm_ffi/collections/array.rs.html | 4 +-
.../generated/src/tvm_ffi/collections/map.rs.html | 528 +++++++++++++++
.../generated/src/tvm_ffi/collections/mod.rs.html | 7 +-
.../src/tvm_ffi/collections/shape.rs.html | 2 +-
.../src/tvm_ffi/collections/tensor.rs.html | 2 +-
.../rust/generated/src/tvm_ffi/derive.rs.html | 2 +-
.../rust/generated/src/tvm_ffi/device.rs.html | 2 +-
.../rust/generated/src/tvm_ffi/dtype.rs.html | 2 +-
.../rust/generated/src/tvm_ffi/error.rs.html | 2 +-
.../rust/generated/src/tvm_ffi/extra/mod.rs.html | 2 +-
.../generated/src/tvm_ffi/extra/module.rs.html | 46 +-
.../rust/generated/src/tvm_ffi/function.rs.html | 2 +-
.../src/tvm_ffi/function_internal.rs.html | 107 +--
.../rust/generated/src/tvm_ffi/lib.rs.html | 54 +-
.../rust/generated/src/tvm_ffi/macros.rs.html | 745 +++++++++++----------
.../rust/generated/src/tvm_ffi/object.rs.html | 511 +++++++-------
.../rust/generated/src/tvm_ffi/optional.rs.html | 201 ++++++
.../rust/generated/src/tvm_ffi/string.rs.html | 2 +-
.../rust/generated/src/tvm_ffi/type_traits.rs.html | 2 +-
.../rust/generated/src/tvm_ffi_macros/lib.rs.html | 43 +-
.../generated/src/tvm_ffi_macros/match_any.rs.html | 162 +++++
.../src/tvm_ffi_macros/object_macros.rs.html | 2 +-
.../generated/src/tvm_ffi_macros/utils.rs.html | 113 ++--
.../rust/generated/src/tvm_ffi_sys/c_api.rs.html | 146 ++--
.../generated/src/tvm_ffi_sys/c_env_api.rs.html | 2 +-
.../rust/generated/src/tvm_ffi_sys/dlpack.rs.html | 2 +-
.../rust/generated/src/tvm_ffi_sys/lib.rs.html | 2 +-
.../{main-5013f961.js => main-fcd733ba.js} | 4 +-
.../rust/generated/static.files/search-b5634cc7.js | 5 -
.../rust/generated/static.files/search-fd9372ac.js | 5 +
.../generated/trait.impl/core/clone/trait.Clone.js | 4 +-
.../rust/generated/trait.impl/core/cmp/trait.Eq.js | 4 +-
.../generated/trait.impl/core/cmp/trait.Ord.js | 2 +-
.../trait.impl/core/cmp/trait.PartialEq.js | 4 +-
.../trait.impl/core/cmp/trait.PartialOrd.js | 2 +-
.../trait.impl/core/convert/trait.From.js | 4 +-
.../trait.impl/core/convert/trait.TryFrom.js | 4 +-
.../trait.impl/core/default/trait.Default.js | 4 +-
.../generated/trait.impl/core/error/trait.Error.js | 2 +-
.../generated/trait.impl/core/fmt/trait.Debug.js | 4 +-
.../generated/trait.impl/core/fmt/trait.Display.js | 2 +-
.../generated/trait.impl/core/hash/trait.Hash.js | 2 +-
.../core/iter/traits/collect/trait.FromIterator.js | 4 +-
.../core/iter/traits/collect/trait.IntoIterator.js | 4 +-
.../traits/exact_size/trait.ExactSizeIterator.js | 9 +
.../core/iter/traits/iterator/trait.Iterator.js | 4 +-
.../generated/trait.impl/core/marker/trait.Copy.js | 2 +-
.../trait.impl/core/marker/trait.Freeze.js | 4 +-
.../generated/trait.impl/core/marker/trait.Send.js | 4 +-
.../core/marker/trait.StructuralPartialEq.js | 2 +-
.../generated/trait.impl/core/marker/trait.Sync.js | 4 +-
.../trait.impl/core/marker/trait.Unpin.js | 4 +-
.../trait.impl/core/marker/trait.UnsafeUnpin.js | 4 +-
.../trait.impl/core/ops/deref/trait.Deref.js | 4 +-
.../trait.impl/core/ops/deref/trait.DerefMut.js | 2 +-
.../trait.impl/core/ops/drop/trait.Drop.js | 2 +-
.../trait.impl/core/ops/index/trait.Index.js | 2 +-
.../core/panic/unwind_safe/trait.RefUnwindSafe.js | 4 +-
.../core/panic/unwind_safe/trait.UnwindSafe.js | 4 +-
ffi/reference/rust/generated/tvm_ffi/all.html | 2 +-
.../rust/generated/tvm_ffi/any/index.html | 2 +-
.../rust/generated/tvm_ffi/any/struct.Any.html | 35 +-
.../rust/generated/tvm_ffi/any/struct.AnyView.html | 34 +-
.../generated/tvm_ffi/any/struct.TryFromTemp.html | 40 +-
.../generated/tvm_ffi/collections/array/index.html | 2 +-
.../tvm_ffi/collections/array/struct.Array.html | 40 +-
.../collections/array/struct.ArrayIterator.html | 408 +++++------
.../tvm_ffi/collections/array/struct.ArrayObj.html | 36 +-
.../rust/generated/tvm_ffi/collections/index.html | 2 +-
.../generated/tvm_ffi/collections/map/index.html | 18 +
.../tvm_ffi/collections/map/sidebar-items.js | 1 +
.../tvm_ffi/collections/map/struct.Map.html | 66 ++
.../tvm_ffi/collections/map/struct.MapIter.html | 213 ++++++
.../tvm_ffi/collections/map/struct.MapObj.html | 31 +
.../tvm_ffi/collections/map/type.MapItems.html | 2 +
.../tvm_ffi/collections/map/type.MapKeys.html | 2 +
.../tvm_ffi/collections/map/type.MapValues.html | 2 +
.../generated/tvm_ffi/collections/shape/index.html | 2 +-
.../tvm_ffi/collections/shape/struct.Shape.html | 368 +++++-----
.../tvm_ffi/collections/shape/struct.ShapeObj.html | 22 +-
.../generated/tvm_ffi/collections/sidebar-items.js | 2 +-
.../tvm_ffi/collections/tensor/index.html | 2 +-
.../collections/tensor/struct.CPUNDAlloc.html | 22 +-
.../tvm_ffi/collections/tensor/struct.Tensor.html | 42 +-
.../collections/tensor/struct.TensorObj.html | 22 +-
.../collections/tensor/trait.DLTensorExt.html | 8 +-
.../collections/tensor/trait.NDAllocator.html | 16 +-
.../generated/tvm_ffi/derive/derive.Object.html | 2 +-
.../generated/tvm_ffi/derive/derive.ObjectRef.html | 2 +-
.../rust/generated/tvm_ffi/derive/index.html | 2 +-
.../tvm_ffi/device/fn.current_stream.html | 2 +-
.../generated/tvm_ffi/device/fn.with_stream.html | 4 +-
.../rust/generated/tvm_ffi/device/index.html | 2 +-
.../rust/generated/tvm_ffi/dtype/index.html | 2 +-
.../tvm_ffi/dtype/trait.AsDLDataType.html | 4 +-
.../tvm_ffi/dtype/trait.DLDataTypeExt.html | 8 +-
.../generated/tvm_ffi/enum.DLDataTypeCode.html | 28 +-
.../rust/generated/tvm_ffi/enum.DLDeviceType.html | 28 +-
.../rust/generated/tvm_ffi/enum.TypeIndex.html | 28 +-
.../tvm_ffi/error/constant.ATTRIBUTE_ERROR.html | 2 +-
.../tvm_ffi/error/constant.INDEX_ERROR.html | 2 +-
.../tvm_ffi/error/constant.KEY_ERROR.html | 2 +-
.../tvm_ffi/error/constant.RUNTIME_ERROR.html | 2 +-
.../tvm_ffi/error/constant.TYPE_ERROR.html | 2 +-
.../tvm_ffi/error/constant.VALUE_ERROR.html | 2 +-
.../rust/generated/tvm_ffi/error/index.html | 2 +-
.../rust/generated/tvm_ffi/error/struct.Error.html | 44 +-
.../generated/tvm_ffi/error/struct.ErrorKind.html | 30 +-
.../generated/tvm_ffi/error/struct.ErrorObj.html | 24 +-
.../rust/generated/tvm_ffi/error/type.Result.html | 2 +-
.../rust/generated/tvm_ffi/extra/index.html | 2 +-
.../rust/generated/tvm_ffi/extra/module/index.html | 2 +-
.../tvm_ffi/extra/module/struct.Module.html | 32 +-
.../tvm_ffi/extra/module/struct.ModuleObj.html | 24 +-
.../rust/generated/tvm_ffi/function/index.html | 2 +-
.../tvm_ffi/function/struct.Function.html | 42 +-
.../tvm_ffi/function/struct.FunctionObj.html | 24 +-
.../function_internal/fn.call_packed_callable.html | 2 +-
.../generated/tvm_ffi/function_internal/index.html | 2 +-
.../function_internal/trait.ArgIntoRef.html | 4 +-
.../function_internal/trait.AsPackedCallable.html | 54 +-
.../function_internal/trait.IntoArgHolder.html | 4 +-
.../trait.IntoArgHolderTuple.html | 18 +-
.../function_internal/trait.TupleAsPackedArgs.html | 22 +-
ffi/reference/rust/generated/tvm_ffi/index.html | 7 +-
.../generated/tvm_ffi/macro.attach_context.html | 2 +-
.../rust/generated/tvm_ffi/macro.bail.html | 2 +-
.../tvm_ffi/macro.cached_global_func!.html | 11 +
.../tvm_ffi/macro.cached_global_func.html | 8 +
.../generated/tvm_ffi/macro.check_safe_call.html | 2 +-
.../rust/generated/tvm_ffi/macro.ensure.html | 2 +-
.../generated/tvm_ffi/macro.function_name.html | 2 +-
.../generated/tvm_ffi/macro.impl_arg_into_ref.html | 2 +-
.../macro.impl_into_arg_holder_default.html | 2 +-
.../generated/tvm_ffi/macro.impl_try_from_any.html | 2 +-
.../macro.impl_try_from_any_for_parametric.html | 2 +-
.../generated/tvm_ffi/macro.into_typed_fn.html | 2 +-
.../rust/generated/tvm_ffi/macro.match_any!.html | 11 +
.../rust/generated/tvm_ffi/macro.match_any.html | 5 +
.../macro.tvm_ffi_dll_export_typed_func.html | 2 +-
.../rust/generated/tvm_ffi/macros/index.html | 2 +-
.../generated/tvm_ffi/object/enum.TypeIndex.html | 28 +-
.../rust/generated/tvm_ffi/object/index.html | 2 +-
.../generated/tvm_ffi/object/struct.Object.html | 24 +-
.../generated/tvm_ffi/object/struct.ObjectArc.html | 51 +-
.../generated/tvm_ffi/object/struct.ObjectRef.html | 28 +-
.../generated/tvm_ffi/object/trait.ObjectCore.html | 12 +-
.../object/trait.ObjectCoreWithExtraItems.html | 8 +-
.../tvm_ffi/object/trait.ObjectRefCore.html | 4 +-
.../rust/generated/tvm_ffi/optional/index.html | 16 +
.../generated/tvm_ffi/optional/sidebar-items.js | 1 +
.../tvm_ffi/optional/struct.Optional.html | 36 +
.../rust/generated/tvm_ffi/sidebar-items.js | 2 +-
.../rust/generated/tvm_ffi/string/index.html | 2 +-
.../generated/tvm_ffi/string/struct.Bytes.html | 421 ++++++------
.../generated/tvm_ffi/string/struct.String.html | 612 +++++++++--------
.../rust/generated/tvm_ffi/struct.DLDataType.html | 42 +-
.../rust/generated/tvm_ffi/struct.DLDevice.html | 34 +-
.../rust/generated/tvm_ffi/struct.TVMFFIAny.html | 40 +-
.../generated/tvm_ffi/struct.TVMFFIObject.html | 30 +-
.../generated/tvm_ffi/type.TVMFFIStreamHandle.html | 2 +-
.../rust/generated/tvm_ffi/type_traits/index.html | 2 +-
.../tvm_ffi/type_traits/trait.AnyCompatible.html | 30 +-
.../rust/generated/tvm_ffi_macros/all.html | 2 +-
.../generated/tvm_ffi_macros/derive.Object.html | 2 +-
.../generated/tvm_ffi_macros/derive.ObjectRef.html | 2 +-
.../rust/generated/tvm_ffi_macros/index.html | 2 +-
.../generated/tvm_ffi_macros/macro.match_any!.html | 11 +
.../generated/tvm_ffi_macros/macro.match_any.html | 5 +
.../rust/generated/tvm_ffi_macros/sidebar-items.js | 2 +-
ffi/reference/rust/generated/tvm_ffi_sys/all.html | 2 +-
.../constant.COMBINED_REF_COUNT_BOTH_ONE.html | 2 +-
.../constant.COMBINED_REF_COUNT_MASK_U32.html | 2 +-
.../constant.COMBINED_REF_COUNT_STRONG_ONE.html | 2 +-
.../constant.COMBINED_REF_COUNT_WEAK_ONE.html | 2 +-
.../c_api/enum.TVMFFIBacktraceUpdateMode.html | 28 +-
.../c_api/enum.TVMFFIObjectDeleterFlagBitMask.html | 28 +-
.../tvm_ffi_sys/c_api/enum.TVMFFITypeIndex.html | 28 +-
.../c_api/fn.TVMFFIAnyViewToOwnedAny.html | 8 +-
.../c_api/fn.TVMFFIBytesFromByteArray.html | 8 +-
.../c_api/fn.TVMFFIDataTypeFromString.html | 8 +-
.../c_api/fn.TVMFFIDataTypeToString.html | 8 +-
.../tvm_ffi_sys/c_api/fn.TVMFFIErrorCreate.html | 12 +-
.../c_api/fn.TVMFFIErrorMoveFromRaised.html | 4 +-
.../tvm_ffi_sys/c_api/fn.TVMFFIErrorSetRaised.html | 2 +-
.../c_api/fn.TVMFFIErrorSetRaisedFromCStr.html | 6 +-
.../tvm_ffi_sys/c_api/fn.TVMFFIFunctionCall.html | 10 +-
.../tvm_ffi_sys/c_api/fn.TVMFFIFunctionCreate.html | 10 +-
.../c_api/fn.TVMFFIFunctionGetGlobal.html | 8 +-
.../c_api/fn.TVMFFIFunctionSetGlobal.html | 8 +-
...arget.html => fn.TVMFFIGetCustomAllocator.html} | 2 +-
.../tvm_ffi_sys/c_api/fn.TVMFFIGetTypeInfo.html | 6 +-
...arget.html => fn.TVMFFISetCustomAllocator.html} | 4 +-
.../c_api/fn.TVMFFIStringFromByteArray.html | 8 +-
.../c_api/fn.TVMFFITensorFromDLPack.html | 12 +-
.../c_api/fn.TVMFFITensorFromDLPackVersioned.html | 12 +-
.../tvm_ffi_sys/c_api/fn.TVMFFITensorToDLPack.html | 6 +-
.../c_api/fn.TVMFFITensorToDLPackVersioned.html | 6 +-
.../c_api/fn.TVMFFITestingDummyTarget.html | 2 +-
.../tvm_ffi_sys/c_api/fn.TVMFFITraceback.html | 12 +-
.../tvm_ffi_sys/c_api/fn.TVMFFITypeKeyToIndex.html | 8 +-
.../rust/generated/tvm_ffi_sys/c_api/index.html | 3 +-
.../generated/tvm_ffi_sys/c_api/sidebar-items.js | 2 +-
.../tvm_ffi_sys/c_api/struct.TVMFFIAny.html | 34 +-
.../tvm_ffi_sys/c_api/struct.TVMFFIByteArray.html | 30 +-
.../c_api/struct.TVMFFICustomAllocator.html | 15 +
.../tvm_ffi_sys/c_api/struct.TVMFFIErrorCell.html | 24 +-
.../tvm_ffi_sys/c_api/struct.TVMFFIFieldInfo.html | 50 +-
.../c_api/struct.TVMFFIFunctionCell.html | 24 +-
.../tvm_ffi_sys/c_api/struct.TVMFFIMethodInfo.html | 26 +-
.../tvm_ffi_sys/c_api/struct.TVMFFIObject.html | 30 +-
.../c_api/struct.TVMFFIObjectAllocHeader.html | 15 +
.../tvm_ffi_sys/c_api/struct.TVMFFIShapeCell.html | 26 +-
.../c_api/struct.TVMFFITypeAttrColumn.html | 34 +-
.../tvm_ffi_sys/c_api/struct.TVMFFITypeInfo.html | 58 +-
.../c_api/struct.TVMFFITypeMetadata.html | 34 +-
.../tvm_ffi_sys/c_api/type.TVMFFIFieldGetter.html | 2 +-
.../tvm_ffi_sys/c_api/type.TVMFFIFieldSetter.html | 2 +-
.../c_api/type.TVMFFIObjectCreator.html | 2 +-
.../c_api/type.TVMFFIObjectDeleter.html | 2 +-
.../tvm_ffi_sys/c_api/type.TVMFFIObjectHandle.html | 2 +-
.../tvm_ffi_sys/c_api/type.TVMFFISafeCallType.html | 2 +-
.../c_api/union.TVMFFIAnyDataUnion.html | 54 +-
.../c_env_api/fn.TVMFFIEnvCheckSignals.html | 2 +-
...n.TVMFFIEnvGetDLPackManagedTensorAllocator.html | 2 +-
.../c_env_api/fn.TVMFFIEnvGetStream.html | 6 +-
.../fn.TVMFFIEnvModLookupFromImports.html | 8 +-
.../fn.TVMFFIEnvModRegisterContextSymbol.html | 8 +-
.../fn.TVMFFIEnvModRegisterSystemLibSymbol.html | 8 +-
.../c_env_api/fn.TVMFFIEnvRegisterCAPI.html | 8 +-
...n.TVMFFIEnvSetDLPackManagedTensorAllocator.html | 8 +-
.../c_env_api/fn.TVMFFIEnvSetStream.html | 10 +-
.../generated/tvm_ffi_sys/c_env_api/index.html | 2 +-
.../type.DLPackManagedTensorAllocator.html | 2 +-
.../c_env_api/type.TVMFFIStreamHandle.html | 2 +-
.../tvm_ffi_sys/dlpack/enum.DLDataTypeCode.html | 28 +-
.../tvm_ffi_sys/dlpack/enum.DLDeviceType.html | 28 +-
.../rust/generated/tvm_ffi_sys/dlpack/index.html | 2 +-
.../tvm_ffi_sys/dlpack/struct.DLDataType.html | 34 +-
.../tvm_ffi_sys/dlpack/struct.DLDevice.html | 30 +-
.../tvm_ffi_sys/dlpack/struct.DLTensor.html | 48 +-
.../rust/generated/tvm_ffi_sys/index.html | 2 +-
.../generated/type.impl/core/result/enum.Result.js | 4 +-
.../generated/type.impl/std/primitive.pointer.js | 2 +-
.../tvm_ffi/collections/map/struct.MapIter.js | 9 +
ffi/reference/rust/index.html | 8 +-
ffi/search.html | 125 +++-
ffi/searchindex.js | 2 +-
1120 files changed, 15073 insertions(+), 9947 deletions(-)
diff --git a/ffi/_modules/index.html b/ffi/_modules/index.html
index 796c60d7fb9..c64ae08273c 100644
--- a/ffi/_modules/index.html
+++ b/ffi/_modules/index.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -849,7 +930,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/_convert.html b/ffi/_modules/tvm_ffi/_convert.html
index 2c6b82e98d0..e23003893eb 100644
--- a/ffi/_modules/tvm_ffi/_convert.html
+++ b/ffi/_modules/tvm_ffi/_convert.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1047,7 +1128,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/_dtype.html b/ffi/_modules/tvm_ffi/_dtype.html
index 72e02d5349f..ad29c8a8871 100644
--- a/ffi/_modules/tvm_ffi/_dtype.html
+++ b/ffi/_modules/tvm_ffi/_dtype.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -815,6 +896,7 @@ window.runMermaid = runMermaid;</script>
<span class="c1"># pylint: disable=invalid-name</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">__future__</span><span class="w"> </span><span class="kn">import</span> <span class="n">annotations</span>
+<span class="kn">import</span><span class="w"> </span><span class="nn">builtins</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">enum</span><span class="w"> </span><span class="kn">import</span> <span class="n">IntEnum</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">ClassVar</span>
@@ -887,6 +969,22 @@ window.runMermaid = runMermaid;</script>
<span class="n">_tvm_ffi_dtype</span><span class="p">:</span> <span class="n">core</span><span class="o">.</span><span class="n">DataType</span>
<span class="n">_NUMPY_DTYPE_TO_STR</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">dict</span><span class="p">[</span><span class="n">Any</span><span class="p">,</span> <span class="nb">str</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{}</span>
+ <span class="n">_INTEGER_CODES</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">set</span><span class="p">[</span><span class="nb">int</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span><span class="n">DataTypeCode</span><span class="o">.</span><span class="n">INT</span><span class="p">,</span> <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">UINT</span><span class="p">}</span>
+ <span class="n">_FLOAT_CODES</span><span class="p">:</span> <span class="n">ClassVar</span><span class="p">[</span><span class="nb">set</span><span class="p">[</span><span class="nb">int</span><span class="p">]]</span> <span class="o">=</span> <span class="p">{</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">BFLOAT</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E3M4</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E4M3</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E4M3B11FNUZ</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E4M3FN</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E4M3FNUZ</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E5M2</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E5M2FNUZ</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float8E8M0FNU</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float6E2M3FN</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float6E3M2FN</span><span class="p">,</span>
+ <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">Float4E2M1FN</span><span class="p">,</span>
+ <span class="p">}</span>
<span class="k">def</span><span class="w"> </span><span class="fm">__new__</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">content</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">dtype</span><span class="p">:</span>
<span class="n">content</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">content</span><span class="p">)</span>
@@ -1090,7 +1188,62 @@ window.runMermaid = runMermaid;</script>
<span class="sd"> Byte size accounting for lanes.</span>
<span class="sd"> """</span>
- <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tvm_ffi_dtype</span><span class="o">.</span><span class="n">lanes</span></div>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tvm_ffi_dtype</span><span class="o">.</span><span class="n">lanes</span>
+
+ <span class="nd">@property</span>
+ <span class="k">def</span><span class="w"> </span><span class="nf">is_bool</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">builtins</span><span class="o">.</span><span class="n">bool</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Whether this dtype stores boolean values."""</span>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">type_code</span> <span class="o">==</span> <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">BOOL</span>
+
+ <span class="nd">@property</span>
+ <span class="k">def</span><span class="w"> </span><span class="nf">is_integer</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">builtins</span><span class="o">.</span><span class="n">bool</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Whether this dtype stores signed or unsigned integer values."""</span>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">type_code</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_INTEGER_CODES</span>
+
+ <span class="nd">@property</span>
+ <span class="k">def</span><span class="w"> </span><span class="nf">is_float</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">builtins</span><span class="o">.</span><span class="n">bool</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Whether this dtype stores floating-point values."""</span>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">type_code</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FLOAT_CODES</span>
+
+ <span class="nd">@property</span>
+ <span class="k">def</span><span class="w"> </span><span class="nf">is_handle</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="n">builtins</span><span class="o">.</span><span class="n">bool</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Whether this dtype stores opaque handle values."""</span>
+ <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">type_code</span> <span class="o">==</span> <span class="n">DataTypeCode</span><span class="o">.</span><span class="n">HANDLE</span>
+
+<div class="viewcode-block" id="dtype.is_dtype">
+<a class="viewcode-back" href="../../reference/python/generated/tvm_ffi.dtype.html#tvm_ffi.dtype.is_dtype">[docs]</a>
+ <span class="nd">@staticmethod</span>
+ <span class="k">def</span><span class="w"> </span><span class="nf">is_dtype</span><span class="p">(</span><span class="n">arg</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="n">dtype</span><span class="p">)</span> <span class="o">-></span> <span class="n">builtins</span><span class="o">.</span><span class="n">bool</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Check if the given string is a valid dtype.</span>
+
+<span class="sd"> Parameters</span>
+<span class="sd"> ----------</span>
+<span class="sd"> arg</span>
+<span class="sd"> The string to check.</span>
+
+<span class="sd"> Returns</span>
+<span class="sd"> -------</span>
+<span class="sd"> bool</span>
+<span class="sd"> Whether the input string is a valid dtype.</span>
+
+<span class="sd"> Examples</span>
+<span class="sd"> --------</span>
+<span class="sd"> .. code-block:: python</span>
+
+<span class="sd"> import tvm_ffi</span>
+
+<span class="sd"> assert tvm_ffi.dtype.is_dtype("float32")</span>
+<span class="sd"> assert not tvm_ffi.dtype.is_dtype("not_a_dtype")</span>
+
+<span class="sd"> """</span>
+ <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">arg</span><span class="p">,</span> <span class="n">dtype</span><span class="p">):</span>
+ <span class="k">return</span> <span class="kc">True</span>
+ <span class="k">try</span><span class="p">:</span>
+ <span class="n">core</span><span class="o">.</span><span class="n">DataType</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">arg</span><span class="p">))</span>
+ <span class="k">return</span> <span class="kc">True</span>
+ <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
+ <span class="k">return</span> <span class="kc">False</span></div>
+</div>
@@ -1147,11 +1300,19 @@ window.runMermaid = runMermaid;</script>
<span class="n">float16</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float16"</span><span class="p">)</span>
<span class="n">bfloat16</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"bfloat16"</span><span class="p">)</span>
<span class="c1"># float8 dtypes</span>
+<span class="n">float8_e3m4</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e3m4"</span><span class="p">)</span>
+<span class="n">float8_e4m3</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e4m3"</span><span class="p">)</span>
+<span class="n">float8_e4m3b11fnuz</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e4m3b11fnuz"</span><span class="p">)</span>
<span class="n">float8_e4m3fn</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e4m3fn"</span><span class="p">)</span>
<span class="n">float8_e4m3fnuz</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e4m3fnuz"</span><span class="p">)</span>
<span class="n">float8_e5m2</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e5m2"</span><span class="p">)</span>
<span class="n">float8_e5m2fnuz</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e5m2fnuz"</span><span class="p">)</span>
<span class="n">float8_e8m0fnu</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float8_e8m0fnu"</span><span class="p">)</span>
+<span class="c1"># float6 dtypes</span>
+<span class="n">float6_e2m3fn</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float6_e2m3fn"</span><span class="p">)</span>
+<span class="n">float6_e3m2fn</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float6_e3m2fn"</span><span class="p">)</span>
+<span class="c1"># float4 dtypes</span>
+<span class="n">float4_e2m1fn</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float4_e2m1fn"</span><span class="p">)</span>
<span class="c1"># float4x2 dtypes</span>
<span class="n">float4_e2m1fnx2</span> <span class="o">=</span> <span class="n">dtype</span><span class="p">(</span><span class="s2">"float4_e2m1fnx2"</span><span class="p">)</span>
<span class="c1"># alias for torch naming pattern for f4x2</span>
@@ -1196,7 +1357,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/_tensor.html b/ffi/_modules/tvm_ffi/_tensor.html
index 66fbfbf50cf..9ff83607b2e 100644
--- a/ffi/_modules/tvm_ffi/_tensor.html
+++ b/ffi/_modules/tvm_ffi/_tensor.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -953,7 +1034,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/access_path.html b/ffi/_modules/tvm_ffi/access_path.html
index fc93116e47a..cccb1ae003a 100644
--- a/ffi/_modules/tvm_ffi/access_path.html
+++ b/ffi/_modules/tvm_ffi/access_path.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1133,7 +1214,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/container.html b/ffi/_modules/tvm_ffi/container.html
index ade318ffcaa..d583e057395 100644
--- a/ffi/_modules/tvm_ffi/container.html
+++ b/ffi/_modules/tvm_ffi/container.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -816,7 +897,17 @@ window.runMermaid = runMermaid;</script>
<span class="kn">import</span><span class="w"> </span><span class="nn">itertools</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">operator</span>
-<span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="n">ItemsView</span> <span class="k">as</span> <span class="n">ItemsViewBase</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
+ <span class="n">Iterable</span><span class="p">,</span>
+ <span class="n">Iterator</span><span class="p">,</span>
+ <span class="n">Mapping</span><span class="p">,</span>
+ <span class="n">MutableMapping</span><span class="p">,</span>
+ <span class="n">MutableSequence</span><span class="p">,</span>
+ <span class="n">Sequence</span><span class="p">,</span>
+<span class="p">)</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="n">KeysView</span> <span class="k">as</span> <span class="n">KeysViewBase</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="n">ValuesView</span> <span class="k">as</span> <span class="n">ValuesViewBase</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
<span class="n">Any</span><span class="p">,</span>
<span class="n">Callable</span><span class="p">,</span>
@@ -829,46 +920,6 @@ window.runMermaid = runMermaid;</script>
<span class="kn">from</span><span class="w"> </span><span class="nn">.</span><span class="w"> </span><span class="kn">import</span> <span class="n">_ffi_api</span><span class="p">,</span> <span class="n">core</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">.registry</span><span class="w"> </span><span class="kn">import</span> <span class="n">register_object</span>
-<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span> <span class="o">>=</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">9</span><span class="p">):</span>
- <span class="c1"># PEP 585 generics</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">ItemsView</span> <span class="k">as</span> <span class="n">ItemsViewBase</span><span class="p">,</span>
- <span class="p">)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">Iterable</span><span class="p">,</span>
- <span class="n">Iterator</span><span class="p">,</span>
- <span class="n">Mapping</span><span class="p">,</span>
- <span class="n">MutableMapping</span><span class="p">,</span>
- <span class="n">MutableSequence</span><span class="p">,</span>
- <span class="n">Sequence</span><span class="p">,</span>
- <span class="p">)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">KeysView</span> <span class="k">as</span> <span class="n">KeysViewBase</span><span class="p">,</span>
- <span class="p">)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">ValuesView</span> <span class="k">as</span> <span class="n">ValuesViewBase</span><span class="p">,</span>
- <span class="p">)</span>
-<span class="k">else</span><span class="p">:</span> <span class="c1"># Python 3.8</span>
- <span class="c1"># workarounds for python 3.8</span>
- <span class="c1"># typing-module generics (subscriptable on 3.8)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">ItemsView</span> <span class="k">as</span> <span class="n">ItemsViewBase</span><span class="p">,</span>
- <span class="p">)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">Iterable</span><span class="p">,</span>
- <span class="n">Iterator</span><span class="p">,</span>
- <span class="n">Mapping</span><span class="p">,</span>
- <span class="n">MutableMapping</span><span class="p">,</span>
- <span class="n">MutableSequence</span><span class="p">,</span>
- <span class="n">Sequence</span><span class="p">,</span>
- <span class="p">)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">KeysView</span> <span class="k">as</span> <span class="n">KeysViewBase</span><span class="p">,</span>
- <span class="p">)</span>
- <span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="p">(</span>
- <span class="n">ValuesView</span> <span class="k">as</span> <span class="n">ValuesViewBase</span><span class="p">,</span>
- <span class="p">)</span>
-
<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s2">"Array"</span><span class="p">,</span> <span class="s2">"Dict"</span><span class="p">,</span> <span class="s2">"List"</span><span class="p">,</span> <span class="s2">"Map"</span><span class="p">]</span>
@@ -1632,7 +1683,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/cpp/extension.html b/ffi/_modules/tvm_ffi/cpp/extension.html
index c9b2a75e81c..ef0ac1ddee6 100644
--- a/ffi/_modules/tvm_ffi/cpp/extension.html
+++ b/ffi/_modules/tvm_ffi/cpp/extension.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -836,21 +917,50 @@ window.runMermaid = runMermaid;</script>
<span class="n">logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
+<span class="k">def</span><span class="w"> </span><span class="nf">_find_compiler</span><span class="p">(</span><span class="n">name</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="o">*</span><span class="n">home_vars</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Locate a compiler on ``PATH`` or under an env-specified toolkit home's ``bin``."""</span>
+ <span class="n">found</span> <span class="o">=</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
+ <span class="k">if</span> <span class="n">found</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+ <span class="k">return</span> <span class="n">found</span>
+ <span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="n">home_vars</span><span class="p">:</span>
+ <span class="n">home</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">var</span><span class="p">)</span>
+ <span class="k">if</span> <span class="n">home</span><span class="p">:</span>
+ <span class="n">found</span> <span class="o">=</span> <span class="n">shutil</span><span class="o">.</span><span class="n">which</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="n">home</span><span class="p">)</span> <span class="o">/</span> <span class="s2">"bin"</span> [...]
+ <span class="k">if</span> <span class="n">found</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
+ <span class="k">return</span> <span class="n">found</span>
+ <span class="k">return</span> <span class="kc">None</span>
+
+
<span class="nd">@functools</span><span class="o">.</span><span class="n">lru_cache</span>
<span class="k">def</span><span class="w"> </span><span class="nf">_detect_gpu_backend</span><span class="p">()</span> <span class="o">-></span> <span class="n">BACKEND_STR</span><span class="p">:</span>
-<span class="w"> </span><span class="sd">"""Auto-detect whether to use CUDA or HIP (ROCm).</span>
-
-<span class="sd"> Returns 'hip' if ROCm/HIP is available, 'cuda' otherwise.</span>
+<span class="w"> </span><span class="sd">"""Auto-detect whether to use CUDA or HIP (ROCm), defaulting to CUDA.</span>
+
+<span class="sd"> Resolution order: the ``TVM_FFI_GPU_BACKEND`` override, then PyTorch build</span>
+<span class="sd"> signals (``torch.version.hip`` / ``torch.version.cuda``), then a discoverable</span>
+<span class="sd"> ``hipcc`` when no ``nvcc`` can be found. Compilers are resolved from ``PATH``</span>
+<span class="sd"> and from the ``CUDA_HOME``/``CUDA_PATH`` and ``ROCM_HOME``/``ROCM_PATH``</span>
+<span class="sd"> toolkit homes, so an env-specified CUDA install is honored even when ``nvcc``</span>
+<span class="sd"> is off ``PATH``. The mere existence of ``/opt/rocm`` is not treated as</span>
+<span class="sd"> evidence of HIP.</span>
<span class="sd"> """</span>
- <span class="c1"># Check environment variable override first</span>
<span class="n">backend</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"TVM_FFI_GPU_BACKEND"</span><span class="p">,</span> <span class="s2">""</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
<span class="k">if</span> <span class="n">backend</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">"cuda"</span><span class="p">,</span> <span class="s2">"hip"</span><span class="p">):</span>
<span class="k">return</span> <span class="n">backend</span> <span class="c1"># type: ignore[return-value]</span>
<span class="k">try</span><span class="p">:</span>
- <span class="n">_find_rocm_home</span><span class="p">()</span>
+ <span class="kn">import</span><span class="w"> </span><span class="nn">torch</span> <span class="c1"># noqa: PLC0415</span>
+
+ <span class="n">version</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">torch</span><span class="p">,</span> <span class="s2">"version"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
+ <span class="k">if</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">version</span><span class="p">,</span> <span class="s2">"hip"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span>
+ <span class="k">return</span> <span class="s2">"hip"</span>
+ <span class="k">if</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">version</span><span class="p">,</span> <span class="s2">"cuda"</span><span class="p">,</span> <span class="kc">None</span><span class="p">):</span>
+ <span class="k">return</span> <span class="s2">"cuda"</span>
+ <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
+ <span class="k">pass</span>
+ <span class="k">if</span> <span class="n">_find_compiler</span><span class="p">(</span><span class="s2">"nvcc"</span><span class="p">,</span> <span class="s2">"CUDA_HOME"</span><span class="p">,</span> <span class="s2">"CUDA_PATH"</span><span class="p">)</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="p">(</span>
+ <span class="n">_find_compiler</span><span class="p">(</span><span class="s2">"hipcc"</span><span class="p">,</span> <span class="s2">"ROCM_HOME"</span><span class="p">,</span> <span class="s2">"ROCM_PATH"</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span>
+ <span class="p">):</span>
<span class="k">return</span> <span class="s2">"hip"</span>
- <span class="k">except</span> <span class="ne">RuntimeError</span><span class="p">:</span>
- <span class="k">return</span> <span class="s2">"cuda"</span>
+ <span class="k">return</span> <span class="s2">"cuda"</span>
<span class="k">def</span><span class="w"> </span><span class="nf">_resolve_gpu_backend</span><span class="p">(</span><span class="n">backend</span><span class="p">:</span> <span class="nb">str</span> <span class="o">|</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">BACKEND_STR</span><span class="p">:</span>
@@ -1285,6 +1395,16 @@ window.runMermaid = runMermaid;</script>
<span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" command = ld -r -o $out $in"</span><span class="p">)</span>
<span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span>
+ <span class="c1"># Copy a single object straight through, bypassing `ld -r`. A partial</span>
+ <span class="c1"># link of one input is a pointless round-trip, and some system linkers</span>
+ <span class="c1"># (e.g. GNU ld 2.45) assign a nonzero sh_addr to zero-size, non-SHF_ALLOC</span>
+ <span class="c1"># sections like `.note.GNU-stack` during it. JITLink then materializes a</span>
+ <span class="c1"># zero-length block at that address, which collides with a real block in</span>
+ <span class="c1"># EHFrameEdgeFixer's block map and aborts C++ (eh_frame-bearing) loads.</span>
+ <span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"rule copy_object"</span><span class="p">)</span>
+ <span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">" command = cp -f $in $out"</span><span class="p">)</span>
+ <span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span>
+
<span class="k">if</span> <span class="n">embed_cubin</span><span class="p">:</span>
<span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">"rule embed_cubin"</span><span class="p">)</span>
<span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
@@ -1329,7 +1449,10 @@ window.runMermaid = runMermaid;</script>
<span class="k">if</span> <span class="n">object_mode</span><span class="p">:</span>
<span class="c1"># Object-only output: merge all object files into the target.</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">IS_WINDOWS</span><span class="p">:</span>
- <span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"build </span><span class="si">{</span><span class="n">output_name</span><span class="si">}</span><span class="s2">: merge_objects </span><span class="si">{</span><span class="s1">' '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">obj_files</span><span class="p">)</span [...]
+ <span class="c1"># A single object needs no partial link — copy it through to avoid</span>
+ <span class="c1"># `ld -r` rewriting section addresses (see the copy_object rule).</span>
+ <span class="n">rule</span> <span class="o">=</span> <span class="s2">"copy_object"</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">obj_files</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">else</span> <span class="s2">"merge_objects"</span>
+ <span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"build </span><span class="si">{</span><span class="n">output_name</span><span class="si">}</span><span class="s2">: </span><span class="si">{</span><span class="n">rule</span><span class="si">}</span><span class="s2"> </span><span class="si">{</span><span class="s1">' '</span><span class="o">.</span><span class="n">jo [...]
<span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span>
<span class="n">ninja</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">"default </span><span class="si">{</span><span class="n">output_name</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
@@ -2322,7 +2445,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/cpp/nvrtc.html b/ffi/_modules/tvm_ffi/cpp/nvrtc.html
index 88dd9354447..eb34e8ec873 100644
--- a/ffi/_modules/tvm_ffi/cpp/nvrtc.html
+++ b/ffi/_modules/tvm_ffi/cpp/nvrtc.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -814,7 +895,7 @@ window.runMermaid = runMermaid;</script>
<span class="kn">from</span><span class="w"> </span><span class="nn">__future__</span><span class="w"> </span><span class="kn">import</span> <span class="n">annotations</span>
-<span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Sequence</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="n">Sequence</span>
<div class="viewcode-block" id="nvrtc_compile">
@@ -1008,7 +1089,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/error.html b/ffi/_modules/tvm_ffi/error.html
index 54d7a3f67d5..2d7b5141d05 100644
--- a/ffi/_modules/tvm_ffi/error.html
+++ b/ffi/_modules/tvm_ffi/error.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1103,7 +1184,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/libinfo.html b/ffi/_modules/tvm_ffi/libinfo.html
index 9c356575054..63e97425240 100644
--- a/ffi/_modules/tvm_ffi/libinfo.html
+++ b/ffi/_modules/tvm_ffi/libinfo.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1230,7 +1311,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/module.html b/ffi/_modules/tvm_ffi/module.html
index c535dd6abc1..e07d7f8578b 100644
--- a/ffi/_modules/tvm_ffi/module.html
+++ b/ffi/_modules/tvm_ffi/module.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1359,7 +1440,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/registry.html b/ffi/_modules/tvm_ffi/registry.html
index 3b4cda54b0e..6512a54d01e 100644
--- a/ffi/_modules/tvm_ffi/registry.html
+++ b/ffi/_modules/tvm_ffi/registry.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -817,7 +898,8 @@ window.runMermaid = runMermaid;</script>
<span class="kn">import</span><span class="w"> </span><span class="nn">json</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">sys</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">warnings</span>
-<span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">Literal</span><span class="p">,</span> <span class="n">Sequence</span><span class="p">,</span> <span class="n">TypeVar</span><span class="p">,</span> <span class="n">overload</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">collections.abc</span><span class="w"> </span><span class="kn">import</span> <span class="n">Collection</span><span class="p">,</span> <span class="n">Sequence</span>
+<span class="kn">from</span><span class="w"> </span><span class="nn">typing</span><span class="w"> </span><span class="kn">import</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Callable</span><span class="p">,</span> <span class="n">Literal</span><span class="p">,</span> <span class="n">TypeVar</span><span class="p">,</span> <span class="n">overload</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">.</span><span class="w"> </span><span class="kn">import</span> <span class="n">core</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">.core</span><span class="w"> </span><span class="kn">import</span> <span class="n">Function</span><span class="p">,</span> <span class="n">TypeInfo</span>
@@ -1210,7 +1292,11 @@ window.runMermaid = runMermaid;</script>
<span class="bp">cls</span><span class="o">.</span><span class="fm">__init__</span> <span class="o">=</span> <span class="fm">__init__</span> <span class="c1"># type: ignore[attr-defined]</span>
-<span class="k">def</span><span class="w"> </span><span class="nf">_add_class_attrs</span><span class="p">(</span><span class="n">type_cls</span><span class="p">:</span> <span class="nb">type</span><span class="p">,</span> <span class="n">type_info</span><span class="p">:</span> <span class="n">TypeInfo</span><span class="p">)</span> <span class="o">-></span> <span class="nb">type</span><span class="p">:</span>
+<span class="k">def</span><span class="w"> </span><span class="nf">_add_class_attrs</span><span class="p">(</span>
+ <span class="n">type_cls</span><span class="p">:</span> <span class="nb">type</span><span class="p">,</span>
+ <span class="n">type_info</span><span class="p">:</span> <span class="n">TypeInfo</span><span class="p">,</span>
+ <span class="n">type_attr_names</span><span class="p">:</span> <span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="p">(),</span>
+<span class="p">)</span> <span class="o">-></span> <span class="nb">type</span><span class="p">:</span>
<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="n">type_info</span><span class="o">.</span><span class="n">fields</span><span class="p">:</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">field</span><span class="o">.</span><span class="n">name</span>
<span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">type_cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span> <span class="c1"># skip attributes defined directly on this class</span>
@@ -1229,9 +1315,26 @@ window.runMermaid = runMermaid;</script>
<span class="n">ffi_init</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">_lookup_type_attr</span><span class="p">(</span><span class="n">type_info</span><span class="o">.</span><span class="n">type_index</span><span class="p">,</span> <span class="s2">"__ffi_init__"</span><span class="p">)</span>
<span class="k">if</span> <span class="n">ffi_init</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">_install_ffi_init_attr</span><span class="p">(</span><span class="n">type_cls</span><span class="p">,</span> <span class="n">type_info</span><span class="p">,</span> <span class="n">ffi_init</span><span class="p">)</span>
+ <span class="n">_add_type_attr_class_attrs</span><span class="p">(</span><span class="n">type_cls</span><span class="p">,</span> <span class="n">type_info</span><span class="p">,</span> <span class="n">type_attr_names</span><span class="p">)</span>
<span class="k">return</span> <span class="n">type_cls</span>
+<span class="k">def</span><span class="w"> </span><span class="nf">_add_type_attr_class_attrs</span><span class="p">(</span>
+ <span class="n">type_cls</span><span class="p">:</span> <span class="nb">type</span><span class="p">,</span>
+ <span class="n">type_info</span><span class="p">:</span> <span class="n">TypeInfo</span><span class="p">,</span>
+ <span class="n">type_attr_names</span><span class="p">:</span> <span class="n">Collection</span><span class="p">[</span><span class="nb">str</span><span class="p">],</span>
+<span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
+<span class="w"> </span><span class="sd">"""Install selected TypeAttrColumn values as Python class attributes."""</span>
+ <span class="k">if</span> <span class="ow">not</span> <span class="n">type_attr_names</span><span class="p">:</span>
+ <span class="k">return</span>
+ <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="n">type_attr_names</span><span class="p">:</span>
+ <span class="n">value</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">_lookup_type_attr</span><span class="p">(</span><span class="n">type_info</span><span class="o">.</span><span class="n">type_index</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span>
+ <span class="k">if</span> <span class="n">value</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
+ <span class="k">continue</span>
+ <span class="k">if</span> <span class="n">name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">type_cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">:</span>
+ <span class="nb">setattr</span><span class="p">(</span><span class="n">type_cls</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
+
+
<span class="k">def</span><span class="w"> </span><span class="nf">_install_ffi_init_attr</span><span class="p">(</span><span class="bp">cls</span><span class="p">:</span> <span class="nb">type</span><span class="p">,</span> <span class="n">type_info</span><span class="p">:</span> <span class="n">TypeInfo</span><span class="p">,</span> <span class="n">ffi_init</span><span class="p">:</span> <span class="n">Function</span><span class="p">)</span> <span class="o">-></span> <span class=" [...]
<span class="w"> </span><span class="sd">"""Install ``__ffi_init__`` as a method that delegates to ``__init_handle_by_constructor__``.</span>
@@ -1353,7 +1456,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/serialization.html b/ffi/_modules/tvm_ffi/serialization.html
index 1da71a825ad..9d738f1fc82 100644
--- a/ffi/_modules/tvm_ffi/serialization.html
+++ b/ffi/_modules/tvm_ffi/serialization.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -926,7 +1007,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/stream.html b/ffi/_modules/tvm_ffi/stream.html
index a0047f18c5d..5bd1e208ee9 100644
--- a/ffi/_modules/tvm_ffi/stream.html
+++ b/ffi/_modules/tvm_ffi/stream.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1065,7 +1146,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_modules/tvm_ffi/structural.html b/ffi/_modules/tvm_ffi/structural.html
index 3e0f1aea890..684d45b7245 100644
--- a/ffi/_modules/tvm_ffi/structural.html
+++ b/ffi/_modules/tvm_ffi/structural.html
@@ -42,7 +42,7 @@
<link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />
- <script src="../../_static/documentation_options.js?v=e435db62"></script>
+ <script src="../../_static/documentation_options.js?v=343e8fc7"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
@@ -272,6 +272,25 @@ let darkTheme = isDarkTheme();
let modal = null;
let modalContent = null;
let previousScrollOffset = [window.scrollX, window.scrollY];
+let _lazyObserver = null;
+let _renderQueue = Promise.resolve();
+
+// Apply d3 zoom to each SVG. Idempotent: an SVG already wrapped is skipped,
+// so this is safe to call both for the initial batch and for diagrams that
+// render lazily once they become visible.
+const addZoomToSvgs = (svgs) => {
+ svgs.each(function() {
+ if (this.getAttribute('data-zoom-applied') === 'true') return;
+ var svg = d3.select(this);
+ svg.html("<g class='wrapper'>" + svg.html() + "</g>");
+ var inner = svg.select("g");
+ var zoom = d3.zoom().on("zoom", function(event) {
+ inner.attr("transform", event.transform);
+ });
+ svg.call(zoom);
+ this.setAttribute('data-zoom-applied', 'true');
+ });
+};
const runMermaid = async (rerun) => {
console.log("Running mermaid diagrams, rerun =", rerun);
@@ -279,7 +298,15 @@ const runMermaid = async (rerun) => {
let all_mermaids = document.querySelectorAll(".mermaid");
if (rerun) {
+ // Disconnect any previous lazy rendering observer
+ if (_lazyObserver) {
+ _lazyObserver.disconnect();
+ _lazyObserver = null;
+ }
+
all_mermaids.forEach((el) => {
+ el.removeAttribute('data-mermaid-deferred');
+ el.removeAttribute('data-mermaid-render-failed');
if(!el.hasAttribute("data-original-code")) {
// store original code
// console.log(`Storing original code for first run: `, el.innerHTML);
@@ -296,35 +323,89 @@ const runMermaid = async (rerun) => {
el.setAttribute('data-original-code', el.innerHTML);
}
});
- await mermaid.run();
+
+ // Separate visible and hidden elements. Mermaid's layout engine measures
+ // text dimensions via the DOM, which fails for elements hidden by a parent
+ // (e.g., Reveal.js non-active slides, sphinx-design unopened tabs),
+ // producing broken SVGs. Render visible elements now, defer hidden ones.
+ const visible = [];
+ const hidden = [];
+ all_mermaids.forEach((el) => {
+ // offsetParent is null for display:none ancestors.
+ // getClientRects().length > 0 catches position:fixed elements
+ // (which also have null offsetParent but are still visible).
+ if (el.offsetParent !== null || el.getClientRects().length > 0) {
+ visible.push(el);
+ } else {
+ hidden.push(el);
+ el.setAttribute('data-mermaid-deferred', 'true');
+ }
+ });
+
+ if (visible.length > 0) {
+ try {
+ await mermaid.run({ nodes: visible });
+ } catch (e) {
+ console.error("Mermaid rendering failed:", e);
+ }
+ }
+
+ // Lazily render hidden elements when they become visible.
+ // Uses a promise chain (_renderQueue) to serialize rendering,
+ // since IntersectionObserver may report multiple entries at once
+ // and mermaid.run() is not safe to call concurrently.
+ if (hidden.length > 0) {
+ if (typeof IntersectionObserver === 'undefined') {
+ console.warn("IntersectionObserver not available; hidden mermaid diagrams will not render.");
+ } else {
+ _renderQueue = Promise.resolve();
+ _lazyObserver = new IntersectionObserver((entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting && entry.target.getAttribute("data-processed") !== "true") {
+ _lazyObserver.unobserve(entry.target);
+ const el = entry.target;
+ _renderQueue = _renderQueue.then(async () => {
+ try {
+ await mermaid.run({ nodes: [el] });
+ el.removeAttribute('data-mermaid-deferred');
+ // Apply zoom to the now-rendered diagram, matching
+ // the decoration visible diagrams receive.
+ if ("False" === "True") {
+ addZoomToSvgs(d3.selectAll(""));
+ }
+ } catch (e) {
+ console.error("Mermaid deferred rendering failed:", e);
+ el.removeAttribute('data-mermaid-deferred');
+ el.setAttribute('data-mermaid-render-failed', 'true');
+ }
+ });
+ }
+ }
+ });
+ hidden.forEach((el) => _lazyObserver.observe(el));
+ }
+ }
}
all_mermaids = document.querySelectorAll(".mermaid");
- const mermaids_processed = document.querySelectorAll(".mermaid[data-processed='true']");
+ // Exclude deferred (hidden) and render-failed elements from completion checks
+ const mermaids_active = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])");
+ const mermaids_processed = document.querySelectorAll(".mermaid:not([data-mermaid-deferred]):not([data-mermaid-render-failed])[data-processed='true']");
if ("False" === "True") {
- const mermaids_to_add_zoom = -1 === -1 ? all_mermaids.length : -1;
+ const mermaids_to_add_zoom = -1 === -1 ? mermaids_active.length : -1;
if(mermaids_to_add_zoom > 0) {
var svgs = d3.selectAll("");
- if(all_mermaids.length !== mermaids_processed.length) {
- setTimeout(() => runMermaid(false), 200);
- return;
- } else if(svgs.size() !== mermaids_to_add_zoom) {
+ // Wait until every active (visible) diagram has rendered. Deferred
+ // diagrams are excluded, so a fixed d3_node_count that counts a
+ // hidden diagram no longer loops forever waiting for its SVG.
+ if(mermaids_active.length !== mermaids_processed.length) {
setTimeout(() => runMermaid(false), 200);
return;
- } else {
- svgs.each(function() {
- var svg = d3.select(this);
- svg.html("<g class='wrapper'>" + svg.html() + "</g>");
- var inner = svg.select("g");
- var zoom = d3.zoom().on("zoom", function(event) {
- inner.attr("transform", event.transform);
- });
- svg.call(zoom);
- });
}
+ addZoomToSvgs(svgs);
}
- } else if(all_mermaids.length !== mermaids_processed.length) {
+ } else if(mermaids_active.length !== mermaids_processed.length) {
// Wait for mermaid to process all diagrams
setTimeout(() => runMermaid(false), 200);
return;
@@ -494,8 +575,8 @@ window.runMermaid = runMermaid;</script>
<link rel="search" title="Search" href="../../search.html" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="docsearch:language" content="en"/>
- <meta name="docsearch:version" content="0.1.dev1+gf90410468" />
- <meta name="docbuild:last-update" content="Jun 17, 2026"/>
+ <meta name="docsearch:version" content="0.1.dev1+g135c2e8bb" />
+ <meta name="docbuild:last-update" content="Jul 25, 2026"/>
</head>
@@ -1152,11 +1233,8 @@ window.runMermaid = runMermaid;</script>
<span class="c1"># fmt: off</span>
<span class="n">value</span><span class="p">:</span> <span class="n">Any</span>
<span class="k">if</span> <span class="n">TYPE_CHECKING</span><span class="p">:</span>
- <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">Any</span> <span class="o">=</span> <span class="o">...</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="o">...</span>
-<div class="viewcode-block" id="VisitInterrupt.__ffi_init__">
-<a class="viewcode-back" href="../../reference/python/generated/tvm_ffi.VisitInterrupt.html#tvm_ffi.VisitInterrupt.__ffi_init__">[docs]</a>
- <span class="k">def</span><span class="w"> </span><span class="nf">__ffi_init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_0</span><span class="p">:</span> <span class="n">Any</span><span class="p">,</span> <span class="o">/</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="o">...</span> <span class="c1"># ty: ignore[invalid-method-override]</span></div>
-
+ <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="o">...</span>
+ <span class="k">def</span><span class="w"> </span><span class="nf">__ffi_init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_0</span><span class="p">:</span> <span class="n">Any</span><span class="p">,</span> <span class="o">/</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="o">...</span> <span class="c1"># ty: ignore[invalid-method-override]</span>
<span class="c1"># fmt: on</span>
<span class="c1"># tvm-ffi-stubgen(end)</span>
@@ -1183,27 +1261,10 @@ window.runMermaid = runMermaid;</script>
<span class="w"> </span><span class="sd">"""Low-level structural traversal visitor.</span>
<span class="sd"> This class exposes the low-level visitor object used by structural</span>
-<span class="sd"> traversal hooks.</span>
+<span class="sd"> traversal hooks. Instances are supplied by an active traversal and cannot</span>
+<span class="sd"> be constructed directly.</span>
<span class="sd"> """</span>
- <span class="c1"># tvm-ffi-stubgen(begin): object/ffi.StructuralVisitor</span>
- <span class="c1"># fmt: off</span>
- <span class="k">if</span> <span class="n">TYPE_CHECKING</span><span class="p">:</span>
- <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="o">...</span>
-<div class="viewcode-block" id="StructuralVisitor.__ffi_init__">
-<a class="viewcode-back" href="../../reference/python/generated/tvm_ffi.StructuralVisitor.html#tvm_ffi.StructuralVisitor.__ffi_init__">[docs]</a>
- <span class="k">def</span><span class="w"> </span><span class="nf">__ffi_init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span> <span class="o">...</span> <span class="c1"># ty: ignore[invalid-method-override]</span></div>
-
- <span class="c1"># fmt: on</span>
- <span class="c1"># tvm-ffi-stubgen(end)</span>
-
-<div class="viewcode-block" id="StructuralVisitor.__init__">
-<a class="viewcode-back" href="../../reference/python/generated/tvm_ffi.StructuralVisitor.html#tvm_ffi.StructuralVisitor.__init__">[docs]</a>
- <span class="k">def</span><span class="w"> </span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-></span> <span class="kc">None</span><span class="p">:</span>
-<span class="w"> </span><span class="sd">"""Create a default structural visitor."""</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">__init_handle_by_constructor__</span><span class="p">(</span><span class="n">_ffi_api</span><span class="o">.</span><span class="n">StructuralVisitor</span><span class="p">)</span></div>
-
-
<div class="viewcode-block" id="StructuralVisitor.visit">
<a class="viewcode-back" href="../../reference/python/generated/tvm_ffi.StructuralVisitor.html#tvm_ffi.StructuralVisitor.visit">[docs]</a>
<span class="k">def</span><span class="w"> </span><span class="nf">visit</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">:</span> <span class="n">Any</span><span class="p">)</span> <span class="o">-></span> <span class="n">VisitInterrupt</span> <span class="o">|</span> <span class="kc">None</span><span class="p">:</span>
@@ -1443,7 +1504,7 @@ By Apache TVM FFI contributors
<div class="footer-item">
<p class="last-updated">
- Last updated on Jun 17, 2026.
+ Last updated on Jul 25, 2026.
<br/>
</p>
</div>
diff --git a/ffi/_sources/concepts/abi_overview.rst b/ffi/_sources/concepts/abi_overview.rst
index b2e1777ea3e..1d690eae814 100644
--- a/ffi/_sources/concepts/abi_overview.rst
+++ b/ffi/_sources/concepts/abi_overview.rst
@@ -475,7 +475,7 @@ The following C code sets the TLS error and returns ``-1`` via :cpp:func:`TVMFFI
:start-after: [Error.RaiseException.begin]
:end-before: [Error.RaiseException.end]
-For non-null-terminated strings, use :cpp:func:`TVMFFIErrorSetRaisedFromCStrParts`, which accepts explicit string lengths.
+When an error message is assembled from reusable parts, use :cpp:func:`TVMFFIErrorSetRaisedFromCStrParts` to avoid duplicating common message fragments.
.. note::
You rarely need to create a :cpp:class:`~tvm::ffi::ErrorObj` directly.
diff --git a/ffi/_sources/concepts/structural_eq_hash.rst b/ffi/_sources/concepts/structural_eq_hash.rst
index cf6efa8fb53..f3acc3a72b5 100644
--- a/ffi/_sources/concepts/structural_eq_hash.rst
+++ b/ffi/_sources/concepts/structural_eq_hash.rst
@@ -50,14 +50,19 @@ Type-Level Annotation
---------------------
The ``structural_eq`` parameter on ``@py_class`` declares how instances of the
-type participate in structural equality and hashing:
+type participate in structural equality and hashing. It defaults to ``"tree"``,
+so the following class is compared recursively by its fields:
.. code-block:: python
- @py_class(structural_eq="tree")
+ @py_class
class Expr(Object):
...
+Specify ``structural_eq`` only when the type needs another role, such as
+``"var"``, ``"dag"``, or ``"singleton"``, or pass ``None`` explicitly to opt
+out of structural equality and hashing.
+
Quick reference
~~~~~~~~~~~~~~~
@@ -70,7 +75,7 @@ Quick reference
- Use when...
* - ``"tree"``
- A regular IR node
- - Default for most IR nodes
+ - Default for ``@py_class`` and most IR nodes
* - ``"const-tree"``
- An immutable value node (with pointer shortcut)
- The type has no transitive ``"var"`` children
@@ -85,7 +90,7 @@ Quick reference
- Exactly one instance per logical identity (e.g. registry entries)
* - ``None``
- Not comparable
- - The type should never be compared structurally
+ - Explicitly opt out of structural comparison
``"tree"`` — The Default
@@ -93,7 +98,7 @@ Quick reference
.. code-block:: python
- @py_class(structural_eq="tree")
+ @py_class
class Add(Object):
lhs: Expr
rhs: Expr
@@ -580,6 +585,12 @@ identity. Pointer equality is the only valid comparison."
No content comparison is ever performed. Different pointers are always
unequal; same pointer is always equal.
+The :class:`~tvm_ffi.dataclasses.Enum` hierarchy always uses this kind by
+default. This includes :class:`~tvm_ffi.dataclasses.IntEnum`,
+:class:`~tvm_ffi.dataclasses.StrEnum`, and every subclass of these enum bases.
+Each registered enum variant is therefore structurally equal only to that same
+singleton variant.
+
.. code-block:: python
op_conv = Op.get("nn.conv2d")
@@ -877,7 +888,7 @@ When defining a new type:
.. mermaid::
graph TD
- Start["New @py_class type"] --> Q1{"Singleton?<br/>(one instance per<br/>logical identity)"}
+ Start["New non-enum @py_class type"] --> Q1{"Singleton?<br/>(one instance per<br/>logical identity)"}
Q1 -->|Yes| UI["structural_eq="singleton""]
Q1 -->|No| Q2{"Represents a<br/>variable binding?"}
Q2 -->|Yes| FV["structural_eq="var""]
@@ -893,6 +904,9 @@ When defining a new type:
style CTN fill:#d4edda
style TN fill:#d4edda
+Enum types do not need this decision process: :class:`~tvm_ffi.dataclasses.Enum`
+and all of its subclasses default to ``"singleton"``.
+
For fields:
.. mermaid::
diff --git a/ffi/_sources/dev/source_build.rst b/ffi/_sources/dev/source_build.rst
index f293aae5eb7..31f692b4591 100644
--- a/ffi/_sources/dev/source_build.rst
+++ b/ffi/_sources/dev/source_build.rst
@@ -34,7 +34,7 @@ This guide covers two common workflows:
- macOS: Apple Clang (via Xcode Command Line Tools)
- Windows: MSVC (Visual Studio 2019 or 2022, x64)
- - Build tools: CMake 3.18+; Ninja
+ - Build tools: CMake 3.26+; Ninja
Build the Python Package
------------------------
diff --git a/ffi/_sources/guides/cpp_lang_guide.md b/ffi/_sources/guides/cpp_lang_guide.md
index f222e8b793a..d964421c071 100644
--- a/ffi/_sources/guides/cpp_lang_guide.md
+++ b/ffi/_sources/guides/cpp_lang_guide.md
@@ -88,7 +88,7 @@ counting correctly when the stored value is an on-heap object.
The tvm-ffi object system provides the foundation for all managed, reference-counted objects
in the system. It enables type safety, cross-language compatibility, and efficient memory management.
-The object system is built around three key classes: Object, ObjectPtr, and ObjectRef.
+The object system is built around four key classes: `Object`, `ObjectPtr`, `Arc`, and `ObjectRef`.
The `Object` class is the base class of all heap-allocated objects. It contains a common header
that includes the `type_index`, reference counter and deleter for the object.
Users do not need to explicitly manage these fields as part of the C++ API. Instead,
@@ -115,16 +115,41 @@ class MyIntPairObj : public tvm::ffi::Object {
void ExampleObjectPtr() {
namespace ffi = tvm::ffi;
- // make_object automatically sets up the deleter correctly
- // This function creates a new ObjectPtr with proper memory management
- // It handles allocation, initialization, and sets up the reference counting system
- ffi::ObjectPtr<MyIntPairObj> obj = ffi::make_object<MyIntPairObj>(100, 200);
+ // make_arc allocates, initializes, and sets up reference counting and the deleter.
+ ffi::Arc<MyIntPairObj> required = ffi::make_arc<MyIntPairObj>(100, 200);
+ // ObjectPtr is the nullable one-pointer carrier.
+ ffi::ObjectPtr<MyIntPairObj> optional = required;
// EXPECT_EQ is used here for demonstration purposes (testing framework)
- EXPECT_EQ(obj->a, 100);
- EXPECT_EQ(obj->b, 200);
+ EXPECT_EQ(required->a, 100);
+ EXPECT_EQ(required->b, 200);
+ optional = nullptr;
}
```
+For an unqualified `Object` subclass `T`, use `Arc<T>` when the object is required and
+`ObjectPtr<T>` when it may be absent. Both are owning pointers with the same one-pointer layout and
+reference-counting behavior. Copying through `Any` retains the object, while moving transfers its
+reference. They can be used in typed containers such as `Array`, `List`, `Map`, `Dict`, `Tuple`,
+`Optional`, `Variant`, and `Expected`, as well as reflected fields and function signatures.
+
+`Arc<T>` has no default or `nullptr` constructor, and `make_arc<T>(args...)` is its normal creation
+API. Its type schema is the bare object schema `{"type":"T"}`, so ABI `None` is rejected. By
+contrast, `ObjectPtr<T>` remains mechanically nullable, maps a null pointer to ABI `None`, and has
+schema `Optional[T]`. `Optional<Arc<T>>` is also supported and produces exactly `Optional[T]`; use
+it when the native field needs the 16-byte `Optional` carrier rather than the 8-byte
+`ObjectPtr<T>` carrier.
+
+Normal C++ move semantics leave a moved-from `Arc` empty. `Arc(UnsafeInit{})` also creates an empty
+value for reflection's controlled construct-then-populate path. These states are exceptions to the
+safe API's non-null guarantee and must be populated before use; Arc operations rely on the invariant
+without runtime validation. A reflected class with an `Arc` field should initialize that field
+explicitly in its unsafe constructor, for example
+`HolderObj(UnsafeInit) : required(UnsafeInit{}) {}`. Because `Arc` publicly inherits `ObjectPtr`,
+deliberately mutating it through the base class can likewise bypass the guarantee and is unsafe.
+
+Qualified pointee types such as `Arc<const T>`, `ObjectPtr<const T>`, volatile pointees, and
+reference pointee types are not supported.
+
We typically provide a reference class that wraps the ObjectPtr.
The `ObjectRef` base class provides the interface and reference counting
functionality for these wrapper classes.
@@ -160,7 +185,8 @@ The ObjectRef acts as a smart pointer wrapper that automatically manages the Obj
The overall implementation pattern is as follows:
- **Object Class**: Inherits from `ffi::Object`, stores data and implements the core functionality.
-- **ObjectPtr**: Smart pointer that manages the Object lifecycle and reference counting.
+- **Arc**: Non-null owning pointer used for required object values.
+- **ObjectPtr**: Nullable owning pointer used when the object may be absent.
- **Ref Class**: Inherits from `ffi::ObjectRef`, provides a user-friendly interface and automatic memory management.
This design ensures efficient memory management while providing a clean API for users. Once we define an ObjectRef class,
diff --git a/ffi/_sources/guides/dataclass_reflection.rst b/ffi/_sources/guides/dataclass_reflection.rst
index d4a1a77346f..803ada55eb4 100644
--- a/ffi/_sources/guides/dataclass_reflection.rst
+++ b/ffi/_sources/guides/dataclass_reflection.rst
@@ -260,7 +260,8 @@ automatically support deep copy (through the ``__ffi_shallow_copy__`` type
attribute).
- **Immutable leaves** (returned as-is): primitives, ``String``, ``Bytes``,
- ``Shape``
+ ``Shape``, and ``Enum`` instances (including ``IntEnum`` and ``StrEnum``
+ subclasses)
- **Recursively copied**: ``Array``, ``List``, ``Map``, ``Dict``, and
reflected objects
@@ -400,12 +401,87 @@ The decorator:
4. Installs ``__copy__``, ``__deepcopy__``, ``__eq__``, ``__hash__``,
``__repr__``, and comparison operators.
+Use ``frozen=True`` when the Python class should expose reflected fields as
+read-only after construction:
+
+.. code-block:: python
+
+ @c_class("my_ext.Point", frozen=True)
+ class Point(tvm_ffi.Object):
+ x: int
+ y: int
+ label: str
+
+This marks the reflected field metadata as frozen and installs read-only
+descriptors on the Python class, even for fields that are registered as
+``def_rw`` on the C++ side. It is intended for immutable value and IR node
+families. Controlled internal updates can still use the field descriptor's
+``set`` method when a framework component needs to rebuild or annotate an
+object.
+
.. note::
``@tvm_ffi.register_object`` can also be used, which delegates to
``c_class`` internally for objects with reflected fields.
+Enum Payload Fields and Structural Identity
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``tvm_ffi.dataclasses.Enum`` and all of its subclasses use ``"singleton"``
+structural equality by default. This includes ``IntEnum``, ``StrEnum``, and
+their subclasses: two enum values are structurally equal only when they are
+the same registered variant.
+
+``tvm_ffi.dataclasses.IntEnum`` and ``StrEnum`` are reflected subclasses of
+``ffi.IntEnum`` and ``ffi.StrEnum``. Their user-visible ``value`` payload is
+stored by the native base class, so subclasses only declare entries:
+
+.. code-block:: python
+
+ from tvm_ffi.dataclasses import IntEnum, StrEnum, entry
+
+ class Level(IntEnum, type_key="my_ext.Level"):
+ low = entry(value=1)
+ high = entry(value=2)
+
+ class Opcode(StrEnum, type_key="my_ext.Opcode"):
+ add = entry(value="+")
+ mul = entry(value="*")
+
+Enum-specific ``__data_to_json__`` and ``__data_from_json__`` hooks preserve
+this singleton identity during JSON graph serialization. Following the scalar
+``TypeAttrDef`` hook pattern, plain ``Enum`` variants serialize as their
+registered name, while ``IntEnum`` and ``StrEnum`` variants serialize as their
+public ``value`` payload (an integer or string, respectively). Deserialization
+uses that scalar to resolve the registered variant instead of allocating a
+replacement object. Singleton-preserving round-trips therefore require payload
+values to be unique within an enum type. This applies both to an enum serialized
+directly and to enum-valued fields nested in another reflected object:
+
+.. code-block:: python
+
+ from tvm_ffi.serialization import from_json_graph_str, to_json_graph_str
+
+ data = to_json_graph_str(Opcode.add)
+ restored = from_json_graph_str(data)
+
+ assert restored.same_as(Opcode.add)
+
+C++ enum owners register the value-based hook pair on their concrete
+``ObjectDef`` or ``TypeAttrDef``. Python-defined ``IntEnum`` and ``StrEnum``
+classes obtain missing hooks from C++ reflection with
+``core._lookup_type_attr``: the serializer is reused from the native payload
+base, while a native factory binds the deserializer to the concrete Python
+type index. This keeps payload lookup in C++ while leaving explicit Python
+hooks unchanged. A plain ``Enum`` owner defines its name-based hook pair
+explicitly; ``EnumDef`` itself only registers variants.
+
+Payload enum values can be used in reflected object fields, including optional
+and container fields. Payload normalization recurses through ``Array``, ``List``,
+``Map``, and ``Dict`` values.
+
+
Inheritance
-----------
diff --git a/ffi/_sources/packaging/cpp_tooling.rst b/ffi/_sources/packaging/cpp_tooling.rst
index 3609305c781..f49b5363f00 100644
--- a/ffi/_sources/packaging/cpp_tooling.rst
+++ b/ffi/_sources/packaging/cpp_tooling.rst
@@ -206,7 +206,7 @@ approach: **build on old glibc, run on new**.
.. code-block:: bash
- docker pull quay.io/pypa/manylinux2014_x86_64
+ docker pull quay.io/pypa/manylinux_2_28_x86_64
Build host and device code inside the container. For CUDA:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Arc.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Arc.rst
new file mode 100644
index 00000000000..6e385cd3f51
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Arc.rst
@@ -0,0 +1,26 @@
+.. _exhale_class_classtvm_1_1ffi_1_1Arc:
+
+Template Class Arc
+==================
+
+- Defined in :ref:`file_tvm_ffi_object.h`
+
+
+Inheritance Relationships
+-------------------------
+
+Base Type
+*********
+
+- ``public tvm::ffi::ObjectPtr< T >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1ObjectPtr`)
+
+
+Class Documentation
+-------------------
+
+
+.. doxygenclass:: tvm::ffi::Arc
+ :project: tvm-ffi
+ :members:
+ :protected-members:
+ :undoc-members:
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
index 5e63628c153..419414d9049 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
@@ -15,6 +15,13 @@ Base Type
- ``public tvm::ffi::ObjectRef`` (:ref:`exhale_class_classtvm_1_1ffi_1_1ObjectRef`)
+Derived Types
+*************
+
+- ``public tvm::ffi::IntEnum`` (:ref:`exhale_class_classtvm_1_1ffi_1_1IntEnum`)
+- ``public tvm::ffi::StrEnum`` (:ref:`exhale_class_classtvm_1_1ffi_1_1StrEnum`)
+
+
Class Documentation
-------------------
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
index 2153403c46c..49719981146 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
@@ -15,6 +15,13 @@ Base Type
- ``public tvm::ffi::Object`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Object`)
+Derived Types
+*************
+
+- ``public tvm::ffi::IntEnumObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1IntEnumObj`)
+- ``public tvm::ffi::StrEnumObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1StrEnumObj`)
+
+
Class Documentation
-------------------
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumState.rst
similarity index 69%
copy from ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
copy to ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumState.rst
index 5e63628c153..1459032b14a 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumState.rst
@@ -1,7 +1,7 @@
-.. _exhale_class_classtvm_1_1ffi_1_1Enum:
+.. _exhale_class_classtvm_1_1ffi_1_1EnumState:
-Class Enum
-==========
+Class EnumState
+===============
- Defined in :ref:`file_tvm_ffi_enum.h`
@@ -19,7 +19,7 @@ Class Documentation
-------------------
-.. doxygenclass:: tvm::ffi::Enum
+.. doxygenclass:: tvm::ffi::EnumState
:project: tvm-ffi
:members:
:protected-members:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumStateObj.rst
similarity index 66%
copy from ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
copy to ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumStateObj.rst
index 2153403c46c..f5d3dbebb36 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumStateObj.rst
@@ -1,7 +1,7 @@
-.. _exhale_class_classtvm_1_1ffi_1_1EnumObj:
+.. _exhale_class_classtvm_1_1ffi_1_1EnumStateObj:
-Class EnumObj
-=============
+Class EnumStateObj
+==================
- Defined in :ref:`file_tvm_ffi_enum.h`
@@ -19,7 +19,7 @@ Class Documentation
-------------------
-.. doxygenclass:: tvm::ffi::EnumObj
+.. doxygenclass:: tvm::ffi::EnumStateObj
:project: tvm-ffi
:members:
:protected-members:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Expected_3_01void_01_4.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Expected_3_01void_01_4.rst
new file mode 100644
index 00000000000..ec1b9c9bdcf
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Expected_3_01void_01_4.rst
@@ -0,0 +1,17 @@
+.. _exhale_class_classtvm_1_1ffi_1_1Expected_3_01void_01_4:
+
+Template Class Expected< void >
+===============================
+
+- Defined in :ref:`file_tvm_ffi_expected.h`
+
+
+Class Documentation
+-------------------
+
+
+.. doxygenclass:: tvm::ffi::Expected< void >
+ :project: tvm-ffi
+ :members:
+ :protected-members:
+ :undoc-members:
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1IntEnum.rst
similarity index 54%
copy from ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
copy to ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1IntEnum.rst
index 2153403c46c..08e995b1edc 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1IntEnum.rst
@@ -1,6 +1,6 @@
-.. _exhale_class_classtvm_1_1ffi_1_1EnumObj:
+.. _exhale_class_classtvm_1_1ffi_1_1IntEnum:
-Class EnumObj
+Class IntEnum
=============
- Defined in :ref:`file_tvm_ffi_enum.h`
@@ -12,14 +12,14 @@ Inheritance Relationships
Base Type
*********
-- ``public tvm::ffi::Object`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Object`)
+- ``public tvm::ffi::Enum`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Enum`)
Class Documentation
-------------------
-.. doxygenclass:: tvm::ffi::EnumObj
+.. doxygenclass:: tvm::ffi::IntEnum
:project: tvm-ffi
:members:
:protected-members:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1IntEnumObj.rst
similarity index 50%
copy from ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
copy to ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1IntEnumObj.rst
index 5e63628c153..1a58d36deaa 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1IntEnumObj.rst
@@ -1,7 +1,7 @@
-.. _exhale_class_classtvm_1_1ffi_1_1Enum:
+.. _exhale_class_classtvm_1_1ffi_1_1IntEnumObj:
-Class Enum
-==========
+Class IntEnumObj
+================
- Defined in :ref:`file_tvm_ffi_enum.h`
@@ -12,14 +12,14 @@ Inheritance Relationships
Base Type
*********
-- ``public tvm::ffi::ObjectRef`` (:ref:`exhale_class_classtvm_1_1ffi_1_1ObjectRef`)
+- ``public tvm::ffi::EnumObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1EnumObj`)
Class Documentation
-------------------
-.. doxygenclass:: tvm::ffi::Enum
+.. doxygenclass:: tvm::ffi::IntEnumObj
:project: tvm-ffi
:members:
:protected-members:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Object.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Object.rst
index a6601a68e21..c59b7d592c0 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Object.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Object.rst
@@ -13,6 +13,7 @@ Derived Types
*************
- ``public tvm::ffi::EnumObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1EnumObj`)
+- ``public tvm::ffi::EnumStateObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1EnumStateObj`)
- ``public tvm::ffi::ErrorObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1ErrorObj`)
- ``public tvm::ffi::FunctionObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1FunctionObj`)
- ``public tvm::ffi::MapBaseObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1MapBaseObj`)
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectPtr.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectPtr.rst
index 2da5c2630d9..f4d3ea72d72 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectPtr.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectPtr.rst
@@ -6,6 +6,15 @@ Template Class ObjectPtr
- Defined in :ref:`file_tvm_ffi_object.h`
+Inheritance Relationships
+-------------------------
+
+Derived Type
+************
+
+- ``public tvm::ffi::Arc< T >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Arc`)
+
+
Class Documentation
-------------------
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectRef.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectRef.rst
index b96128d5393..ce0b39c147e 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectRef.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1ObjectRef.rst
@@ -13,17 +13,19 @@ Derived Types
*************
- ``public tvm::ffi::Array< tvm::ffi::Any >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Array`)
+- ``public tvm::ffi::Dict< tvm::ffi::Any, tvm::ffi::ObjectRef >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Dict`)
+- ``public tvm::ffi::Dict< tvm::ffi::String, tvm::ffi::Dict< tvm::ffi::ObjectRef, tvm::ffi::Any > >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Dict`)
- ``public tvm::ffi::List< tvm::ffi::ObjectRef >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1List`)
- ``public tvm::ffi::Map< tvm::ffi::String, tvm::ffi::Function >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Map`)
- ``public tvm::ffi::Array< T, typename >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Array`)
- ``public tvm::ffi::Dict< K, V, typename >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Dict`)
- ``public tvm::ffi::Enum`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Enum`)
+- ``public tvm::ffi::EnumState`` (:ref:`exhale_class_classtvm_1_1ffi_1_1EnumState`)
- ``public tvm::ffi::Error`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Error`)
- ``public tvm::ffi::Function`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Function`)
- ``public tvm::ffi::List< T, typename >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1List`)
- ``public tvm::ffi::Map< K, V, typename >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Map`)
- ``public tvm::ffi::Module`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Module`)
-- ``public tvm::ffi::Optional< T, std::enable_if_t< use_ptr_based_optional_v< T > > >``
- ``public tvm::ffi::Shape`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Shape`)
- ``public tvm::ffi::StructuralKey`` (:ref:`exhale_class_classtvm_1_1ffi_1_1StructuralKey`)
- ``public tvm::ffi::StructuralVisitor`` (:ref:`exhale_class_classtvm_1_1ffi_1_1StructuralVisitor`)
@@ -31,7 +33,6 @@ Derived Types
- ``public tvm::ffi::Tuple< Types >`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Tuple`)
- ``public tvm::ffi::VisitErrorContext`` (:ref:`exhale_class_classtvm_1_1ffi_1_1VisitErrorContext`)
- ``public tvm::ffi::VisitInterrupt`` (:ref:`exhale_class_classtvm_1_1ffi_1_1VisitInterrupt`)
-- ``public tvm::ffi::details::VariantBase< true >``
- ``public tvm::ffi::reflection::AccessPath`` (:ref:`exhale_class_classtvm_1_1ffi_1_1reflection_1_1AccessPath`)
- ``public tvm::ffi::reflection::AccessStep`` (:ref:`exhale_class_classtvm_1_1ffi_1_1reflection_1_1AccessStep`)
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1StrEnum.rst
similarity index 54%
copy from ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
copy to ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1StrEnum.rst
index 2153403c46c..d29f5d0acf2 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1EnumObj.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1StrEnum.rst
@@ -1,6 +1,6 @@
-.. _exhale_class_classtvm_1_1ffi_1_1EnumObj:
+.. _exhale_class_classtvm_1_1ffi_1_1StrEnum:
-Class EnumObj
+Class StrEnum
=============
- Defined in :ref:`file_tvm_ffi_enum.h`
@@ -12,14 +12,14 @@ Inheritance Relationships
Base Type
*********
-- ``public tvm::ffi::Object`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Object`)
+- ``public tvm::ffi::Enum`` (:ref:`exhale_class_classtvm_1_1ffi_1_1Enum`)
Class Documentation
-------------------
-.. doxygenclass:: tvm::ffi::EnumObj
+.. doxygenclass:: tvm::ffi::StrEnum
:project: tvm-ffi
:members:
:protected-members:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1StrEnumObj.rst
similarity index 50%
copy from ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
copy to ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1StrEnumObj.rst
index 5e63628c153..98ebd8a776e 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Enum.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1StrEnumObj.rst
@@ -1,7 +1,7 @@
-.. _exhale_class_classtvm_1_1ffi_1_1Enum:
+.. _exhale_class_classtvm_1_1ffi_1_1StrEnumObj:
-Class Enum
-==========
+Class StrEnumObj
+================
- Defined in :ref:`file_tvm_ffi_enum.h`
@@ -12,14 +12,14 @@ Inheritance Relationships
Base Type
*********
-- ``public tvm::ffi::ObjectRef`` (:ref:`exhale_class_classtvm_1_1ffi_1_1ObjectRef`)
+- ``public tvm::ffi::EnumObj`` (:ref:`exhale_class_classtvm_1_1ffi_1_1EnumObj`)
Class Documentation
-------------------
-.. doxygenclass:: tvm::ffi::Enum
+.. doxygenclass:: tvm::ffi::StrEnumObj
:project: tvm-ffi
:members:
:protected-members:
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Variant.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Variant.rst
index 8fa8d7525ae..a32a899d16c 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Variant.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1Variant.rst
@@ -6,15 +6,6 @@ Template Class Variant
- Defined in :ref:`file_tvm_ffi_container_variant.h`
-Inheritance Relationships
--------------------------
-
-Base Type
-*********
-
-- ``public tvm::ffi::details::VariantBase< details::all_object_ref_v< V... > >``
-
-
Class Documentation
-------------------
diff --git a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef.rst b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef.rst
index 97ee8c87b8b..8828c27f6d2 100644
--- a/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef.rst
+++ b/ffi/_sources/reference/cpp/generated/classtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef.rst
@@ -6,6 +6,16 @@ Template Class OverloadObjectDef
- Defined in :ref:`file_tvm_ffi_reflection_overload.h`
+Nested Relationships
+--------------------
+
+
+Nested Types
+************
+
+- :ref:`exhale_struct_structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod`
+
+
Inheritance Relationships
-------------------------
diff --git a/ffi/_sources/reference/cpp/generated/define_type__traits_8h_1a63cd913de4d021d2e201531d5c675a88.rst b/ffi/_sources/reference/cpp/generated/define_type__traits_8h_1a63cd913de4d021d2e201531d5c675a88.rst
new file mode 100644
index 00000000000..4da53d1c38b
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/define_type__traits_8h_1a63cd913de4d021d2e201531d5c675a88.rst
@@ -0,0 +1,14 @@
+.. _exhale_define_type__traits_8h_1a63cd913de4d021d2e201531d5c675a88:
+
+Define TVM_FFI_DECLARE_OBJECT_INFO_LOOKUP
+=========================================
+
+- Defined in :ref:`file_tvm_ffi_type_traits.h`
+
+
+Define Documentation
+--------------------
+
+
+.. doxygendefine:: TVM_FFI_DECLARE_OBJECT_INFO_LOOKUP
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/dir_tvm_ffi.rst b/ffi/_sources/reference/cpp/generated/dir_tvm_ffi.rst
index 541d0b4f021..d95cef105a9 100644
--- a/ffi/_sources/reference/cpp/generated/dir_tvm_ffi.rst
+++ b/ffi/_sources/reference/cpp/generated/dir_tvm_ffi.rst
@@ -27,6 +27,7 @@ Files
- :ref:`file_tvm_ffi_base_details.h`
- :ref:`file_tvm_ffi_c_api.h`
- :ref:`file_tvm_ffi_cast.h`
+- :ref:`file_tvm_ffi_device.h`
- :ref:`file_tvm_ffi_dtype.h`
- :ref:`file_tvm_ffi_endian.h`
- :ref:`file_tvm_ffi_enum.h`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_any.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_any.h.rst
index 5d00f3435d4..01860fd1375 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_any.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_any.h.rst
@@ -35,6 +35,8 @@ Includes
--------
+- ``limits``
+
- ``string`` (:ref:`file_tvm_ffi_string.h`)
- ``tvm/ffi/c_api.h`` (:ref:`file_tvm_ffi_c_api.h`)
@@ -85,6 +87,8 @@ Included By
- :ref:`file_tvm_ffi_function.h`
+- :ref:`file_tvm_ffi_optional.h`
+
- :ref:`file_tvm_ffi_reflection_access_path.h`
- :ref:`file_tvm_ffi_reflection_accessor.h`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_c_api.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_c_api.h.rst
index 22a0acddd16..7ccba91b249 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_c_api.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_c_api.h.rst
@@ -85,6 +85,8 @@ Classes
- :ref:`exhale_struct_structTVMFFIByteArray`
+- :ref:`exhale_struct_structTVMFFICustomAllocator`
+
- :ref:`exhale_struct_structTVMFFIErrorCell`
- :ref:`exhale_struct_structTVMFFIFieldInfo`
@@ -95,6 +97,8 @@ Classes
- :ref:`exhale_struct_structTVMFFIObject`
+- :ref:`exhale_struct_structTVMFFIObjectAllocHeader`
+
- :ref:`exhale_struct_structTVMFFIOpaqueObjectCell`
- :ref:`exhale_struct_structTVMFFISeqCell`
@@ -171,6 +175,8 @@ Functions
- :ref:`exhale_function_c__api_8h_1aa26fa16c024c6f2fa15e46aa1333fdb9`
+- :ref:`exhale_function_c__api_8h_1a147c7c5616be4acf5a71623dbb7dd680`
+
- :ref:`exhale_function_c__api_8h_1a53c5ec2971806966ed96a6add32b5238`
- :ref:`exhale_function_c__api_8h_1afee5a803e22f9baf5ee2ff1f0ace6429`
@@ -191,6 +197,8 @@ Functions
- :ref:`exhale_function_c__api_8h_1a3253bbf35e2ad1361b2ce1de13d2c9b2`
+- :ref:`exhale_function_c__api_8h_1aa7d102c19d2ac12f730935e6fb210bf1`
+
- :ref:`exhale_function_c__api_8h_1a74c26efdd74840abc3e1581c73a38bfa`
- :ref:`exhale_function_c__api_8h_1a724b0d386cf3d50c7d141ca37be19092`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_cast.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_cast.h.rst
index 49d14cb9af6..ea3330e3d1d 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_cast.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_cast.h.rst
@@ -41,6 +41,8 @@ Includes
- ``tvm/ffi/optional.h`` (:ref:`file_tvm_ffi_optional.h`)
+- ``type_traits`` (:ref:`file_tvm_ffi_type_traits.h`)
+
Included By
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_list.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_list.h.rst
index b2f788a52f7..3d1c675fed3 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_list.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_list.h.rst
@@ -69,6 +69,8 @@ Included By
-----------
+- :ref:`file_tvm_ffi_enum.h`
+
- :ref:`file_tvm_ffi_extra_stl.h`
- :ref:`file_tvm_ffi_extra_visit_error_context.h`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_tensor.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_tensor.h.rst
index 11be699ac4c..2cbd0056da7 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_tensor.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_container_tensor.h.rst
@@ -41,6 +41,8 @@ Includes
- ``tvm/ffi/container/shape.h`` (:ref:`file_tvm_ffi_container_shape.h`)
+- ``tvm/ffi/device.h`` (:ref:`file_tvm_ffi_device.h`)
+
- ``tvm/ffi/dtype.h`` (:ref:`file_tvm_ffi_dtype.h`)
- ``tvm/ffi/error.h`` (:ref:`file_tvm_ffi_error.h`)
@@ -84,11 +86,11 @@ Functions
---------
-- :ref:`exhale_function_tensor_8h_1a65b3a61c540c72d9410150a3a7a76dde`
+- :ref:`exhale_function_tensor_8h_1a011d0a2dcbe5702156124d7a7223b3dd`
- :ref:`exhale_function_tensor_8h_1a226723176642cde5996498e7da6a6368`
-- :ref:`exhale_function_tensor_8h_1a011d0a2dcbe5702156124d7a7223b3dd`
+- :ref:`exhale_function_tensor_8h_1a65b3a61c540c72d9410150a3a7a76dde`
- :ref:`exhale_function_tensor_8h_1a71e4a492b5a03a19a95087771a7e9ed1`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_device.h.rst
similarity index 54%
copy from ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst
copy to ffi/_sources/reference/cpp/generated/file_tvm_ffi_device.h.rst
index 874ab2c5268..1a8accb5079 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_device.h.rst
@@ -1,8 +1,8 @@
-.. _file_tvm_ffi_dtype.h:
+.. _file_tvm_ffi_device.h:
-File dtype.h
-============
+File device.h
+=============
|exhale_lsh| :ref:`Parent directory <dir_tvm_ffi>` (``tvm/ffi``)
@@ -10,7 +10,7 @@ File dtype.h
-Data type handling.
+Device handling.
@@ -18,14 +18,14 @@ Data type handling.
:local:
:backlinks: none
-Definition (``tvm/ffi/dtype.h``)
---------------------------------
+Definition (``tvm/ffi/device.h``)
+---------------------------------
.. toctree::
:maxdepth: 1
- program_listing_file_tvm_ffi_dtype.h.rst
+ program_listing_file_tvm_ffi_device.h.rst
@@ -39,11 +39,13 @@ Includes
- ``dlpack/dlpack.h``
-- ``string`` (:ref:`file_tvm_ffi_string.h`)
+- ``limits``
+
+- ``optional`` (:ref:`file_tvm_ffi_optional.h`)
-- ``tvm/ffi/error.h`` (:ref:`file_tvm_ffi_error.h`)
+- ``string`` (:ref:`file_tvm_ffi_string.h`)
-- ``tvm/ffi/function.h`` (:ref:`file_tvm_ffi_function.h`)
+- ``string_view``
- ``tvm/ffi/string.h`` (:ref:`file_tvm_ffi_string.h`)
@@ -70,19 +72,3 @@ Namespaces
- :ref:`namespace_tvm__ffi`
-
-Enums
------
-
-
-- :ref:`exhale_enum_dtype_8h_1a16f66b97fa44d7bd6114324c8b8e1bed`
-
-
-Functions
----------
-
-
-- :ref:`exhale_function_dtype_8h_1a94787950883e5a7e97b764ddd342afc3`
-
-- :ref:`exhale_function_dtype_8h_1a8a71c64237efaa13a8d40dfacd6c3165`
-
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst
index 874ab2c5268..5d0be12667a 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_dtype.h.rst
@@ -84,5 +84,13 @@ Functions
- :ref:`exhale_function_dtype_8h_1a94787950883e5a7e97b764ddd342afc3`
+- :ref:`exhale_function_dtype_8h_1a89696eef7917af8ff34285cb6fae4c63`
+
+- :ref:`exhale_function_dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a`
+
+- :ref:`exhale_function_dtype_8h_1a74a70941a707682598886f8475f86848`
+
+- :ref:`exhale_function_dtype_8h_1a95190c80d6dfa260c156b00ce5336c83`
+
- :ref:`exhale_function_dtype_8h_1a8a71c64237efaa13a8d40dfacd6c3165`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_enum.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_enum.h.rst
index d535094957b..3295da6fbab 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_enum.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_enum.h.rst
@@ -43,6 +43,8 @@ Includes
- ``tvm/ffi/container/dict.h`` (:ref:`file_tvm_ffi_container_dict.h`)
+- ``tvm/ffi/container/list.h`` (:ref:`file_tvm_ffi_container_list.h`)
+
- ``tvm/ffi/error.h`` (:ref:`file_tvm_ffi_error.h`)
- ``tvm/ffi/object.h`` (:ref:`file_tvm_ffi_object.h`)
@@ -85,3 +87,15 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1EnumObj`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1EnumState`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1EnumStateObj`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1IntEnum`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1IntEnumObj`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1StrEnum`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1StrEnumObj`
+
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_error.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_error.h.rst
index b56524cdce6..607937e8149 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_error.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_error.h.rst
@@ -92,8 +92,6 @@ Included By
- :ref:`file_tvm_ffi_tvm_ffi.h`
-- :ref:`file_tvm_ffi_type_traits.h`
-
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_expected.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_expected.h.rst
index ba86a955eff..16311cba62a 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_expected.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_expected.h.rst
@@ -73,5 +73,7 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1Expected`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1Expected_3_01void_01_4`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1Unexpected`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_base64.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_base64.h.rst
index f7b571fe46c..9a61de7a6d0 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_base64.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_base64.h.rst
@@ -61,7 +61,7 @@ Functions
- :ref:`exhale_function_base64_8h_1ae1d4736f7dc56b224acd303ba7bf7a45`
-- :ref:`exhale_function_base64_8h_1aa5b2a4531449585b9f079cb170a79f0b`
-
- :ref:`exhale_function_base64_8h_1a279b4ba2f4c7ea16291ef24b73e43963`
+- :ref:`exhale_function_base64_8h_1aa5b2a4531449585b9f079cb170a79f0b`
+
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_json.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_json.h.rst
index 0bef95761b4..a0cbcc3dd02 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_json.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_extra_json.h.rst
@@ -71,7 +71,7 @@ Functions
- :ref:`exhale_function_json_8h_1a86217bda8bfebd85f8265878bc8a59b8`
-- :ref:`exhale_function_json_8h_1a2cd33b0fbc0194eaa803b8a476670587`
+- :ref:`exhale_function_json_8h_1a0a0dc3202335cbaa265618821764fa2d`
Typedefs
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_memory.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_memory.h.rst
index d5b1d86cb56..d163c4ec86d 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_memory.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_memory.h.rst
@@ -39,6 +39,8 @@ Includes
- ``cstdlib``
+- ``new``
+
- ``tvm/ffi/object.h`` (:ref:`file_tvm_ffi_object.h`)
- ``type_traits`` (:ref:`file_tvm_ffi_type_traits.h`)
@@ -85,6 +87,8 @@ Functions
---------
+- :ref:`exhale_function_memory_8h_1a6001462e18d71614c0f11a4c2e064f7e`
+
- :ref:`exhale_function_memory_8h_1a801e8ecc2e3adbc1dac52c714e7cef11`
- :ref:`exhale_function_memory_8h_1a8892f2a3cad8dbc51930c464f2ab863b`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_object.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_object.h.rst
index 787138a77ae..0ab21712069 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_object.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_object.h.rst
@@ -43,6 +43,8 @@ Includes
- ``tvm/ffi/c_api.h`` (:ref:`file_tvm_ffi_c_api.h`)
+- ``tvm/ffi/type_traits.h`` (:ref:`file_tvm_ffi_type_traits.h`)
+
- ``type_traits`` (:ref:`file_tvm_ffi_type_traits.h`)
- ``utility``
@@ -87,8 +89,6 @@ Included By
- :ref:`file_tvm_ffi_tvm_ffi.h`
-- :ref:`file_tvm_ffi_type_traits.h`
-
@@ -109,10 +109,12 @@ Classes
- :ref:`exhale_struct_structtvm_1_1ffi_1_1ObjectPtrHash`
-- :ref:`exhale_struct_structtvm_1_1ffi_1_1StaticTypeKey`
+- :ref:`exhale_struct_structtvm_1_1ffi_1_1ObjectRefWithFallbackTraitsBase`
- :ref:`exhale_struct_structtvm_1_1ffi_1_1UnsafeInit`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1Arc`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1Object`
- :ref:`exhale_class_classtvm_1_1ffi_1_1ObjectPtr`
@@ -124,13 +126,6 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1WeakObjectPtr`
-Functions
----------
-
-
-- :ref:`exhale_function_object_8h_1a0d6e075f219808c4ff7adebd99210a7b`
-
-
Defines
-------
@@ -148,11 +143,11 @@ Defines
- :ref:`exhale_define_object_8h_1a0fc0cc2d8f4318bc41a896c117e8a15c`
-Typedefs
---------
+Variables
+---------
-- :ref:`exhale_typedef_object_8h_1a7ba296d84188e5970ba854332a1f04a6`
+- :ref:`exhale_variable_object_8h_1a5f52cb03b4b23d5d7738ff0386335845`
-- :ref:`exhale_typedef_object_8h_1ae125f5f5a8a94c7340577c1959805295`
+- :ref:`exhale_variable_object_8h_1a31dc4b1b71941b3e4217a0e389f807a4`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_optional.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_optional.h.rst
index 7bf4b6b6964..3815d21d9a8 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_optional.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_optional.h.rst
@@ -32,7 +32,7 @@ Definition (``tvm/ffi/optional.h``)
Detailed Description
--------------------
-Optional<T> specializes for T is ObjectRef and used nullptr to indicate nullopt.
+Optional<T> uses a hybrid representation. For types that enable Any storage (``TypeTraits<T>::storage_enabled``), it is backed by a single :ref:`exhale_struct_structTVMFFIAny` (Any) with nullopt represented as kTVMFFINone, mirroring Variant<...>; the layout is then independent of T (sizeof == sizeof(Any)) which keeps the ABI stable. For types that do not enable storage (e.g. non-owning view types) it falls back to std::optional<T>.
@@ -47,6 +47,8 @@ Includes
- ``string`` (:ref:`file_tvm_ffi_string.h`)
+- ``tvm/ffi/any.h`` (:ref:`file_tvm_ffi_any.h`)
+
- ``tvm/ffi/error.h`` (:ref:`file_tvm_ffi_error.h`)
- ``tvm/ffi/object.h`` (:ref:`file_tvm_ffi_object.h`)
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_accessor.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_accessor.h.rst
index 37e27923f7a..8e0a520d15d 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_accessor.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_accessor.h.rst
@@ -121,15 +121,13 @@ Variables
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a214da76aef89b240bf763409cc7ce8f4`
+- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1ab8b34ca1b301024a7f48d226906bf5c1`
+
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a23d22935800d0c4ccefe7a3a0b9a44c0`
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a8ad904131880910d82adfd8e695fe259`
-- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a73b8599796f9364537b3ac1091e6ca5a`
-
-- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1aff9e02aea85ecba0ee1956f7ee2ce4a9`
-
-- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a2235b3faf38b1017a13ef6178d9a8fa8`
+- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a877b4867a278823be18e6c7f7bff378e`
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a4e67838e846b587f2f82127c53b6ef86`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_enum_def.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_enum_def.h.rst
index d9a0c532201..80438c9ffa5 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_enum_def.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_enum_def.h.rst
@@ -37,8 +37,6 @@ Includes
- ``cstdint``
-- ``string`` (:ref:`file_tvm_ffi_string.h`)
-
- ``tvm/ffi/any.h`` (:ref:`file_tvm_ffi_any.h`)
- ``tvm/ffi/c_api.h`` (:ref:`file_tvm_ffi_c_api.h`)
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_overload.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_overload.h.rst
index b4d5c86a479..81391e9bc2a 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_overload.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_reflection_overload.h.rst
@@ -95,5 +95,7 @@ Classes
-------
+- :ref:`exhale_struct_structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_string.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_string.h.rst
index ee5e1ddd52d..759c8c10a51 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_string.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_string.h.rst
@@ -71,6 +71,8 @@ Included By
- :ref:`file_tvm_ffi_any.h`
+- :ref:`file_tvm_ffi_device.h`
+
- :ref:`file_tvm_ffi_dtype.h`
- :ref:`file_tvm_ffi_enum.h`
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_tvm_ffi.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_tvm_ffi.h.rst
index 1eec8e58af4..b77789d6be1 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_tvm_ffi.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_tvm_ffi.h.rst
@@ -66,6 +66,8 @@ Includes
- ``tvm/ffi/container/variant.h`` (:ref:`file_tvm_ffi_container_variant.h`)
+- ``tvm/ffi/device.h`` (:ref:`file_tvm_ffi_device.h`)
+
- ``tvm/ffi/dtype.h`` (:ref:`file_tvm_ffi_dtype.h`)
- ``tvm/ffi/endian.h`` (:ref:`file_tvm_ffi_endian.h`)
diff --git a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_type_traits.h.rst b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_type_traits.h.rst
index d549b2dc605..e31d46031e3 100644
--- a/ffi/_sources/reference/cpp/generated/file_tvm_ffi_type_traits.h.rst
+++ b/ffi/_sources/reference/cpp/generated/file_tvm_ffi_type_traits.h.rst
@@ -9,6 +9,11 @@ File type_traits.h
.. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS
+
+Type trait helpers for FFI values and lookup-only ABI objects.
+
+
+
.. contents:: Contents
:local:
:backlinks: none
@@ -30,7 +35,7 @@ Includes
--------
-- ``limits``
+- ``optional`` (:ref:`file_tvm_ffi_optional.h`)
- ``string`` (:ref:`file_tvm_ffi_string.h`)
@@ -38,10 +43,6 @@ Includes
- ``tvm/ffi/c_api.h`` (:ref:`file_tvm_ffi_c_api.h`)
-- ``tvm/ffi/error.h`` (:ref:`file_tvm_ffi_error.h`)
-
-- ``tvm/ffi/object.h`` (:ref:`file_tvm_ffi_object.h`)
-
- ``type_traits`` (:ref:`file_tvm_ffi_type_traits.h`)
- ``utility``
@@ -58,10 +59,14 @@ Included By
- :ref:`file_tvm_ffi_container_tensor.h`
+- :ref:`file_tvm_ffi_device.h`
+
- :ref:`file_tvm_ffi_dtype.h`
- :ref:`file_tvm_ffi_extra_stl.h`
+- :ref:`file_tvm_ffi_object.h`
+
- :ref:`file_tvm_ffi_reflection_accessor.h`
- :ref:`file_tvm_ffi_reflection_overload.h`
@@ -92,7 +97,7 @@ Classes
- :ref:`exhale_struct_structtvm_1_1ffi_1_1FallbackOnlyTraitsBase`
-- :ref:`exhale_struct_structtvm_1_1ffi_1_1ObjectRefWithFallbackTraitsBase`
+- :ref:`exhale_struct_structtvm_1_1ffi_1_1StaticTypeKey`
- :ref:`exhale_struct_structtvm_1_1ffi_1_1TypeToFieldStaticTypeIndex`
@@ -100,3 +105,33 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1StrictBool`
+
+Functions
+---------
+
+
+- :ref:`exhale_function_type__traits_8h_1a0d6e075f219808c4ff7adebd99210a7b`
+
+
+Defines
+-------
+
+
+- :ref:`exhale_define_type__traits_8h_1a63cd913de4d021d2e201531d5c675a88`
+
+
+Typedefs
+--------
+
+
+- :ref:`exhale_typedef_type__traits_8h_1a7ba296d84188e5970ba854332a1f04a6`
+
+- :ref:`exhale_typedef_type__traits_8h_1ae125f5f5a8a94c7340577c1959805295`
+
+
+Variables
+---------
+
+
+- :ref:`exhale_variable_type__traits_8h_1a62ef22ceb232bddd3e9540895af38cc1`
+
diff --git a/ffi/_sources/reference/cpp/generated/function_c__api_8h_1a147c7c5616be4acf5a71623dbb7dd680.rst b/ffi/_sources/reference/cpp/generated/function_c__api_8h_1a147c7c5616be4acf5a71623dbb7dd680.rst
new file mode 100644
index 00000000000..3523d4e971f
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_c__api_8h_1a147c7c5616be4acf5a71623dbb7dd680.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_c__api_8h_1a147c7c5616be4acf5a71623dbb7dd680:
+
+Function TVMFFIGetCustomAllocator
+=================================
+
+- Defined in :ref:`file_tvm_ffi_c_api.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: TVMFFIGetCustomAllocator(void)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_c__api_8h_1aa7d102c19d2ac12f730935e6fb210bf1.rst b/ffi/_sources/reference/cpp/generated/function_c__api_8h_1aa7d102c19d2ac12f730935e6fb210bf1.rst
new file mode 100644
index 00000000000..4083519085c
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_c__api_8h_1aa7d102c19d2ac12f730935e6fb210bf1.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_c__api_8h_1aa7d102c19d2ac12f730935e6fb210bf1:
+
+Function TVMFFISetCustomAllocator
+=================================
+
+- Defined in :ref:`file_tvm_ffi_c_api.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: TVMFFISetCustomAllocator(TVMFFICustomAllocator *)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a.rst b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a.rst
new file mode 100644
index 00000000000..699a69caec8
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a:
+
+Function tvm::ffi::DTypeIsBool
+==============================
+
+- Defined in :ref:`file_tvm_ffi_dtype.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: tvm::ffi::DTypeIsBool(DLDataType)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a74a70941a707682598886f8475f86848.rst b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a74a70941a707682598886f8475f86848.rst
new file mode 100644
index 00000000000..d0ddb91bd6b
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a74a70941a707682598886f8475f86848.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_dtype_8h_1a74a70941a707682598886f8475f86848:
+
+Function tvm::ffi::DTypeIsFloat
+===============================
+
+- Defined in :ref:`file_tvm_ffi_dtype.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: tvm::ffi::DTypeIsFloat(DLDataType)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a89696eef7917af8ff34285cb6fae4c63.rst b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a89696eef7917af8ff34285cb6fae4c63.rst
new file mode 100644
index 00000000000..1b8ca78e67a
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a89696eef7917af8ff34285cb6fae4c63.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_dtype_8h_1a89696eef7917af8ff34285cb6fae4c63:
+
+Function tvm::ffi::DTypeAbbrev
+==============================
+
+- Defined in :ref:`file_tvm_ffi_dtype.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: tvm::ffi::DTypeAbbrev(DLDataType)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a95190c80d6dfa260c156b00ce5336c83.rst b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a95190c80d6dfa260c156b00ce5336c83.rst
new file mode 100644
index 00000000000..62c04dabbe1
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_dtype_8h_1a95190c80d6dfa260c156b00ce5336c83.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_dtype_8h_1a95190c80d6dfa260c156b00ce5336c83:
+
+Function tvm::ffi::DTypeIsInt
+=============================
+
+- Defined in :ref:`file_tvm_ffi_dtype.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: tvm::ffi::DTypeIsInt(DLDataType)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_json_8h_1a2cd33b0fbc0194eaa803b8a476670587.rst b/ffi/_sources/reference/cpp/generated/function_json_8h_1a0a0dc3202335cbaa265618821764fa2d.rst
similarity index 68%
rename from ffi/_sources/reference/cpp/generated/function_json_8h_1a2cd33b0fbc0194eaa803b8a476670587.rst
rename to ffi/_sources/reference/cpp/generated/function_json_8h_1a0a0dc3202335cbaa265618821764fa2d.rst
index 22b87f65c58..e113ecc3a23 100644
--- a/ffi/_sources/reference/cpp/generated/function_json_8h_1a2cd33b0fbc0194eaa803b8a476670587.rst
+++ b/ffi/_sources/reference/cpp/generated/function_json_8h_1a0a0dc3202335cbaa265618821764fa2d.rst
@@ -1,4 +1,4 @@
-.. _exhale_function_json_8h_1a2cd33b0fbc0194eaa803b8a476670587:
+.. _exhale_function_json_8h_1a0a0dc3202335cbaa265618821764fa2d:
Function tvm::ffi::json::Stringify
==================================
@@ -10,5 +10,5 @@ Function Documentation
----------------------
-.. doxygenfunction:: tvm::ffi::json::Stringify(const json::Value&, Optional<int>)
+.. doxygenfunction:: tvm::ffi::json::Stringify(const json::Value&, const Optional<int>&)
:project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_memory_8h_1a6001462e18d71614c0f11a4c2e064f7e.rst b/ffi/_sources/reference/cpp/generated/function_memory_8h_1a6001462e18d71614c0f11a4c2e064f7e.rst
new file mode 100644
index 00000000000..ad7769713b6
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/function_memory_8h_1a6001462e18d71614c0f11a4c2e064f7e.rst
@@ -0,0 +1,14 @@
+.. _exhale_function_memory_8h_1a6001462e18d71614c0f11a4c2e064f7e:
+
+Template Function tvm::ffi::make_arc
+====================================
+
+- Defined in :ref:`file_tvm_ffi_memory.h`
+
+
+Function Documentation
+----------------------
+
+
+.. doxygenfunction:: tvm::ffi::make_arc(Args&&...)
+ :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/function_object_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst b/ffi/_sources/reference/cpp/generated/function_type__traits_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst
similarity index 57%
rename from ffi/_sources/reference/cpp/generated/function_object_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst
rename to ffi/_sources/reference/cpp/generated/function_type__traits_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst
index 486a65aacae..02bce92ed70 100644
--- a/ffi/_sources/reference/cpp/generated/function_object_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst
+++ b/ffi/_sources/reference/cpp/generated/function_type__traits_8h_1a0d6e075f219808c4ff7adebd99210a7b.rst
@@ -1,9 +1,9 @@
-.. _exhale_function_object_8h_1a0d6e075f219808c4ff7adebd99210a7b:
+.. _exhale_function_type__traits_8h_1a0d6e075f219808c4ff7adebd99210a7b:
Function tvm::ffi::TypeIndexToTypeKey
=====================================
-- Defined in :ref:`file_tvm_ffi_object.h`
+- Defined in :ref:`file_tvm_ffi_type_traits.h`
Function Documentation
diff --git a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi.rst b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi.rst
index e7d3328d92b..e5b28bff2f6 100644
--- a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi.rst
+++ b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi.rst
@@ -72,6 +72,8 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1AnyView`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1Arc`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1Array`
- :ref:`exhale_class_classtvm_1_1ffi_1_1ArrayObj`
@@ -92,16 +94,26 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1EnumObj`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1EnumState`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1EnumStateObj`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1Error`
- :ref:`exhale_class_classtvm_1_1ffi_1_1ErrorObj`
- :ref:`exhale_class_classtvm_1_1ffi_1_1Expected`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1Expected_3_01void_01_4`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1Function`
- :ref:`exhale_class_classtvm_1_1ffi_1_1FunctionObj`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1IntEnum`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1IntEnumObj`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1List`
- :ref:`exhale_class_classtvm_1_1ffi_1_1ListObj`
@@ -138,6 +150,10 @@ Classes
- :ref:`exhale_class_classtvm_1_1ffi_1_1SmallMapBaseObj`
+- :ref:`exhale_class_classtvm_1_1ffi_1_1StrEnum`
+
+- :ref:`exhale_class_classtvm_1_1ffi_1_1StrEnumObj`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1StrictBool`
- :ref:`exhale_class_classtvm_1_1ffi_1_1String`
@@ -196,14 +212,14 @@ Functions
---------
-- :ref:`exhale_function_base64_8h_1ae1d4736f7dc56b224acd303ba7bf7a45`
-
- :ref:`exhale_function_base64_8h_1acb849cdb1d9b9620be10bbcda0257afa`
-- :ref:`exhale_function_base64_8h_1a279b4ba2f4c7ea16291ef24b73e43963`
+- :ref:`exhale_function_base64_8h_1ae1d4736f7dc56b224acd303ba7bf7a45`
- :ref:`exhale_function_base64_8h_1aa5b2a4531449585b9f079cb170a79f0b`
+- :ref:`exhale_function_base64_8h_1a279b4ba2f4c7ea16291ef24b73e43963`
+
- :ref:`exhale_function_endian_8h_1ab4e0ed8000c632cd2c7cd089c0a0d1af`
- :ref:`exhale_function_array_8h_1af5983fd2a31e79635307875b3a216472`
@@ -214,6 +230,14 @@ Functions
- :ref:`exhale_function_dtype_8h_1a94787950883e5a7e97b764ddd342afc3`
+- :ref:`exhale_function_dtype_8h_1a89696eef7917af8ff34285cb6fae4c63`
+
+- :ref:`exhale_function_dtype_8h_1a16f5ec0ba28cdd73f61247f4a662115a`
+
+- :ref:`exhale_function_dtype_8h_1a74a70941a707682598886f8475f86848`
+
+- :ref:`exhale_function_dtype_8h_1a95190c80d6dfa260c156b00ce5336c83`
+
- :ref:`exhale_function_error_8h_1af4cf9e94df0f183e9c5c0a3ccb05fda5`
- :ref:`exhale_function_string_8h_1a462b67a1ca03cb444893ec950bf5e916`
@@ -228,10 +252,10 @@ Functions
- :ref:`exhale_function_tensor_8h_1a226723176642cde5996498e7da6a6368`
-- :ref:`exhale_function_tensor_8h_1a011d0a2dcbe5702156124d7a7223b3dd`
-
- :ref:`exhale_function_tensor_8h_1a65b3a61c540c72d9410150a3a7a76dde`
+- :ref:`exhale_function_tensor_8h_1a011d0a2dcbe5702156124d7a7223b3dd`
+
- :ref:`exhale_function_cast_8h_1a4dba749dd934d8a7891ad126a8fdcc1f`
- :ref:`exhale_function_cast_8h_1a3c5fed9bb23b4804b61037c8ac4874f1`
@@ -244,6 +268,8 @@ Functions
- :ref:`exhale_function_tensor_8h_1aab70a15ca1dde710bc3052c5ce1f6fbd`
+- :ref:`exhale_function_memory_8h_1a6001462e18d71614c0f11a4c2e064f7e`
+
- :ref:`exhale_function_memory_8h_1a801e8ecc2e3adbc1dac52c714e7cef11`
- :ref:`exhale_function_array_8h_1a3b56317c7cfb2760cf6c09c303840967`
@@ -276,7 +302,7 @@ Functions
- :ref:`exhale_function_string_8h_1ad045700080c053c50d68cde298b2b4b2`
-- :ref:`exhale_function_object_8h_1a0d6e075f219808c4ff7adebd99210a7b`
+- :ref:`exhale_function_type__traits_8h_1a0d6e075f219808c4ff7adebd99210a7b`
- :ref:`exhale_function_function_8h_1a111e2ed7444eb220e19c7624d0932d89`
@@ -289,13 +315,19 @@ Typedefs
- :ref:`exhale_typedef_structural__visit_8h_1a745d053678181bd38e0fee17b772656b`
-- :ref:`exhale_typedef_object_8h_1a7ba296d84188e5970ba854332a1f04a6`
+- :ref:`exhale_typedef_type__traits_8h_1a7ba296d84188e5970ba854332a1f04a6`
-- :ref:`exhale_typedef_object_8h_1ae125f5f5a8a94c7340577c1959805295`
+- :ref:`exhale_typedef_type__traits_8h_1ae125f5f5a8a94c7340577c1959805295`
Variables
---------
+- :ref:`exhale_variable_object_8h_1a5f52cb03b4b23d5d7738ff0386335845`
+
- :ref:`exhale_variable_array_8h_1a3bbf4c2bf19b72b026ad9e19a23143d5`
+
+- :ref:`exhale_variable_object_8h_1a31dc4b1b71941b3e4217a0e389f807a4`
+
+- :ref:`exhale_variable_type__traits_8h_1a62ef22ceb232bddd3e9540895af38cc1`
diff --git a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__json.rst b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__json.rst
index 77f2c45e9fb..1b41103b0ed 100644
--- a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__json.rst
+++ b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__json.rst
@@ -19,7 +19,7 @@ Functions
- :ref:`exhale_function_json_8h_1a86217bda8bfebd85f8265878bc8a59b8`
-- :ref:`exhale_function_json_8h_1a2cd33b0fbc0194eaa803b8a476670587`
+- :ref:`exhale_function_json_8h_1a0a0dc3202335cbaa265618821764fa2d`
Typedefs
diff --git a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection.rst b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection.rst
index aa5c25194dc..8d6cf725693 100644
--- a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection.rst
+++ b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection.rst
@@ -39,6 +39,8 @@ Classes
- :ref:`exhale_struct_structtvm_1_1ffi_1_1reflection_1_1MethodInfoBuilder`
+- :ref:`exhale_struct_structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod`
+
- :ref:`exhale_class_classtvm_1_1ffi_1_1reflection_1_1AccessPath`
- :ref:`exhale_class_classtvm_1_1ffi_1_1reflection_1_1AccessPathObj`
diff --git a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection__type_attr.rst b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection__type_attr.rst
index e021d1bb0bd..bbec413ff40 100644
--- a/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection__type_attr.rst
+++ b/ffi/_sources/reference/cpp/generated/namespace_tvm__ffi__reflection__type_attr.rst
@@ -46,15 +46,13 @@ Variables
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a214da76aef89b240bf763409cc7ce8f4`
+- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1ab8b34ca1b301024a7f48d226906bf5c1`
+
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a23d22935800d0c4ccefe7a3a0b9a44c0`
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a8ad904131880910d82adfd8e695fe259`
-- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a73b8599796f9364537b3ac1091e6ca5a`
-
-- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1aff9e02aea85ecba0ee1956f7ee2ce4a9`
-
-- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a2235b3faf38b1017a13ef6178d9a8fa8`
+- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a877b4867a278823be18e6c7f7bff378e`
- :ref:`exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a4e67838e846b587f2f82127c53b6ef86`
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_any.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_any.h.rst
index fd389639860..0bb033d04bc 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_any.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_any.h.rst
@@ -35,6 +35,7 @@ Program Listing for File any.h
#include <tvm/ffi/string.h>
#include <tvm/ffi/type_traits.h>
+ #include <limits>
#include <string>
#include <utility>
@@ -104,7 +105,7 @@ Program Listing for File any.h
template <typename T, typename = std::enable_if_t<TypeTraits<T>::convert_enabled>>
TVM_FFI_INLINE T cast() const {
std::optional<T> opt = TypeTraits<T>::TryCastFromAnyView(&data_);
- if (!opt.has_value()) {
+ if (TVM_FFI_PREDICT_FALSE(!opt.has_value())) {
TVM_FFI_THROW(TypeError) << "Cannot convert from type `"
<< TypeTraits<T>::GetMismatchTypeInfo(&data_) << "` to `"
<< TypeTraits<T>::TypeStr() << "`";
@@ -238,6 +239,22 @@ Program Listing for File any.h
}
}
+ template <typename T,
+ typename = std::enable_if_t<TypeTraits<T>::storage_enabled || std::is_same_v<T, Any>>>
+ TVM_FFI_INLINE T as_or_throw() && {
+ if constexpr (std::is_same_v<T, Any>) {
+ return std::move(*this);
+ } else {
+ std::optional<T> result = std::move(*this).template as<T>();
+ if (TVM_FFI_PREDICT_FALSE(!result.has_value())) {
+ TVM_FFI_THROW(TypeError) << "Cannot treat type `"
+ << TypeTraits<T>::GetMismatchTypeInfo(&data_) << "` as type `"
+ << TypeTraits<T>::TypeStr() << "`";
+ }
+ return *std::move(result);
+ }
+ }
+
template <typename T,
typename = std::enable_if_t<TypeTraits<T>::convert_enabled || std::is_same_v<T, Any>>>
TVM_FFI_INLINE std::optional<T> as() const& {
@@ -252,6 +269,22 @@ Program Listing for File any.h
}
}
+ template <typename T,
+ typename = std::enable_if_t<TypeTraits<T>::convert_enabled || std::is_same_v<T, Any>>>
+ TVM_FFI_INLINE T as_or_throw() const& {
+ if constexpr (std::is_same_v<T, Any>) {
+ return *this;
+ } else {
+ std::optional<T> result = this->as<T>();
+ if (TVM_FFI_PREDICT_FALSE(!result.has_value())) {
+ TVM_FFI_THROW(TypeError) << "Cannot treat type `"
+ << TypeTraits<T>::GetMismatchTypeInfo(&data_) << "` as type `"
+ << TypeTraits<T>::TypeStr() << "`";
+ }
+ return *std::move(result);
+ }
+ }
+
template <typename T, typename = std::enable_if_t<std::is_base_of_v<Object, T>>>
TVM_FFI_INLINE const T* as() const& {
return this->as<const T*>().value_or(nullptr);
@@ -260,7 +293,7 @@ Program Listing for File any.h
template <typename T, typename = std::enable_if_t<TypeTraits<T>::convert_enabled>>
TVM_FFI_INLINE T cast() const& {
std::optional<T> opt = TypeTraits<T>::TryCastFromAnyView(&data_);
- if (!opt.has_value()) {
+ if (TVM_FFI_PREDICT_FALSE(!opt.has_value())) {
TVM_FFI_THROW(TypeError) << "Cannot convert from type `"
<< TypeTraits<T>::GetMismatchTypeInfo(&data_) << "` to `"
<< TypeTraits<T>::TypeStr() << "`";
@@ -275,7 +308,7 @@ Program Listing for File any.h
}
// slow path, try to do fallback convert
std::optional<T> opt = TypeTraits<T>::TryCastFromAnyView(&data_);
- if (!opt.has_value()) {
+ if (TVM_FFI_PREDICT_FALSE(!opt.has_value())) {
TVM_FFI_THROW(TypeError) << "Cannot convert from type `"
<< TypeTraits<T>::GetMismatchTypeInfo(&data_) << "` to `"
<< TypeTraits<T>::TypeStr() << "`";
@@ -622,6 +655,86 @@ Program Listing for File any.h
}
}
};
+
+ // Defer this definition until any.h so the throwing path can depend on
+ // TVM_FFI_THROW(TypeError), while object.h stays below the error layer.
+ template <typename ObjectRefType, typename>
+ TVM_FFI_INLINE ObjectRefType ObjectRef::as_or_throw() const& {
+ if (data_ != nullptr) {
+ // Piggy back to Any TypeTraits for rich ObjectRef check, temp any_data will optimize away.
+ TVMFFIAny any_data;
+ any_data.type_index = data_->type_index();
+ TVM_FFI_UNSAFE_ASSUME(any_data.type_index >= TypeIndex::kTVMFFIStaticObjectBegin);
+ any_data.zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(&any_data);
+ any_data.v_obj = reinterpret_cast<TVMFFIObject*>(const_cast<Object*>(data_.get()));
+ if (TVM_FFI_PREDICT_TRUE(TypeTraits<ObjectRefType>::CheckAnyStrict(&any_data))) {
+ ObjectRefType result(UnsafeInit{});
+ result.data_ = data_;
+ return result;
+ } else {
+ TVM_FFI_THROW(TypeError) << "Cannot treat type `"
+ << TypeTraits<ObjectRefType>::GetMismatchTypeInfo(&any_data)
+ << "` as type `" << TypeTraits<ObjectRefType>::TypeStr() << "`";
+ }
+ } else {
+ if constexpr (ObjectRefType::_type_is_nullable) {
+ return ObjectRefType(UnsafeInit{});
+ } else {
+ TVM_FFI_THROW(TypeError) << "Cannot treat type `" << StaticTypeKey::kTVMFFINone
+ << "` as type `" << TypeTraits<ObjectRefType>::TypeStr() << "`";
+ }
+ }
+ TVM_FFI_UNREACHABLE();
+ }
+
+ template <typename ObjectRefType, typename>
+ TVM_FFI_INLINE ObjectRefType ObjectRef::as_or_throw() && {
+ if (data_ != nullptr) {
+ // Piggy back to Any TypeTraits for rich ObjectRef check, temp any_data will optimize away.
+ TVMFFIAny any_data;
+ any_data.type_index = data_->type_index();
+ TVM_FFI_UNSAFE_ASSUME(any_data.type_index >= TypeIndex::kTVMFFIStaticObjectBegin);
+ any_data.zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(&any_data);
+ any_data.v_obj = reinterpret_cast<TVMFFIObject*>(const_cast<Object*>(data_.get()));
+ if (TVM_FFI_PREDICT_TRUE(TypeTraits<ObjectRefType>::CheckAnyStrict(&any_data))) {
+ ObjectRefType result(UnsafeInit{});
+ result.data_ = std::move(data_);
+ data_ = nullptr;
+ return result;
+ } else {
+ TVM_FFI_THROW(TypeError) << "Cannot treat type `"
+ << TypeTraits<ObjectRefType>::GetMismatchTypeInfo(&any_data)
+ << "` as type `" << TypeTraits<ObjectRefType>::TypeStr() << "`";
+ }
+ } else {
+ if constexpr (ObjectRefType::_type_is_nullable) {
+ return ObjectRefType(UnsafeInit{});
+ } else {
+ TVM_FFI_THROW(TypeError) << "Cannot treat type `" << StaticTypeKey::kTVMFFINone
+ << "` as type `" << TypeTraits<ObjectRefType>::TypeStr() << "`";
+ }
+ }
+ TVM_FFI_UNREACHABLE();
+ }
+
+ // Placed near the end because this specialization depends on error handling.
+ template <>
+ struct TypeTraits<uint64_t> : public TypeTraitsIntBase<uint64_t> {
+ TVM_FFI_INLINE static void CopyToAnyView(const uint64_t& src, TVMFFIAny* result) {
+ if (src > static_cast<uint64_t>(std::numeric_limits<int64_t>::max())) {
+ TVM_FFI_THROW(OverflowError)
+ << "Integer value " << src << " is too large to fit in int64_t. "
+ << "Consider explicitly casting to int64_t first if this is intentional.";
+ }
+ TypeTraitsIntBase<uint64_t>::CopyInt64ToAnyView(static_cast<int64_t>(src), result);
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(uint64_t src, TVMFFIAny* result) {
+ CopyToAnyView(src, result);
+ }
+ };
} // namespace ffi
// Expose to the tvm namespace for usability
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_base_details.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_base_details.h.rst
index 72bf15ccfe2..820a5c480e6 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_base_details.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_base_details.h.rst
@@ -93,13 +93,13 @@ Program Listing for File base_details.h
#if defined(__clang__)
#define TVM_FFI_UNSAFE_ASSUME(cond) __builtin_assume(cond)
#elif defined(__GNUC__)
- // GCC 13+ supports __attribute__((assume(...))); fall back to the void-cast
- // no-op for older GCC where __builtin_assume is absent.
- #if __GNUC__ >= 13
- #define TVM_FFI_UNSAFE_ASSUME(cond) __attribute__((assume(cond)))
- #else
- #define TVM_FFI_UNSAFE_ASSUME(cond) static_cast<void>(0)
- #endif
+ // GCC does not reliably propagate __attribute__((assume(...))) through the
+ // returned-aggregate/helper flows used in TVM_FFI hot paths. Lower to an
+ // unreachable edge instead so GCC 11/14 recover the intended codegen.
+ #define TVM_FFI_UNSAFE_ASSUME(cond) \
+ do { \
+ if (!(cond)) __builtin_unreachable(); \
+ } while (0)
#elif defined(_MSC_VER)
#define TVM_FFI_UNSAFE_ASSUME(cond) __assume(cond)
#else
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_c_api.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_c_api.h.rst
index 2ab0e88cf5e..2224577392d 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_c_api.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_c_api.h.rst
@@ -293,6 +293,23 @@ Program Listing for File c_api.h
TVM_FFI_DLL int TVMFFIObjectCreateOpaque(void* handle, int32_t type_index,
void (*deleter)(void* handle), TVMFFIObjectHandle* out);
+ //-----------------------------------------------------------------------
+ // Section: ObjectAllocHeader and CustomAllocator
+ //-----------------------------------------------------------------------
+ typedef struct {
+ void (*delete_space)(void* ptr);
+ } TVMFFIObjectAllocHeader;
+
+ typedef struct {
+ void* (*allocate)(size_t size, size_t alignment, int32_t type_index, void* context);
+
+ void* context;
+ } TVMFFICustomAllocator;
+
+ TVM_FFI_DLL TVMFFICustomAllocator* TVMFFIGetCustomAllocator(void);
+
+ TVM_FFI_DLL int TVMFFISetCustomAllocator(TVMFFICustomAllocator* allocator);
+
TVM_FFI_DLL int TVMFFITypeKeyToIndex(const TVMFFIByteArray* type_key, int32_t* out_tindex);
//-----------------------------------------------------------------------
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_cast.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_cast.h.rst
index f66b1cef5e8..4f7cb661c72 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_cast.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_cast.h.rst
@@ -35,25 +35,31 @@ Program Listing for File cast.h
#include <tvm/ffi/object.h>
#include <tvm/ffi/optional.h>
+ #include <type_traits>
+
namespace tvm {
namespace ffi {
template <typename RefType, typename ObjectType>
inline RefType GetRef(const ObjectType* ptr) {
- using ContainerType = typename RefType::ContainerType;
- static_assert(std::is_base_of_v<ContainerType, ObjectType>,
- "Can only cast to the ref of same container type");
-
- if constexpr (is_optional_type_v<RefType> || RefType::_type_is_nullable) {
- if (ptr == nullptr) {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<RefType>(nullptr);
+ if constexpr (object_ref_contains_v<RefType, ObjectType>) {
+ if constexpr (is_optional_type_v<RefType> || RefType::_type_is_nullable) {
+ if (ptr == nullptr) {
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<RefType>(nullptr);
+ }
+ } else {
+ TVM_FFI_ICHECK_NOTNULL(ptr);
}
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<RefType>(
+ details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(
+ const_cast<Object*>(static_cast<const Object*>(ptr))));
} else {
- TVM_FFI_ICHECK_NOTNULL(ptr);
+ static_assert(object_ref_contains_v<RefType, ObjectType>,
+ "GetRef requires RefType to contain every ObjectType instance; specialize "
+ "object_ref_contains_v for statically safe typed refs or use "
+ "ObjectRef::as<RefType>() for runtime-dependent checks");
+ TVM_FFI_UNREACHABLE();
}
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<RefType>(
- details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(
- const_cast<Object*>(static_cast<const Object*>(ptr))));
}
template <typename BaseType, typename ObjectType>
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_array.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_array.h.rst
index f83e85bc754..d5ec75ebebb 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_array.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_array.h.rst
@@ -162,10 +162,10 @@ Program Listing for File array.h
Array(Array<T>&& other) // NOLINT(google-explicit-constructor)
: ObjectRef(std::move(other.data_)) {}
Array(const Array<T>& other) : ObjectRef(other.data_) {} // NOLINT(google-explicit-constructor)
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
Array(Array<U>&& other) // NOLINT(google-explicit-constructor)
: ObjectRef(std::move(other.data_)) {}
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
Array(const Array<U>& other) // NOLINT(google-explicit-constructor)
: ObjectRef(other.data_) {}
@@ -177,12 +177,12 @@ Program Listing for File array.h
data_ = other.data_;
return *this;
}
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
TVM_FFI_INLINE Array<T>& operator=(Array<U>&& other) {
data_ = std::move(other.data_);
return *this;
}
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
TVM_FFI_INLINE Array<T>& operator=(const Array<U>& other) {
data_ = other.data_;
return *this;
@@ -273,13 +273,15 @@ Program Listing for File array.h
// mutation in std::vector, implements copy-on-write
void push_back(const T& item) {
ArrayObj* p = CopyOnWrite(1);
- p->EmplaceInit(p->TVMFFISeqCell::size++, item);
+ p->EmplaceInit(p->TVMFFISeqCell::size, item);
+ ++p->TVMFFISeqCell::size;
}
template <typename... Args>
void emplace_back(Args&&... args) {
ArrayObj* p = CopyOnWrite(1);
- p->EmplaceInit(p->TVMFFISeqCell::size++, std::forward<Args>(args)...);
+ p->EmplaceInit(p->TVMFFISeqCell::size, std::forward<Args>(args)...);
+ ++p->TVMFFISeqCell::size;
}
void insert(iterator position, const T& val) {
@@ -436,6 +438,7 @@ Program Listing for File array.h
}
using ContainerType = ArrayObj;
+ static constexpr bool _type_container_is_exact = false;
template <typename... Args>
static Array<T> Agregate(Args... args) {
@@ -613,10 +616,9 @@ Program Listing for File array.h
}
};
- namespace details {
+
template <typename T, typename U>
- inline constexpr bool type_contains_v<Array<T>, Array<U>> = type_contains_v<T, U>;
- } // namespace details
+ inline constexpr bool type_subsumes_v<Array<T>, Array<U>> = type_subsumes_v<T, U>;
} // namespace ffi
} // namespace tvm
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_dict.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_dict.h.rst
index b83a68903cd..594255c227e 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_dict.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_dict.h.rst
@@ -73,14 +73,12 @@ Program Listing for File dict.h
: ObjectRef(other.data_) {}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Dict(Dict<KU, VU>&& other) // NOLINT(google-explicit-constructor)
: ObjectRef(std::move(other.data_)) {}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
// NOLINTNEXTLINE(google-explicit-constructor)
Dict(const Dict<KU, VU>& other) : ObjectRef(other.data_) {}
@@ -95,16 +93,14 @@ Program Listing for File dict.h
}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Dict<K, V>& operator=(Dict<KU, VU>&& other) {
data_ = std::move(other.data_);
return *this;
}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Dict<K, V>& operator=(const Dict<KU, VU>& other) {
data_ = other.data_;
return *this;
@@ -167,6 +163,7 @@ Program Listing for File dict.h
}
using ContainerType = DictObj;
+ static constexpr bool _type_container_is_exact = false;
class iterator {
@@ -250,11 +247,10 @@ Program Listing for File dict.h
}
};
- namespace details {
+
template <typename K, typename V, typename KU, typename VU>
- inline constexpr bool type_contains_v<Dict<K, V>, Dict<KU, VU>> =
- type_contains_v<K, KU> && type_contains_v<V, VU>;
- } // namespace details
+ inline constexpr bool type_subsumes_v<Dict<K, V>, Dict<KU, VU>> =
+ type_subsumes_v<K, KU> && type_subsumes_v<V, VU>;
} // namespace ffi
} // namespace tvm
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_list.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_list.h.rst
index 966d4ffd79e..f119a889e6a 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_list.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_list.h.rst
@@ -116,11 +116,11 @@ Program Listing for File list.h
: ObjectRef(std::move(other.data_)) {}
List(const List<T>& other) : ObjectRef(other.data_) {} // NOLINT(google-explicit-constructor)
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
List(List<U>&& other) // NOLINT(google-explicit-constructor)
: ObjectRef(std::move(other.data_)) {}
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
List(const List<U>& other) // NOLINT(google-explicit-constructor)
: ObjectRef(other.data_) {}
@@ -134,13 +134,13 @@ Program Listing for File list.h
return *this;
}
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
TVM_FFI_INLINE List<T>& operator=(List<U>&& other) {
data_ = std::move(other.data_);
return *this;
}
- template <typename U, typename = std::enable_if_t<details::type_contains_v<T, U>>>
+ template <typename U, typename = std::enable_if_t<type_subsumes_v<T, U>>>
TVM_FFI_INLINE List<T>& operator=(const List<U>& other) {
data_ = other.data_;
return *this;
@@ -222,13 +222,15 @@ Program Listing for File list.h
// mutation in std::vector
void push_back(const T& item) {
ListObj* p = EnsureCapacity(1);
- p->EmplaceInit(p->TVMFFISeqCell::size++, item);
+ p->EmplaceInit(p->TVMFFISeqCell::size, item);
+ ++p->TVMFFISeqCell::size;
}
template <typename... Args>
void emplace_back(Args&&... args) {
ListObj* p = EnsureCapacity(1);
- p->EmplaceInit(p->TVMFFISeqCell::size++, std::forward<Args>(args)...);
+ p->EmplaceInit(p->TVMFFISeqCell::size, std::forward<Args>(args)...);
+ ++p->TVMFFISeqCell::size;
}
void insert(iterator position, const T& val) {
@@ -314,6 +316,7 @@ Program Listing for File list.h
}
using ContainerType = ListObj;
+ static constexpr bool _type_container_is_exact = false;
private:
ListObj* EnsureCapacity(int64_t reserve_extra) {
@@ -359,10 +362,9 @@ Program Listing for File list.h
}
};
- namespace details {
+
template <typename T, typename U>
- inline constexpr bool type_contains_v<List<T>, List<U>> = type_contains_v<T, U>;
- } // namespace details
+ inline constexpr bool type_subsumes_v<List<T>, List<U>> = type_subsumes_v<T, U>;
} // namespace ffi
} // namespace tvm
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_map.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_map.h.rst
index 9353496e54d..887fd4faa55 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_map.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_map.h.rst
@@ -71,14 +71,12 @@ Program Listing for File map.h
: ObjectRef(other.data_) {}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Map(Map<KU, VU>&& other) // NOLINT(google-explicit-constructor)
: ObjectRef(std::move(other.data_)) {}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Map(const Map<KU, VU>& other) : ObjectRef(other.data_) {} // NOLINT(google-explicit-constructor)
Map<K, V>& operator=(Map<K, V>&& other) {
@@ -92,16 +90,14 @@ Program Listing for File map.h
}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Map<K, V>& operator=(Map<KU, VU>&& other) {
data_ = std::move(other.data_);
return *this;
}
template <typename KU, typename VU,
- typename = std::enable_if_t<details::type_contains_v<K, KU> &&
- details::type_contains_v<V, VU>>>
+ typename = std::enable_if_t<type_subsumes_v<K, KU> && type_subsumes_v<V, VU>>>
Map<K, V>& operator=(const Map<KU, VU>& other) {
data_ = other.data_;
return *this;
@@ -167,6 +163,7 @@ Program Listing for File map.h
return GetMapObj();
}
using ContainerType = MapObj;
+ static constexpr bool _type_container_is_exact = false;
class iterator {
@@ -254,11 +251,10 @@ Program Listing for File map.h
}
};
- namespace details {
+
template <typename K, typename V, typename KU, typename VU>
- inline constexpr bool type_contains_v<Map<K, V>, Map<KU, VU>> =
- type_contains_v<K, KU> && type_contains_v<V, VU>;
- } // namespace details
+ inline constexpr bool type_subsumes_v<Map<K, V>, Map<KU, VU>> =
+ type_subsumes_v<K, KU> && type_subsumes_v<V, VU>;
} // namespace ffi
} // namespace tvm
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tensor.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tensor.h.rst
index bee598ee38a..d29c1a492ff 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tensor.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tensor.h.rst
@@ -34,6 +34,7 @@ Program Listing for File tensor.h
#define TVM_FFI_CONTAINER_TENSOR_H_
#include <tvm/ffi/container/shape.h>
+ #include <tvm/ffi/device.h>
#include <tvm/ffi/dtype.h>
#include <tvm/ffi/error.h>
#include <tvm/ffi/type_traits.h>
@@ -87,12 +88,7 @@ Program Listing for File tensor.h
}
inline size_t GetDataSize(size_t numel, DLDataType dtype) {
- // compatible handling sub-byte uint1(bool), which usually stored as uint8_t
- // TODO(tqchen): revisit and switch to kDLBool
- if (dtype.code == kDLUInt && dtype.bits == 1 && dtype.lanes == 1) {
- return numel;
- }
- // for other sub-byte types, packing is preferred
+ // Sub-byte types are stored packed.
// Use uint64_t to avoid overflow on 32-bit platforms (WASM) for large allocations.
return static_cast<size_t>((static_cast<uint64_t>(numel) * dtype.bits * dtype.lanes + 7) / 8);
}
@@ -483,6 +479,50 @@ Program Listing for File tensor.h
return GetDataSize(tensor.numel(), tensor.dtype());
}
+ // DLTensor* support lives with Tensor/TensorView because the conversion path
+ // is tensor-specific and can reuse the FFI error layer.
+ template <>
+ struct TypeTraits<DLTensor*> : public TypeTraitsBase {
+ static constexpr bool storage_enabled = false;
+ static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIDLTensorPtr;
+
+ TVM_FFI_INLINE static void CopyToAnyView(DLTensor* src, TVMFFIAny* result) {
+ TVM_FFI_ICHECK_NOTNULL(src);
+ result->type_index = TypeIndex::kTVMFFIDLTensorPtr;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_ptr = src;
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ return src->type_index == TypeIndex::kTVMFFIDLTensorPtr;
+ }
+
+ TVM_FFI_INLINE static DLTensor* CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ TVM_FFI_UNSAFE_ASSUME(src->type_index == TypeIndex::kTVMFFIDLTensorPtr);
+ return static_cast<DLTensor*>(src->v_ptr);
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(DLTensor*, TVMFFIAny*) {
+ TVM_FFI_THROW(RuntimeError)
+ << "DLTensor* cannot be held in Any as it does not retain ownership, use Tensor instead";
+ }
+
+ TVM_FFI_INLINE static std::optional<DLTensor*> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFIDLTensorPtr) {
+ return static_cast<DLTensor*>(src->v_ptr);
+ } else if (src->type_index == TypeIndex::kTVMFFITensor) {
+ return TVMFFITensorGetDLTensorPtr(src->v_obj);
+ }
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return StaticTypeKey::kTVMFFIDLTensorPtr; }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":")" + std::string(StaticTypeKey::kTVMFFIDLTensorPtr) + R"("})";
+ }
+ };
+
// TensorView type, allow implicit casting from DLTensor*
// NOTE: we deliberately do not support MoveToAny and MoveFromAny since it does not retain ownership
template <>
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tuple.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tuple.h.rst
index 2eccfcbf984..eb5a1a7f541 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tuple.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_tuple.h.rst
@@ -53,11 +53,11 @@ Program Listing for File tuple.h
Tuple(const Tuple<Types...>& other) : ObjectRef(other) {}
Tuple(Tuple<Types...>&& other) noexcept : ObjectRef(std::move(other)) {}
template <typename... UTypes,
- typename = std::enable_if_t<(details::type_contains_v<Types, UTypes> && ...), int>>
+ typename = std::enable_if_t<(type_subsumes_v<Types, UTypes> && ...), int>>
Tuple(const Tuple<UTypes...>& other) : ObjectRef(other) {} // NOLINT(google-explicit-constructor)
template <typename... UTypes,
- typename = std::enable_if_t<(details::type_contains_v<Types, UTypes> && ...), int>>
+ typename = std::enable_if_t<(type_subsumes_v<Types, UTypes> && ...), int>>
Tuple(Tuple<UTypes...>&& other) // NOLINT(google-explicit-constructor)
: ObjectRef(std::move(other)) {}
@@ -78,14 +78,14 @@ Program Listing for File tuple.h
}
template <typename... UTypes,
- typename = std::enable_if_t<(details::type_contains_v<Types, UTypes> && ...)>>
+ typename = std::enable_if_t<(type_subsumes_v<Types, UTypes> && ...)>>
TVM_FFI_INLINE Tuple& operator=(const Tuple<UTypes...>& other) {
data_ = other.data_;
return *this;
}
template <typename... UTypes,
- typename = std::enable_if_t<(details::type_contains_v<Types, UTypes> && ...)>>
+ typename = std::enable_if_t<(type_subsumes_v<Types, UTypes> && ...)>>
TVM_FFI_INLINE Tuple& operator=(Tuple<UTypes...>&& other) {
data_ = std::move(other.data_);
return *this;
@@ -121,6 +121,7 @@ Program Listing for File tuple.h
}
using ContainerType = ArrayObj;
+ static constexpr bool _type_container_is_exact = false;
private:
static ObjectPtr<ArrayObj> MakeDefaultTupleNode() {
@@ -263,10 +264,11 @@ Program Listing for File tuple.h
}
};
- namespace details {
+
template <typename... T, typename... U>
- inline constexpr bool type_contains_v<Tuple<T...>, Tuple<U...>> = (type_contains_v<T, U> && ...);
- } // namespace details
+ inline constexpr bool
+ type_subsumes_v<Tuple<T...>, Tuple<U...>, std::enable_if_t<sizeof...(T) == sizeof...(U)>> =
+ (type_subsumes_v<T, U> && ...);
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_variant.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_variant.h.rst
index 2aa358b39ef..6c3527b8777 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_variant.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_container_variant.h.rst
@@ -42,91 +42,30 @@ Program Listing for File variant.h
namespace tvm {
namespace ffi {
- namespace details {
- template <bool all_storage_object = false>
- class VariantBase {
- public:
- TVM_FFI_INLINE bool same_as(const VariantBase<all_storage_object>& other) const {
- return data_.same_as(other.data_);
- }
-
- protected:
- template <typename T>
- explicit VariantBase(T other) : data_(std::move(other)) {}
-
- TVM_FFI_INLINE void SetData(Any other_data) { data_ = std::move(other_data); }
-
- TVM_FFI_INLINE Any MoveToAny() && { return std::move(data_); }
-
- TVM_FFI_INLINE AnyView ToAnyView() const { return data_.operator AnyView(); }
-
- Any data_;
- };
-
- // Specialization for all object ref case, backed by ObjectRef.
- template <>
- class VariantBase<true> : public ObjectRef {
- protected:
- template <typename T>
- explicit VariantBase(const T& other) : ObjectRef(other) {}
- template <typename T,
- typename = std::enable_if_t<!std::is_same_v<std::decay_t<T>, VariantBase<true>>>>
- explicit VariantBase(T&& other) : ObjectRef(std::forward<T>(other)) {}
- explicit VariantBase(UnsafeInit tag) : ObjectRef(tag) {}
- explicit VariantBase(Any other)
- : ObjectRef(details::AnyUnsafe::MoveFromAnyAfterCheck<ObjectRef>(std::move(other))) {}
-
- TVM_FFI_INLINE void SetData(ObjectPtr<Object> other) { data_ = std::move(other); }
-
- TVM_FFI_INLINE Any MoveToAny() && { return Any(ObjectRef(std::move(data_))); }
-
- TVM_FFI_INLINE AnyView ToAnyView() const {
- TVMFFIAny any_data;
- if (data_ == nullptr) {
- any_data.type_index = TypeIndex::kTVMFFINone;
- any_data.zero_padding = 0;
- any_data.v_int64 = 0;
- } else {
- TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(&any_data);
- any_data.type_index = data_->type_index();
- any_data.zero_padding = 0;
- any_data.v_obj = details::ObjectUnsafe::TVMFFIObjectPtrFromObjectPtr<Object>(data_);
- }
- return AnyView::CopyFromTVMFFIAny(any_data);
- }
- };
- } // namespace details
-
template <typename... V>
- class Variant : public details::VariantBase<details::all_object_ref_v<V...>> {
+ class Variant {
public:
- using TParent = details::VariantBase<details::all_object_ref_v<V...>>;
static_assert(details::all_storage_enabled_v<V...>,
"All types used in Variant<...> must be compatible with Any");
+ static constexpr bool _type_container_is_exact = false;
/*
* \brief Helper utility to check if the type can be contained in the variant
*/
template <typename T>
- static constexpr bool variant_contains_v = (details::type_contains_v<V, T> || ...);
+ static constexpr bool variant_contains_v = (type_subsumes_v<V, T> || ...);
/* \brief Helper utility for SFINAE if the type is part of the variant */
template <typename T>
using enable_if_variant_contains_t = std::enable_if_t<variant_contains_v<T>>;
- Variant(const Variant<V...>& other) : TParent(other.data_) {}
- Variant(Variant<V...>&& other) noexcept : TParent(std::move(other.data_)) {}
+ Variant(const Variant<V...>& other) = default;
+ Variant(Variant<V...>&& other) noexcept = default;
- TVM_FFI_INLINE Variant& operator=(const Variant<V...>& other) {
- this->SetData(other.data_);
- return *this;
- }
+ Variant& operator=(const Variant<V...>& other) = default;
- TVM_FFI_INLINE Variant& operator=(Variant<V...>&& other) noexcept {
- this->SetData(std::move(other.data_));
- return *this;
- }
+ Variant& operator=(Variant<V...>&& other) noexcept = default;
template <typename T, typename = enable_if_variant_contains_t<T>>
- Variant(T other) : TParent(std::move(other)) {} // NOLINT(*)
+ Variant(T other) : data_(std::move(other)) {} // NOLINT(*)
template <typename T, typename = enable_if_variant_contains_t<T>>
TVM_FFI_INLINE Variant& operator=(T other) {
@@ -135,42 +74,46 @@ Program Listing for File variant.h
template <typename T, typename = enable_if_variant_contains_t<T>>
TVM_FFI_INLINE std::optional<T> as() const {
- return this->TParent::ToAnyView().template as<T>();
+ return ToAnyView().template as<T>();
}
template <typename T, typename = std::enable_if_t<std::is_base_of_v<Object, T>>>
TVM_FFI_INLINE const T* as() const {
- return this->TParent::ToAnyView().template as<const T*>().value_or(nullptr);
+ return ToAnyView().template as<const T*>().value_or(nullptr);
}
template <typename T, typename = enable_if_variant_contains_t<T>>
TVM_FFI_INLINE T get() const& {
- return this->TParent::ToAnyView().template cast<T>();
+ return ToAnyView().template cast<T>();
}
template <typename T, typename = enable_if_variant_contains_t<T>>
TVM_FFI_INLINE T get() && {
- return std::move(*this).TParent::MoveToAny().template cast<T>();
+ return std::move(*this).MoveToAny().template cast<T>();
}
- TVM_FFI_INLINE std::string GetTypeKey() const { return this->TParent::ToAnyView().GetTypeKey(); }
+ TVM_FFI_INLINE std::string GetTypeKey() const { return ToAnyView().GetTypeKey(); }
+
+ TVM_FFI_INLINE bool same_as(const Variant<V...>& other) const {
+ return data_.same_as(other.data_);
+ }
private:
friend struct TypeTraits<Variant<V...>>;
friend struct ObjectPtrHash;
friend struct ObjectPtrEqual;
// constructor from any
- explicit Variant(Any data) : TParent(std::move(data)) {}
+ explicit Variant(Any data) : data_(std::move(data)) {}
TVM_FFI_INLINE Object* GetObjectPtrForHashEqual() const {
constexpr bool all_object_v = (std::is_base_of_v<ObjectRef, V> && ...);
static_assert(all_object_v,
"All types used in Variant<...> must be derived from ObjectRef "
"to enable ObjectPtrHash/ObjectPtrEqual");
- return this->data_.get();
+ return details::AnyUnsafe::ObjectPtrFromAnyAfterCheck(this->data_);
}
- // rexpose to friend class
- using TParent::MoveToAny;
- using TParent::ToAnyView;
+ TVM_FFI_INLINE AnyView ToAnyView() const { return data_.operator AnyView(); }
+ TVM_FFI_INLINE Any MoveToAny() && { return std::move(data_); }
+ Any data_;
};
template <typename... V>
@@ -244,10 +187,9 @@ Program Listing for File variant.h
return a.GetObjectPtrForHashEqual() == b.GetObjectPtrForHashEqual();
}
- namespace details {
+
template <typename... V, typename T>
- inline constexpr bool type_contains_v<Variant<V...>, T> = (type_contains_v<V, T> || ...);
- } // namespace details
+ inline constexpr bool type_subsumes_v<Variant<V...>, T> = (type_subsumes_v<V, T> || ...);
} // namespace ffi
} // namespace tvm
#endif // TVM_FFI_CONTAINER_VARIANT_H_
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_device.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_device.h.rst
new file mode 100644
index 00000000000..66f4317931b
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_device.h.rst
@@ -0,0 +1,151 @@
+
+.. _program_listing_file_tvm_ffi_device.h:
+
+Program Listing for File device.h
+=================================
+
+|exhale_lsh| :ref:`Return to documentation for file <file_tvm_ffi_device.h>` (``tvm/ffi/device.h``)
+
+.. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS
+
+.. code-block:: cpp
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ #ifndef TVM_FFI_DEVICE_H_
+ #define TVM_FFI_DEVICE_H_
+
+ #include <dlpack/dlpack.h>
+ #include <tvm/ffi/string.h>
+ #include <tvm/ffi/type_traits.h>
+
+ #include <cstdint>
+ #include <limits>
+ #include <optional>
+ #include <string>
+ #include <string_view>
+
+ namespace tvm {
+ namespace ffi {
+ namespace details {
+
+ TVM_FFI_INLINE static std::optional<DLDeviceType> TryParseDLDeviceType(std::string_view name) {
+ if (name == "cpu") return kDLCPU;
+ if (name == "cuda") return kDLCUDA;
+ if (name == "opencl") return kDLOpenCL;
+ if (name == "vulkan") return kDLVulkan;
+ if (name == "metal" || name == "mps") return kDLMetal;
+ if (name == "vpi") return kDLVPI;
+ if (name == "rocm") return kDLROCM;
+ if (name == "ext_dev") return kDLExtDev;
+ if (name == "hexagon") return kDLHexagon;
+ if (name == "wgpu" || name == "webgpu") return kDLWebGPU;
+ if (name == "maia") return kDLMAIA;
+ if (name == "trn") return kDLTrn;
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::optional<int32_t> TryParseDLDeviceIndex(std::string_view index) {
+ if (index.empty()) return std::nullopt;
+ int64_t value = 0;
+ for (char ch : index) {
+ if (ch < '0' || ch > '9') return std::nullopt;
+ value = value * 10 + (ch - '0');
+ if (value > std::numeric_limits<int32_t>::max()) return std::nullopt;
+ }
+ return static_cast<int32_t>(value);
+ }
+
+ TVM_FFI_INLINE static std::optional<DLDevice> TryStringViewToDLDevice(std::string_view str) {
+ size_t space_pos = str.find(' ');
+ if (space_pos != std::string_view::npos) {
+ str = str.substr(0, space_pos);
+ }
+ size_t colon_pos = str.find(':');
+ std::string_view name = colon_pos == std::string_view::npos ? str : str.substr(0, colon_pos);
+ if (name.empty()) return std::nullopt;
+ if (str.find(':', colon_pos == std::string_view::npos ? str.size() : colon_pos + 1) !=
+ std::string_view::npos) {
+ return std::nullopt;
+ }
+ std::optional<DLDeviceType> device_type = TryParseDLDeviceType(name);
+ if (!device_type.has_value()) return std::nullopt;
+ int32_t device_id = 0;
+ if (colon_pos != std::string_view::npos) {
+ std::optional<int32_t> parsed_device_id = TryParseDLDeviceIndex(str.substr(colon_pos + 1));
+ if (!parsed_device_id.has_value()) return std::nullopt;
+ device_id = parsed_device_id.value();
+ }
+ return DLDevice{device_type.value(), device_id};
+ }
+
+ } // namespace details
+
+ // Device
+ template <>
+ struct TypeTraits<DLDevice> : public TypeTraitsBase {
+ static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIDevice;
+
+ TVM_FFI_INLINE static void CopyToAnyView(const DLDevice& src, TVMFFIAny* result) {
+ result->type_index = TypeIndex::kTVMFFIDevice;
+ result->zero_padding = 0;
+ result->v_device = src;
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(DLDevice src, TVMFFIAny* result) {
+ result->type_index = TypeIndex::kTVMFFIDevice;
+ result->zero_padding = 0;
+ result->v_device = src;
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ return src->type_index == TypeIndex::kTVMFFIDevice;
+ }
+
+ TVM_FFI_INLINE static DLDevice CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ TVM_FFI_UNSAFE_ASSUME(src->type_index == TypeIndex::kTVMFFIDevice);
+ return src->v_device;
+ }
+
+ TVM_FFI_INLINE static DLDevice MoveFromAnyAfterCheck(TVMFFIAny* src) {
+ // POD type, we can just copy the value
+ return CopyFromAnyViewAfterCheck(src);
+ }
+
+ TVM_FFI_INLINE static std::optional<DLDevice> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFIDevice) {
+ return src->v_device;
+ }
+ if (auto opt_str = TypeTraits<String>::TryCastFromAnyView(src)) {
+ return details::TryStringViewToDLDevice(std::string_view(opt_str->data(), opt_str->size()));
+ }
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return StaticTypeKey::kTVMFFIDevice; }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":")" + std::string(StaticTypeKey::kTVMFFIDevice) + R"("})";
+ }
+ };
+
+ } // namespace ffi
+ } // namespace tvm
+
+ #endif // TVM_FFI_DEVICE_H_
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_dtype.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_dtype.h.rst
index d73702e8544..9eab3221d9e 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_dtype.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_dtype.h.rst
@@ -131,6 +131,132 @@ Program Listing for File dtype.h
return TypeTraits<String>::MoveFromAnyAfterCheck(&out);
}
+ inline bool DTypeIsFloat(DLDataType dtype) {
+ switch (static_cast<int>(dtype.code)) {
+ case kDLFloat:
+ case kDLBfloat:
+ case kDLFloat8_e3m4:
+ case kDLFloat8_e4m3:
+ case kDLFloat8_e4m3b11fnuz:
+ case kDLFloat8_e4m3fn:
+ case kDLFloat8_e4m3fnuz:
+ case kDLFloat8_e5m2:
+ case kDLFloat8_e5m2fnuz:
+ case kDLFloat8_e8m0fnu:
+ case kDLFloat6_e2m3fn:
+ case kDLFloat6_e3m2fn:
+ case kDLFloat4_e2m1fn:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ TVM_FFI_INLINE bool DTypeIsInt(DLDataType dtype) {
+ return dtype.code == kDLInt || dtype.code == kDLUInt;
+ }
+
+ TVM_FFI_INLINE bool DTypeIsBool(DLDataType dtype) { return dtype.code == kDLBool; }
+
+ inline std::string DTypeAbbrev(DLDataType dtype) {
+ if (dtype.bits == 8 && dtype.lanes == 1 && dtype.code == kDLBool) {
+ return "bool";
+ }
+ if (dtype.code == kDLOpaqueHandle && dtype.lanes == 0 && dtype.bits == 0) {
+ return "void";
+ }
+
+ std::string result;
+ switch (static_cast<int>(dtype.code)) {
+ case kDLInt: {
+ result = "i";
+ break;
+ }
+ case kDLUInt: {
+ result = "u";
+ break;
+ }
+ case kDLFloat: {
+ result = "f";
+ break;
+ }
+ case kDLOpaqueHandle: {
+ return "handle";
+ }
+ case kDLBfloat: {
+ result = "bf";
+ break;
+ }
+ case kDLBool: {
+ result = "bool";
+ break;
+ }
+ case kDLFloat8_e3m4: {
+ result = "f8_e3m4";
+ break;
+ }
+ case kDLFloat8_e4m3: {
+ result = "f8_e4m3";
+ break;
+ }
+ case kDLFloat8_e4m3b11fnuz: {
+ result = "f8_e4m3b11fnuz";
+ break;
+ }
+ case kDLFloat8_e4m3fn: {
+ result = "f8_e4m3fn";
+ break;
+ }
+ case kDLFloat8_e4m3fnuz: {
+ result = "f8_e4m3fnuz";
+ break;
+ }
+ case kDLFloat8_e5m2: {
+ result = "f8_e5m2";
+ break;
+ }
+ case kDLFloat8_e5m2fnuz: {
+ result = "f8_e5m2fnuz";
+ break;
+ }
+ case kDLFloat8_e8m0fnu: {
+ result = "f8_e8m0fnu";
+ break;
+ }
+ case kDLFloat6_e2m3fn: {
+ result = "f6_e2m3fn";
+ break;
+ }
+ case kDLFloat6_e3m2fn: {
+ result = "f6_e3m2fn";
+ break;
+ }
+ case kDLFloat4_e2m1fn: {
+ result = "f4_e2m1fn";
+ break;
+ }
+ default: {
+ if (static_cast<int>(dtype.code) >= static_cast<int>(DLExtDataTypeCode::kDLExtCustomBegin)) {
+ String full_name = DLDataTypeToString(dtype);
+ return std::string(full_name.data(), full_name.size());
+ }
+ TVM_FFI_THROW(ValueError) << "DLDataType contains unknown type_code="
+ << static_cast<int>(dtype.code);
+ }
+ }
+
+ int16_t lanes = static_cast<int16_t>(dtype.lanes);
+ if (dtype.code < kDLFloat8_e3m4 && (dtype.code != kDLBool || dtype.bits != 8)) {
+ result += std::to_string(static_cast<int>(dtype.bits));
+ }
+ if (lanes > 1) {
+ result += "x" + std::to_string(lanes);
+ } else if (lanes < -1) {
+ result += "xvscalex" + std::to_string(-lanes);
+ }
+ return result;
+ }
+
// DLDataType
template <>
struct TypeTraits<DLDataType> : public TypeTraitsBase {
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_enum.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_enum.h.rst
index 50fe2f9479d..a65aed743e0 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_enum.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_enum.h.rst
@@ -35,6 +35,7 @@ Program Listing for File enum.h
#include <tvm/ffi/any.h>
#include <tvm/ffi/c_api.h>
#include <tvm/ffi/container/dict.h>
+ #include <tvm/ffi/container/list.h>
#include <tvm/ffi/error.h>
#include <tvm/ffi/object.h>
#include <tvm/ffi/reflection/accessor.h>
@@ -48,28 +49,47 @@ Program Listing for File enum.h
namespace ffi {
class Enum;
+ class IntEnum;
+ class StrEnum;
+
+ class EnumStateObj : public Object {
+ public:
+ List<ObjectRef> entries;
+ Dict<Any, ObjectRef> indexes;
+ Dict<String, Dict<ObjectRef, Any>> attrs;
+
+ TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ffi.EnumState", EnumStateObj, Object);
+ };
+
+ class EnumState : public ObjectRef {
+ public:
+ TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(EnumState, ObjectRef, EnumStateObj);
+ };
class EnumObj : public Object {
public:
- int64_t _value;
- String _name;
+ int64_t _int_index = 0;
+ String _str_index;
EnumObj() = default;
- EnumObj(int64_t value, String name) : _value(value), _name(std::move(name)) {}
+ EnumObj(int64_t int_index, String str_index)
+ : _int_index(int_index), _str_index(std::move(str_index)) {}
+ // NOLINTBEGIN(bugprone-reserved-identifier)
+ template <typename EnumClsObj>
+ static Enum _GetByIntIndex(int64_t index);
template <typename EnumClsObj>
- static Enum Get(const String& name);
+ static Enum _GetByStrIndex(const String& index);
+ static Enum _GetByIntIndex(int32_t type_index, int64_t index);
+ static Enum _GetByStrIndex(int32_t type_index, const String& index);
+ // NOLINTEND(bugprone-reserved-identifier)
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindUniqueInstance;
TVM_FFI_DECLARE_OBJECT_INFO("ffi.Enum", EnumObj, Object);
private:
- static const TVMFFITypeAttrColumn* GetEnumEntriesColumn() {
- constexpr TVMFFIByteArray kAttrName =
- reflection::AsByteArray(reflection::type_attr::kEnumEntries);
- static const TVMFFITypeAttrColumn* column = TVMFFIGetTypeAttrColumn(&kAttrName);
- return column;
- }
+ template <typename Index>
+ static Enum GetByIndex(int32_t type_index, const Index& index);
};
class Enum : public ObjectRef {
@@ -77,30 +97,60 @@ Program Listing for File enum.h
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(Enum, ObjectRef, EnumObj);
};
- template <typename EnumClsObj>
- inline Enum EnumObj::Get(const String& name) {
- static_assert(std::is_base_of_v<EnumObj, EnumClsObj>,
- "EnumObj::Get<T> requires T to be a subclass of EnumObj");
- const TVMFFITypeAttrColumn* column = GetEnumEntriesColumn();
- int32_t type_index = EnumClsObj::RuntimeTypeIndex();
- if (column != nullptr) {
- int32_t offset = type_index - column->begin_index;
- if (offset >= 0 && offset < column->size) {
- const TVMFFIAny* stored = &column->data[offset];
- if (stored->type_index != kTVMFFINone) {
- Dict<String, Enum> entries = AnyView::CopyFromTVMFFIAny(*stored).cast<Dict<String, Enum>>();
- auto it = entries.find(name);
- if (it != entries.end()) {
- return (*it).second;
- }
- }
- }
+ class IntEnumObj : public EnumObj {
+ public:
+ TVM_FFI_DECLARE_OBJECT_INFO("ffi.IntEnum", IntEnumObj, EnumObj);
+ };
+
+ class IntEnum : public Enum {
+ public:
+ TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(IntEnum, Enum, IntEnumObj);
+ };
+
+ class StrEnumObj : public EnumObj {
+ public:
+ TVM_FFI_DECLARE_OBJECT_INFO("ffi.StrEnum", StrEnumObj, EnumObj);
+ };
+
+ class StrEnum : public Enum {
+ public:
+ TVM_FFI_DEFINE_OBJECT_REF_METHODS_NULLABLE(StrEnum, Enum, StrEnumObj);
+ };
+
+ template <typename Index>
+ inline Enum EnumObj::GetByIndex(int32_t type_index, const Index& index) {
+ static reflection::TypeAttrColumn state_column(reflection::type_attr::kEnumState);
+ if (AnyView value = state_column[type_index]; value != nullptr) {
+ EnumState state = value.cast<EnumState>();
+ if (auto entry = state->indexes.Get(Any(index))) return entry->as_or_throw<Enum>();
}
- TVM_FFI_THROW(RuntimeError) << "Enum `" << EnumClsObj::_type_key << "` has no instance named `"
- << name << "`";
+ TVM_FFI_THROW(ValueError) << "Enum `" << TypeIndexToTypeKey(type_index)
+ << "` has no instance with index " << index;
TVM_FFI_UNREACHABLE();
}
+ // NOLINTBEGIN(bugprone-reserved-identifier)
+ template <typename EnumClsObj>
+ inline Enum EnumObj::_GetByIntIndex(int64_t index) {
+ static_assert(std::is_base_of_v<EnumObj, EnumClsObj>);
+ return _GetByIntIndex(EnumClsObj::_GetOrAllocRuntimeTypeIndex(), index);
+ }
+
+ template <typename EnumClsObj>
+ inline Enum EnumObj::_GetByStrIndex(const String& index) {
+ static_assert(std::is_base_of_v<EnumObj, EnumClsObj>);
+ return _GetByStrIndex(EnumClsObj::_GetOrAllocRuntimeTypeIndex(), index);
+ }
+
+ inline Enum EnumObj::_GetByIntIndex(int32_t type_index, int64_t index) {
+ return GetByIndex(type_index, index);
+ }
+
+ inline Enum EnumObj::_GetByStrIndex(int32_t type_index, const String& index) {
+ return GetByIndex(type_index, index);
+ }
+ // NOLINTEND(bugprone-reserved-identifier)
+
} // namespace ffi
} // namespace tvm
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_error.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_error.h.rst
index 34cb178620c..c8b7ab7a3f8 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_error.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_error.h.rst
@@ -118,7 +118,7 @@ Program Listing for File error.h
};
} // namespace details
- class Error : public ObjectRef, public std::exception {
+ class TVM_FFI_DLL Error : public ObjectRef, public std::exception {
public:
Error(std::string kind, std::string message, std::string backtrace) {
data_ = make_object<details::ErrorObjFromStd>(std::move(kind), std::move(message),
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_expected.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_expected.h.rst
index 8de6abc3293..892de3d5b90 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_expected.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_expected.h.rst
@@ -72,6 +72,9 @@ Program Listing for File expected.h
template <typename T>
class Expected {
public:
+ static_assert(
+ !std::is_void_v<T>,
+ "Expected with a cv-qualified void success type is not allowed. Use Expected<void>.");
static_assert(!std::is_same_v<T, Error>, "Expected<Error> is not allowed. Use Error directly.");
// NOLINTNEXTLINE(google-explicit-constructor,runtime/explicit)
@@ -152,6 +155,62 @@ Program Listing for File expected.h
Any data_; // Invariant: holds a T (type_index != kTVMFFIError) or an Error.
};
+ template <>
+ class Expected<void> {
+ public:
+ Expected() = default;
+
+ // NOLINTNEXTLINE(google-explicit-constructor,runtime/explicit)
+ Expected(Error error) : data_(Any(std::move(error))) {}
+
+ template <typename E, typename = std::enable_if_t<std::is_base_of_v<Error, std::remove_cv_t<E>>>>
+ // NOLINTNEXTLINE(google-explicit-constructor,runtime/explicit)
+ Expected(Unexpected<E> unexpected) : data_(Any(std::move(unexpected).error())) {}
+
+ TVM_FFI_INLINE int32_t type_index() const noexcept { return data_.type_index(); }
+
+ TVM_FFI_INLINE bool is_ok() const noexcept {
+ return data_.type_index() != TypeIndex::kTVMFFIError;
+ }
+
+ TVM_FFI_INLINE bool is_err() const noexcept {
+ return data_.type_index() == TypeIndex::kTVMFFIError;
+ }
+
+ TVM_FFI_INLINE bool has_value() const noexcept { return is_ok(); }
+
+ TVM_FFI_INLINE void value() const& {
+ if (TVM_FFI_PREDICT_FALSE(is_err())) {
+ throw details::AnyUnsafe::CopyFromAnyViewAfterCheck<Error>(data_);
+ }
+ }
+
+ TVM_FFI_INLINE void value() && {
+ if (TVM_FFI_PREDICT_FALSE(is_err())) {
+ throw details::AnyUnsafe::MoveFromAnyAfterCheck<Error>(std::move(data_));
+ }
+ }
+
+ TVM_FFI_INLINE Error error() const& {
+ if (is_ok()) {
+ TVM_FFI_THROW(RuntimeError) << "Bad expected access: contains value, not error";
+ }
+ return details::AnyUnsafe::CopyFromAnyViewAfterCheck<Error>(data_);
+ }
+
+ TVM_FFI_INLINE Error error() && {
+ if (is_ok()) {
+ TVM_FFI_THROW(RuntimeError) << "Bad expected access: contains value, not error";
+ }
+ return details::AnyUnsafe::MoveFromAnyAfterCheck<Error>(std::move(data_));
+ }
+
+ private:
+ friend struct details::ExpectedUnsafe;
+
+ Any data_; // Invariant: holds FFI None on success or an Error.
+ };
+
namespace details {
struct ExpectedUnsafe {
@@ -174,11 +233,16 @@ Program Listing for File expected.h
template <typename T, typename U>
TVM_FFI_INLINE static T ValueAs(const Expected<U>& result) {
- const Any& data = result.data_;
- if (TVM_FFI_PREDICT_TRUE(data.type_index() != TypeIndex::kTVMFFIError)) {
- return AnyUnsafe::CopyFromAnyViewAfterCheck<T>(data);
+ if constexpr (std::is_void_v<T>) {
+ static_assert(std::is_void_v<U>, "ExpectedUnsafe::ValueAs<void> requires an Expected<void>");
+ result.value();
+ } else {
+ const Any& data = result.data_;
+ if (TVM_FFI_PREDICT_TRUE(data.type_index() != TypeIndex::kTVMFFIError)) {
+ return AnyUnsafe::CopyFromAnyViewAfterCheck<T>(data);
+ }
+ throw AnyUnsafe::CopyFromAnyViewAfterCheck<Error>(data);
}
- throw AnyUnsafe::CopyFromAnyViewAfterCheck<Error>(data);
}
};
@@ -244,6 +308,61 @@ Program Listing for File expected.h
}
};
+ template <>
+ struct TypeTraits<Expected<void>> : public TypeTraitsBase {
+ TVM_FFI_INLINE static void CopyToAnyView(const Expected<void>& src, TVMFFIAny* result) {
+ if (src.is_err()) {
+ TypeTraits<Error>::CopyToAnyView(src.error(), result);
+ } else {
+ TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
+ }
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(Expected<void> src, TVMFFIAny* result) {
+ if (src.is_err()) {
+ TypeTraits<Error>::MoveToAny(std::move(src).error(), result);
+ } else {
+ TypeTraits<std::nullptr_t>::MoveToAny(nullptr, result);
+ }
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ return TypeTraits<std::nullptr_t>::CheckAnyStrict(src) ||
+ TypeTraits<Error>::CheckAnyStrict(src);
+ }
+
+ TVM_FFI_INLINE static Expected<void> CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ if (TypeTraits<std::nullptr_t>::CheckAnyStrict(src)) {
+ return Expected<void>();
+ }
+ return TypeTraits<Error>::CopyFromAnyViewAfterCheck(src);
+ }
+
+ TVM_FFI_INLINE static Expected<void> MoveFromAnyAfterCheck(TVMFFIAny* src) {
+ if (TypeTraits<std::nullptr_t>::CheckAnyStrict(src)) {
+ return Expected<void>();
+ }
+ return TypeTraits<Error>::MoveFromAnyAfterCheck(src);
+ }
+
+ TVM_FFI_INLINE static std::optional<Expected<void>> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (TypeTraits<std::nullptr_t>::CheckAnyStrict(src)) {
+ return Expected<void>();
+ }
+ if (auto opt_err = TypeTraits<Error>::TryCastFromAnyView(src)) {
+ return Expected<void>(*std::move(opt_err));
+ }
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return "Expected<void>"; }
+
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":"Expected","args":[)" + TypeTraits<std::nullptr_t>::TypeSchema() +
+ R"(,{"type":"ffi.Error"}]})";
+ }
+ };
+
} // namespace ffi
} // namespace tvm
#endif // TVM_FFI_EXPECTED_H_
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_json.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_json.h.rst
index b5831cf5b64..8b10e3e8f66 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_json.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_json.h.rst
@@ -49,7 +49,7 @@ Program Listing for File json.h
TVM_FFI_EXTRA_CXX_API json::Value Parse(const String& json_str, String* error_msg = nullptr);
TVM_FFI_EXTRA_CXX_API String Stringify(const json::Value& value,
- Optional<int> indent = std::nullopt);
+ const Optional<int>& indent = std::nullopt);
} // namespace json
} // namespace ffi
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_module.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_module.h.rst
index 84f5af6c197..9f4a8ef4087 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_module.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_module.h.rst
@@ -49,7 +49,7 @@ Program Listing for File module.h
virtual const char* kind() const = 0;
virtual int GetPropertyMask() const { return 0b000; }
virtual Optional<Function> GetFunction(const String& name) = 0;
- virtual bool ImplementsFunction(const String& name) { return GetFunction(name).defined(); }
+ virtual bool ImplementsFunction(const String& name) { return GetFunction(name).has_value(); }
virtual Optional<String> GetFunctionDoc(const String& name) { return std::nullopt; }
// Rationale: We separate the docstring from the metadata since docstrings
// can be unstructured and sometimes large, while metadata can be focused
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_equal.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_equal.h.rst
index 70e1c9fa283..a6b605c162c 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_equal.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_equal.h.rst
@@ -53,7 +53,7 @@ Program Listing for File structural_equal.h
* \return True if the two Any values are structurally equal, false otherwise.
*/
TVM_FFI_INLINE bool operator()(const Any& lhs, const Any& rhs) const {
- return Equal(lhs, rhs, false, true);
+ return Equal(lhs, rhs, false, false);
}
};
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_visit.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_visit.h.rst
index 1755c7aa420..72305a8b725 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_visit.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_extra_structural_visit.h.rst
@@ -95,8 +95,6 @@ Program Listing for File structural_visit.h
class StructuralVisitorObj : public Object {
public:
- StructuralVisitorObj() : StructuralVisitorObj(VTable()) {}
-
TVM_FFI_INLINE Optional<VisitInterrupt> Visit(AnyView value) {
return VisitExpected(value).value();
}
@@ -106,8 +104,26 @@ Program Listing for File structural_visit.h
(*vtable_->visit)(this, value));
}
- TVM_FFI_INLINE Optional<VisitInterrupt> DefaultVisit(AnyView value) {
- return DefaultVisitExpected(value).value();
+ TVM_FFI_INLINE TVMFFIDefRegionKind def_region_kind() const { return def_region_mode_; }
+
+ template <typename Callback>
+ TVM_FFI_INLINE auto WithDefRegionKind(TVMFFIDefRegionKind kind, Callback&& callback) {
+ class Scope {
+ public:
+ Scope(StructuralVisitorObj* visitor, TVMFFIDefRegionKind kind)
+ : visitor_(visitor), old_kind_(visitor->def_region_mode_) {
+ visitor_->def_region_mode_ = kind;
+ }
+ ~Scope() { visitor_->def_region_mode_ = old_kind_; }
+ Scope(const Scope&) = delete;
+ Scope& operator=(const Scope&) = delete;
+
+ private:
+ StructuralVisitorObj* visitor_;
+ TVMFFIDefRegionKind old_kind_;
+ };
+ Scope scope(this, kind);
+ return std::forward<Callback>(callback)();
}
TVM_FFI_INLINE Expected<Optional<VisitInterrupt>> DefaultVisitExpected(AnyView value) noexcept {
@@ -141,28 +157,6 @@ Program Listing for File structural_visit.h
return details::VisitReflectedFieldsExpected(this, value.cast<const Object*>());
}
- TVM_FFI_INLINE TVMFFIDefRegionKind def_region_kind() const { return def_region_mode_; }
-
- template <typename Callback>
- TVM_FFI_INLINE auto WithDefRegionKind(TVMFFIDefRegionKind kind, Callback&& callback) {
- class Scope {
- public:
- Scope(StructuralVisitorObj* visitor, TVMFFIDefRegionKind kind)
- : visitor_(visitor), old_kind_(visitor->def_region_mode_) {
- visitor_->def_region_mode_ = kind;
- }
- ~Scope() { visitor_->def_region_mode_ = old_kind_; }
- Scope(const Scope&) = delete;
- Scope& operator=(const Scope&) = delete;
-
- private:
- StructuralVisitorObj* visitor_;
- TVMFFIDefRegionKind old_kind_;
- };
- Scope scope(this, kind);
- return std::forward<Callback>(callback)();
- }
-
static constexpr const bool _type_mutable = true;
TVM_FFI_DECLARE_OBJECT_INFO("ffi.StructuralVisitor", StructuralVisitorObj, Object);
@@ -172,28 +166,10 @@ Program Listing for File structural_visit.h
const StructuralVisitorVTable* vtable_ = nullptr;
TVMFFIDefRegionKind def_region_mode_ = kTVMFFIDefRegionKindNone;
-
- private:
- static const StructuralVisitorVTable* VTable() {
- static const StructuralVisitorVTable vtable{&StructuralVisitorObj::DispatchVisit};
- return &vtable;
- }
-
- static TVMFFIAny DispatchVisit(StructuralVisitorObj* visitor, AnyView value) noexcept {
- auto interrupt = visitor->DefaultVisitExpected(value);
- if (TVM_FFI_PREDICT_FALSE(interrupt.type_index() == TypeIndex::kTVMFFIError)) {
- if (value.type_index() >= TypeIndex::kTVMFFIStaticObjectBegin) {
- Error err = interrupt.error();
- details::UpdateVisitErrorContext(err, value.cast<ObjectRef>());
- }
- }
- return details::ExpectedUnsafe::MoveToTVMFFIAny(std::move(interrupt));
- }
};
class StructuralVisitor : public ObjectRef {
public:
- StructuralVisitor() : ObjectRef(make_object<StructuralVisitorObj>()) {}
explicit StructuralVisitor(ObjectPtr<StructuralVisitorObj> n) : ObjectRef(std::move(n)) {}
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(StructuralVisitor, ObjectRef, StructuralVisitorObj);
@@ -211,6 +187,13 @@ Program Listing for File structural_visit.h
StructuralVisitorObj* visitor, const Object* obj) noexcept {
int32_t type_index = obj->type_index();
const TVMFFITypeInfo* type_info = TVMFFIGetTypeInfo(type_index);
+ // A non-recursive definition applies to a FreeVar itself, but not to its children. All other
+ // inherited modes propagate until an explicit field annotation overrides them.
+ TVMFFIDefRegionKind inherited_kind = visitor->def_region_kind();
+ if (inherited_kind == kTVMFFIDefRegionKindNonRecursive && type_info->metadata != nullptr &&
+ type_info->metadata->structural_eq_hash_kind == kTVMFFISEqHashKindFreeVar) {
+ inherited_kind = kTVMFFIDefRegionKindNone;
+ }
Expected<Optional<VisitInterrupt>> result = Optional<VisitInterrupt>(std::nullopt);
reflection::ForEachFieldInfoWithEarlyStop(
@@ -228,19 +211,15 @@ Program Listing for File structural_visit.h
return true;
}
- TVMFFIDefRegionKind kind = kTVMFFIDefRegionKindNone;
+ TVMFFIDefRegionKind kind = inherited_kind;
if (field_info->flags & kTVMFFIFieldFlagBitMaskSEqHashDefNonRecursive) {
kind = kTVMFFIDefRegionKindNonRecursive;
} else if (field_info->flags & kTVMFFIFieldFlagBitMaskSEqHashDefRecursive) {
kind = kTVMFFIDefRegionKindRecursive;
}
- if (kind != kTVMFFIDefRegionKindNone) {
- result = visitor->WithDefRegionKind(
- kind, [&]() { return visitor->VisitExpected(field_value); });
- } else {
- result = visitor->VisitExpected(field_value);
- }
+ result =
+ visitor->WithDefRegionKind(kind, [&]() { return visitor->VisitExpected(field_value); });
return StructuralVisitNeedEarlyReturn(result);
});
return result;
@@ -358,7 +337,9 @@ Program Listing for File structural_visit.h
private:
static const StructuralVisitorVTable* VTable() {
- static const StructuralVisitorVTable vtable{&StructuralWalkCallbackVisitorObj::DispatchVisit};
+ static const StructuralVisitorVTable vtable{
+ &StructuralWalkCallbackVisitorObj::DispatchVisit,
+ };
return &vtable;
}
@@ -374,7 +355,11 @@ Program Listing for File structural_visit.h
if constexpr (order == WalkOrder::kPreOrder) {
auto result = dispatch_(value, this->def_region_kind());
TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN_WITH_ERROR_CONTEXT(result, value);
- int32_t type_index = result.type_index();
+ // Hoist the call out of TVM_FFI_UNSAFE_ASSUME: clang's -Wassume rejects
+ // arguments that contain a call expression (its potential side effects
+ // would be discarded), while [[maybe_unused]] keeps -Wunused-variable
+ // quiet on configs where the assume macro compiles away.
+ [[maybe_unused]] int32_t type_index = result.type_index();
TVM_FFI_UNSAFE_ASSUME(type_index == TypeIndex::kTVMFFIInt);
if (TVM_FFI_PREDICT_FALSE(details::ExpectedUnsafe::ValueAs<int32_t>(result) ==
WalkResult::kSkipTag)) {
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_function.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_function.h.rst
index 117ee7a2cac..a2e159fd765 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_function.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_function.h.rst
@@ -405,7 +405,18 @@ Program Listing for File function.h
if (ret_code == 0) {
if constexpr (std::is_same_v<T, Any>) {
- return std::move(result);
+ return result;
+ } else if constexpr (std::is_same_v<T, void>) {
+ if (result.type_index() == TypeIndex::kTVMFFINone) {
+ return Expected<void>();
+ }
+ if (auto err = result.template try_cast<Error>()) {
+ return Unexpected(std::move(*err));
+ }
+ return Unexpected(Error(
+ "TypeError",
+ "CallExpected: result type mismatch, expected void, but got " + result.GetTypeKey(),
+ ""));
} else {
// Try T first (fast path), then Error
if (auto val = result.template try_cast<T>()) {
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_memory.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_memory.h.rst
index d11b5e35467..dfe9be51e92 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_memory.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_memory.h.rst
@@ -35,6 +35,7 @@ Program Listing for File memory.h
#include <cstddef>
#include <cstdlib>
+ #include <new>
#include <type_traits>
#include <utility>
@@ -53,9 +54,7 @@ Program Listing for File memory.h
// - Can specialize by type of object to give the specific allocator to each object.
namespace details {
- template <size_t align>
- TVM_FFI_INLINE void* AlignedAlloc(size_t size) {
- static_assert(align != 0 && (align & (align - 1)) == 0, "align must be a power of 2");
+ TVM_FFI_INLINE void* AlignedAlloc(size_t size, size_t align) {
#ifdef _MSC_VER
// MSVC have to use _aligned_malloc
if (void* ptr = _aligned_malloc(size, align)) {
@@ -63,24 +62,23 @@ Program Listing for File memory.h
}
throw std::bad_alloc();
#else
- if constexpr (align <= alignof(std::max_align_t)) {
+ if (align <= alignof(std::max_align_t)) {
// malloc guarantees alignment of std::max_align_t
if (void* ptr = std::malloc(size)) {
return ptr;
}
throw std::bad_alloc();
- } else {
- void* ptr;
- // for other alignments, use posix_memalign
- if (posix_memalign(&ptr, align, size) != 0) {
- throw std::bad_alloc();
- }
- return ptr;
}
+ void* ptr;
+ // for other alignments, use posix_memalign
+ if (posix_memalign(&ptr, align, size) != 0) {
+ throw std::bad_alloc();
+ }
+ return ptr;
#endif
}
- TVM_FFI_INLINE void AlignedFree(void* data) {
+ TVM_FFI_INLINE void AlignedFree(void* data) noexcept {
#ifdef _MSC_VER
// MSVC have to use _aligned_free
_aligned_free(data);
@@ -127,6 +125,25 @@ Program Listing for File memory.h
// Simple allocator that uses new/delete.
class SimpleObjAllocator : public ObjAllocatorBase<SimpleObjAllocator> {
+ private:
+ class AllocGuard {
+ public:
+ explicit AllocGuard(void* data) noexcept : data_(data) {}
+ AllocGuard(const AllocGuard&) = delete;
+ AllocGuard& operator=(const AllocGuard&) = delete;
+
+ ~AllocGuard() noexcept {
+ if (data_ != nullptr) {
+ ObjectUnsafe::GetObjectAllocHeaderFromPtr(data_)->delete_space(data_);
+ }
+ }
+
+ void Release() noexcept { data_ = nullptr; }
+
+ private:
+ void* data_;
+ };
+
public:
template <typename T>
class Handler {
@@ -146,8 +163,14 @@ Program Listing for File memory.h
// class with non-virtual destructor.
// We are fine here as we captured the right deleter during construction.
// This is also the right way to get storage type for an object pool.
- void* data = AlignedAlloc<alignof(T)>(sizeof(T));
+ static_assert(alignof(T) <= alignof(::std::max_align_t),
+ "Object types with alignment > max_align_t are not supported "
+ "by the custom allocator hook");
+ TVMFFICustomAllocator* alloc = TVMFFIGetCustomAllocator();
+ void* data = alloc->allocate(sizeof(T), alignof(T), T::RuntimeTypeIndex(), alloc->context);
+ AllocGuard alloc_guard(data);
new (data) T(std::forward<Args>(args)...);
+ alloc_guard.Release();
return reinterpret_cast<T*>(data);
}
@@ -165,7 +188,8 @@ Program Listing for File memory.h
tptr->T::~T();
}
if (flags & kTVMFFIObjectDeleterFlagBitMaskWeak) {
- AlignedFree(static_cast<void*>(tptr));
+ ObjectUnsafe::GetObjectAllocHeaderFromPtr(static_cast<void*>(tptr))
+ ->delete_space(static_cast<void*>(tptr));
}
}
};
@@ -193,13 +217,20 @@ Program Listing for File memory.h
static_assert(
alignof(ArrayType) % alignof(ElemType) == 0 && sizeof(ArrayType) % alignof(ElemType) == 0,
"element alignment constraint");
+ static_assert(alignof(ArrayType) <= alignof(::std::max_align_t),
+ "Object types with alignment > max_align_t are not supported "
+ "by the custom allocator hook");
size_t size = sizeof(ArrayType) + sizeof(ElemType) * num_elems;
// round up to the nearest multiple of align
constexpr size_t align = alignof(ArrayType);
// C++ standard always guarantees that alignof operator returns a power of 2
size_t aligned_size = (size + (align - 1)) & ~(align - 1);
- void* data = AlignedAlloc<align>(aligned_size);
+ TVMFFICustomAllocator* alloc = TVMFFIGetCustomAllocator();
+ void* data =
+ alloc->allocate(aligned_size, align, ArrayType::RuntimeTypeIndex(), alloc->context);
+ AllocGuard alloc_guard(data);
new (data) ArrayType(std::forward<Args>(args)...);
+ alloc_guard.Release();
return reinterpret_cast<ArrayType*>(data);
}
@@ -217,7 +248,8 @@ Program Listing for File memory.h
tptr->ArrayType::~ArrayType();
}
if (flags & kTVMFFIObjectDeleterFlagBitMaskWeak) {
- AlignedFree(static_cast<void*>(tptr));
+ ObjectUnsafe::GetObjectAllocHeaderFromPtr(static_cast<void*>(tptr))
+ ->delete_space(static_cast<void*>(tptr));
}
}
};
@@ -229,6 +261,11 @@ Program Listing for File memory.h
return details::SimpleObjAllocator().make_object<T>(std::forward<Args>(args)...);
}
+ template <typename T, typename... Args>
+ inline Arc<T> make_arc(Args&&... args) {
+ return details::ObjectUnsafe::ArcFromObjectPtr(make_object<T>(std::forward<Args>(args)...));
+ }
+
template <typename ArrayType, typename ElemType, typename... Args>
inline ObjectPtr<ArrayType> make_inplace_array_object(size_t num_elems, Args&&... args) {
return details::SimpleObjAllocator().make_inplace_array<ArrayType, ElemType>(
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_object.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_object.h.rst
index e005c548b81..d513c98b224 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_object.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_object.h.rst
@@ -33,6 +33,7 @@ Program Listing for File object.h
#include <tvm/ffi/base_details.h>
#include <tvm/ffi/c_api.h>
+ #include <tvm/ffi/type_traits.h>
#include <optional>
#include <string>
@@ -42,48 +43,8 @@ Program Listing for File object.h
namespace tvm {
namespace ffi {
- using TypeIndex = TVMFFITypeIndex;
-
- using TypeInfo = TVMFFITypeInfo;
-
struct UnsafeInit {};
- struct StaticTypeKey {
- static constexpr const char* kTVMFFIAny = "Any";
- static constexpr const char* kTVMFFINone = "None";
- static constexpr const char* kTVMFFIBool = "bool";
- static constexpr const char* kTVMFFIInt = "int";
- static constexpr const char* kTVMFFIFloat = "float";
- static constexpr const char* kTVMFFIOpaquePtr = "void*";
- static constexpr const char* kTVMFFIDataType = "DataType";
- static constexpr const char* kTVMFFIDevice = "Device";
- static constexpr const char* kTVMFFIDLTensorPtr = "DLTensor*";
- static constexpr const char* kTVMFFIRawStr = "const char*";
- static constexpr const char* kTVMFFIByteArrayPtr = "TVMFFIByteArray*";
- static constexpr const char* kTVMFFIObjectRValueRef = "ObjectRValueRef";
- static constexpr const char* kTVMFFISmallStr = "ffi.SmallStr";
- static constexpr const char* kTVMFFISmallBytes = "ffi.SmallBytes";
- static constexpr const char* kTVMFFIError = "ffi.Error";
- static constexpr const char* kTVMFFIBytes = "ffi.Bytes";
- static constexpr const char* kTVMFFIStr = "ffi.String";
- static constexpr const char* kTVMFFIShape = "ffi.Shape";
- static constexpr const char* kTVMFFITensor = "ffi.Tensor";
- static constexpr const char* kTVMFFIObject = "ffi.Object";
- static constexpr const char* kTVMFFIFunction = "ffi.Function";
- static constexpr const char* kTVMFFIArray = "ffi.Array";
- static constexpr const char* kTVMFFIList = "ffi.List";
- static constexpr const char* kTVMFFIMap = "ffi.Map";
- static constexpr const char* kTVMFFIModule = "ffi.Module";
- static constexpr const char* kTVMFFIDict = "ffi.Dict";
- static constexpr const char* kTVMFFIVisitInterrupt = "ffi.VisitInterrupt";
- static constexpr const char* kTVMFFIOpaquePyObject = "ffi.OpaquePyObject";
- };
-
- inline std::string TypeIndexToTypeKey(int32_t type_index) {
- const TypeInfo* type_info = TVMFFIGetTypeInfo(type_index);
- return std::string(type_info->type_key.data, type_info->type_key.size);
- }
-
namespace details {
// Helper to perform
// unsafe operations related to object
@@ -96,6 +57,7 @@ Program Listing for File object.h
template <typename TargetType>
TVM_FFI_INLINE bool IsObjectInstance(int32_t object_type_index);
+
} // namespace details
class Object {
@@ -161,8 +123,8 @@ Program Listing for File object.h
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindUnsupported;
// The following functions are provided by macro
// TVM_FFI_DECLARE_OBJECT_INFO and TVM_FFI_DECLARE_OBJECT_INFO_FINAL
- static int32_t RuntimeTypeIndex() { return TypeIndex::kTVMFFIObject; }
- static int32_t _GetOrAllocRuntimeTypeIndex() { // NOLINT(bugprone-reserved-identifier)
+ TVM_FFI_INLINE static int32_t RuntimeTypeIndex() noexcept { return TypeIndex::kTVMFFIObject; }
+ TVM_FFI_COLD_CODE static int32_t _GetOrAllocRuntimeTypeIndex() { // NOLINT(*)
return TypeIndex::kTVMFFIObject;
}
@@ -388,6 +350,68 @@ Program Listing for File object.h
friend struct tvm::ffi::details::ObjectUnsafe;
};
+ template <typename T>
+ class Arc : public ObjectPtr<T> {
+ public:
+ Arc() = delete;
+ Arc(std::nullptr_t) = delete;
+
+ Arc(const Arc&) = default;
+
+ Arc(Arc&&) = default;
+
+ Arc& operator=(const Arc&) = default;
+
+ Arc& operator=(Arc&&) = default;
+
+ template <typename U, std::enable_if_t<std::is_base_of_v<T, U>, int> = 0>
+ Arc(const Arc<U>& other) // NOLINT(*)
+ : ObjectPtr<T>(static_cast<const ObjectPtr<U>&>(other)) {}
+
+ template <typename U, std::enable_if_t<std::is_base_of_v<T, U>, int> = 0>
+ Arc(Arc<U>&& other) // NOLINT(*)
+ : ObjectPtr<T>(std::move(static_cast<ObjectPtr<U>&>(other))) {}
+
+ explicit Arc(UnsafeInit tag) : ObjectPtr<T>(nullptr) { static_cast<void>(tag); }
+
+ private:
+ explicit Arc(ObjectPtr<T> ptr) : ObjectPtr<T>(std::move(ptr)) {}
+
+ using ObjectPtr<T>::reset;
+ using ObjectPtr<T>::swap;
+
+ template <typename U, typename... Args>
+ friend Arc<U> make_arc(Args&&... args);
+ template <typename>
+ friend class Arc;
+ friend struct tvm::ffi::details::ObjectUnsafe;
+ };
+
+ template <typename T>
+ inline constexpr bool is_object_subclass_v = std::is_base_of_v<Object, T>;
+
+ namespace details {
+
+ template <typename T>
+ inline constexpr bool is_qualified_object_v =
+ ::tvm::ffi::is_object_subclass_v<std::remove_cv_t<std::remove_reference_t<T>>> &&
+ !std::is_same_v<T, std::remove_cv_t<std::remove_reference_t<T>>>;
+
+ } // namespace details
+
+
+ template <typename BaseObject, typename DerivedObject>
+ inline constexpr bool type_subsumes_v<ObjectPtr<BaseObject>, ObjectPtr<DerivedObject>> =
+ std::is_base_of_v<BaseObject, DerivedObject>;
+
+ template <typename BaseObject, typename DerivedObject>
+ inline constexpr bool type_subsumes_v<Arc<BaseObject>, Arc<DerivedObject>> =
+ std::is_base_of_v<BaseObject, DerivedObject>;
+
+ template <typename BaseObject, typename DerivedObject>
+ inline constexpr bool type_subsumes_v<ObjectPtr<BaseObject>, Arc<DerivedObject>> =
+ std::is_base_of_v<BaseObject, DerivedObject>;
+
template <typename T>
class WeakObjectPtr {
public:
@@ -497,7 +521,7 @@ Program Listing for File object.h
int use_count() const { return data_.use_count(); }
template <typename ObjectType, typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>>
- const ObjectType* as() const {
+ const ObjectType* as() const& {
if (data_ != nullptr && data_->IsInstance<ObjectType>()) {
return static_cast<ObjectType*>(data_.get());
} else {
@@ -507,20 +531,61 @@ Program Listing for File object.h
template <typename ObjectRefType,
typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
- TVM_FFI_INLINE std::optional<ObjectRefType> as() const {
+ TVM_FFI_INLINE std::optional<ObjectRefType> as() const& {
if (data_ != nullptr) {
- if (data_->IsInstance<typename ObjectRefType::ContainerType>()) {
- ObjectRefType ref(UnsafeInit{});
- ref.data_ = data_;
- return ref;
- } else {
- return std::nullopt;
+ // Piggy back to Any TypeTraits for rich ObjectRef check, temp any_data will optimize away.
+ TVMFFIAny any_data;
+ any_data.type_index = data_->type_index();
+ TVM_FFI_UNSAFE_ASSUME(any_data.type_index >= TypeIndex::kTVMFFIStaticObjectBegin);
+ any_data.zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(&any_data);
+ any_data.v_obj = reinterpret_cast<TVMFFIObject*>(const_cast<Object*>(data_.get()));
+ if (TypeTraits<ObjectRefType>::CheckAnyStrict(&any_data)) {
+ ObjectRefType result(UnsafeInit{});
+ result.data_ = data_;
+ return result;
+ }
+ return std::nullopt;
+ }
+ if constexpr (ObjectRefType::_type_is_nullable) {
+ return ObjectRefType(UnsafeInit{});
+ }
+ return std::nullopt;
+ }
+
+ template <typename ObjectRefType,
+ typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
+ TVM_FFI_INLINE std::optional<ObjectRefType> as() && {
+ if (data_ != nullptr) {
+ // Piggy back to Any TypeTraits for rich ObjectRef check, temp any_data will optimize away.
+ TVMFFIAny any_data;
+ any_data.type_index = data_->type_index();
+ TVM_FFI_UNSAFE_ASSUME(any_data.type_index >= TypeIndex::kTVMFFIStaticObjectBegin);
+ any_data.zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(&any_data);
+ any_data.v_obj = reinterpret_cast<TVMFFIObject*>(const_cast<Object*>(data_.get()));
+ if (TypeTraits<ObjectRefType>::CheckAnyStrict(&any_data)) {
+ ObjectRefType result(UnsafeInit{});
+ result.data_ = std::move(data_);
+ data_ = nullptr;
+ return result;
}
- } else {
return std::nullopt;
}
+ if constexpr (ObjectRefType::_type_is_nullable) {
+ return ObjectRefType(UnsafeInit{});
+ }
+ return std::nullopt;
}
+ template <typename ObjectRefType,
+ typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
+ TVM_FFI_INLINE ObjectRefType as_or_throw() const&;
+
+ template <typename ObjectRefType,
+ typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
+ TVM_FFI_INLINE ObjectRefType as_or_throw() &&;
+
int32_t type_index() const {
return data_ != nullptr ? data_->type_index() : TypeIndex::kTVMFFINone;
}
@@ -530,6 +595,7 @@ Program Listing for File object.h
}
using ContainerType = Object;
+ static constexpr bool _type_container_is_exact = true;
static constexpr bool _type_is_nullable = true;
protected:
@@ -540,6 +606,13 @@ Program Listing for File object.h
friend struct tvm::ffi::details::ObjectUnsafe;
};
+ template <typename RefType, typename ObjectType,
+ typename = std::enable_if_t<std::is_base_of_v<ObjectRef, RefType> &&
+ std::is_base_of_v<Object, ObjectType>>>
+ inline constexpr bool object_ref_contains_v =
+ RefType::_type_container_is_exact &&
+ std::is_base_of_v<typename RefType::ContainerType, ObjectType>;
+
// forward delcare variant
template <typename... V>
class Variant;
@@ -570,7 +643,7 @@ Program Listing for File object.h
#define TVM_FFI_DECLARE_OBJECT_INFO_STATIC(TypeKey, TypeName, ParentType) \
static constexpr int32_t _type_depth = ParentType::_type_depth + 1; \
- static int32_t _GetOrAllocRuntimeTypeIndex() { \
+ TVM_FFI_COLD_CODE static int32_t _GetOrAllocRuntimeTypeIndex() { \
static_assert(!ParentType::_type_final, "ParentType marked as final"); \
static_assert(TypeName::_type_child_slots == 0 || ParentType::_type_child_slots == 0 || \
TypeName::_type_child_slots < ParentType::_type_child_slots, \
@@ -582,12 +655,12 @@ Program Listing for File object.h
TypeName::_type_child_slots_can_overflow, ParentType::_GetOrAllocRuntimeTypeIndex()); \
return TypeName::_type_index; \
} \
- static int32_t RuntimeTypeIndex() { return TypeName::_type_index; } \
+ TVM_FFI_INLINE static int32_t RuntimeTypeIndex() noexcept { return TypeName::_type_index; } \
static constexpr const char* _type_key = TypeKey
#define TVM_FFI_DECLARE_OBJECT_INFO_PREDEFINED_TYPE_KEY(TypeName, ParentType) \
static constexpr int32_t _type_depth = ParentType::_type_depth + 1; \
- static int32_t _GetOrAllocRuntimeTypeIndex() { \
+ TVM_FFI_COLD_CODE static int32_t _GetOrAllocRuntimeTypeIndex() { \
static_assert(!ParentType::_type_final, "ParentType marked as final"); \
static_assert(TypeName::_type_child_slots == 0 || ParentType::_type_child_slots == 0 || \
TypeName::_type_child_slots < ParentType::_type_child_slots, \
@@ -599,7 +672,8 @@ Program Listing for File object.h
TypeName::_type_child_slots_can_overflow, ParentType::_GetOrAllocRuntimeTypeIndex()); \
return tindex; \
} \
- static int32_t RuntimeTypeIndex() { return _GetOrAllocRuntimeTypeIndex(); }
+ static inline const int32_t _type_index = _GetOrAllocRuntimeTypeIndex(); \
+ TVM_FFI_INLINE static int32_t RuntimeTypeIndex() noexcept { return TypeName::_type_index; }
#define TVM_FFI_DECLARE_OBJECT_INFO(TypeKey, TypeName, ParentType) \
static constexpr const char* _type_key = TypeKey; \
@@ -716,6 +790,11 @@ Program Listing for File object.h
return const_cast<TVMFFIObject*>(&(src->header_));
}
+ TVM_FFI_INLINE static TVMFFIObjectAllocHeader* GetObjectAllocHeaderFromPtr(void* ptr) {
+ return reinterpret_cast<TVMFFIObjectAllocHeader*>(static_cast<char*>(ptr) -
+ sizeof(TVMFFIObjectAllocHeader));
+ }
+
// Suppress -Winvalid-offsetof: we intentionally use offsetof on non-standard-layout types
// to avoid undefined behavior from null pointer arithmetic that sanitizers flag.
#if defined(__clang__) || defined(__GNUC__)
@@ -778,6 +857,11 @@ Program Listing for File object.h
return ObjectPtrFromOwned<T>(reinterpret_cast<Object*>(obj_ptr));
}
+ template <typename T>
+ TVM_FFI_INLINE static Arc<T> ArcFromObjectPtr(ObjectPtr<T>&& ptr) {
+ return Arc<T>(std::move(ptr));
+ }
+
template <typename T>
TVM_FFI_INLINE static T* RawObjectPtrFromUnowned(TVMFFIObject* obj_ptr) {
// NOTE: this is important to first cast to Object*
@@ -831,7 +915,290 @@ Program Listing for File object.h
return GetHeader(obj_ptr);
}
};
+
} // namespace details
+
+ template <typename T>
+ struct TypeToRuntimeTypeIndex<T, std::enable_if_t<std::is_base_of_v<ObjectRef, T>>> {
+ static int32_t v() { return T::ContainerType::RuntimeTypeIndex(); }
+ };
+
+ template <typename TObject>
+ struct TypeToRuntimeTypeIndex<
+ ObjectPtr<TObject>, std::enable_if_t<is_object_subclass_v<TObject> &&
+ std::is_same_v<TObject, std::remove_cv_t<TObject>>>> {
+ static int32_t v() { return TObject::RuntimeTypeIndex(); }
+ };
+
+ template <typename TObject>
+ struct TypeToRuntimeTypeIndex<
+ Arc<TObject>, std::enable_if_t<is_object_subclass_v<TObject> &&
+ std::is_same_v<TObject, std::remove_cv_t<TObject>>>> {
+ static int32_t v() { return TObject::RuntimeTypeIndex(); }
+ };
+
+ template <typename TObject>
+ struct TypeTraits<ObjectPtr<TObject>,
+ std::enable_if_t<is_object_subclass_v<TObject> &&
+ std::is_same_v<TObject, std::remove_cv_t<TObject>>>>
+ : public TypeTraitsBase {
+ static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIObject;
+
+ TVM_FFI_INLINE static void CopyToAnyView(const ObjectPtr<TObject>& src, TVMFFIAny* result) {
+ if (src == nullptr) {
+ TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
+ return;
+ }
+ TVMFFIObject* obj_ptr = details::ObjectUnsafe::TVMFFIObjectPtrFromObjectPtr(src);
+ result->type_index = obj_ptr->type_index;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_obj = obj_ptr;
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(ObjectPtr<TObject> src, TVMFFIAny* result) {
+ if (src == nullptr) {
+ TypeTraits<std::nullptr_t>::MoveToAny(nullptr, result);
+ return;
+ }
+ TVMFFIObject* obj_ptr = details::ObjectUnsafe::MoveObjectPtrToTVMFFIObjectPtr(std::move(src));
+ result->type_index = obj_ptr->type_index;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_obj = obj_ptr;
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFINone) return true;
+ return src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
+ details::IsObjectInstance<TObject>(src->type_index);
+ }
+
+ TVM_FFI_INLINE static ObjectPtr<TObject> CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFINone) return nullptr;
+ return details::ObjectUnsafe::ObjectPtrFromUnowned<TObject>(src->v_obj);
+ }
+
+ TVM_FFI_INLINE static ObjectPtr<TObject> MoveFromAnyAfterCheck(TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFINone) return nullptr;
+ ObjectPtr<TObject> result = details::ObjectUnsafe::ObjectPtrFromOwned<TObject>(src->v_obj);
+ TypeTraits<std::nullptr_t>::MoveToAny(nullptr, src);
+ return result;
+ }
+
+ TVM_FFI_INLINE static std::optional<ObjectPtr<TObject>> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (CheckAnyStrict(src)) return CopyFromAnyViewAfterCheck(src);
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return TObject::_type_key; }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":"Optional","args":[{"type":")" + std::string(TObject::_type_key) + R"("}]})";
+ }
+ };
+
+ template <typename TObject>
+ struct TypeTraits<Arc<TObject>,
+ std::enable_if_t<is_object_subclass_v<TObject> &&
+ std::is_same_v<TObject, std::remove_cv_t<TObject>>>>
+ : public TypeTraitsBase {
+ static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIObject;
+
+ TVM_FFI_INLINE static void CopyToAnyView(const Arc<TObject>& src, TVMFFIAny* result) {
+ TypeTraits<ObjectPtr<TObject>>::CopyToAnyView(src, result);
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(Arc<TObject> src, TVMFFIAny* result) {
+ TypeTraits<ObjectPtr<TObject>>::MoveToAny(std::move(src), result);
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ return src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
+ details::IsObjectInstance<TObject>(src->type_index);
+ }
+
+ TVM_FFI_INLINE static Arc<TObject> CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ return details::ObjectUnsafe::ArcFromObjectPtr(
+ details::ObjectUnsafe::ObjectPtrFromUnowned<TObject>(src->v_obj));
+ }
+
+ TVM_FFI_INLINE static Arc<TObject> MoveFromAnyAfterCheck(TVMFFIAny* src) {
+ Arc<TObject> result = details::ObjectUnsafe::ArcFromObjectPtr(
+ details::ObjectUnsafe::ObjectPtrFromOwned<TObject>(src->v_obj));
+ TypeTraits<std::nullptr_t>::MoveToAny(nullptr, src);
+ return result;
+ }
+
+ TVM_FFI_INLINE static std::optional<Arc<TObject>> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (CheckAnyStrict(src)) return CopyFromAnyViewAfterCheck(src);
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return TObject::_type_key; }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":")" + std::string(TObject::_type_key) + R"("})";
+ }
+ };
+
+ template <typename TObjRef>
+ struct ObjectRefTypeTraitsBase : public TypeTraitsBase {
+ static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIObject;
+ using ContainerType = typename TObjRef::ContainerType;
+
+ TVM_FFI_INLINE static void CopyToAnyView(const TObjRef& src, TVMFFIAny* result) {
+ if constexpr (TObjRef::_type_is_nullable) {
+ if (!src.defined()) {
+ TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
+ return;
+ }
+ }
+ TVMFFIObject* obj_ptr = details::ObjectUnsafe::TVMFFIObjectPtrFromObjectRef(src);
+ result->type_index = obj_ptr->type_index;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_obj = obj_ptr;
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(TObjRef src, TVMFFIAny* result) {
+ if constexpr (TObjRef::_type_is_nullable) {
+ if (!src.defined()) {
+ TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
+ return;
+ }
+ }
+ TVMFFIObject* obj_ptr = details::ObjectUnsafe::MoveObjectRefToTVMFFIObjectPtr(std::move(src));
+ result->type_index = obj_ptr->type_index;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_obj = obj_ptr;
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ if constexpr (TObjRef::_type_is_nullable) {
+ if (src->type_index == TypeIndex::kTVMFFINone) return true;
+ }
+ return src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
+ details::IsObjectInstance<ContainerType>(src->type_index);
+ }
+
+ TVM_FFI_INLINE static TObjRef CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ if constexpr (TObjRef::_type_is_nullable) {
+ if (src->type_index == TypeIndex::kTVMFFINone) {
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(nullptr);
+ }
+ }
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(
+ details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(src->v_obj));
+ }
+
+ TVM_FFI_INLINE static TObjRef MoveFromAnyAfterCheck(TVMFFIAny* src) {
+ if constexpr (TObjRef::_type_is_nullable) {
+ if (src->type_index == TypeIndex::kTVMFFINone) {
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(nullptr);
+ }
+ }
+ ObjectPtr<ContainerType> obj_ptr =
+ details::ObjectUnsafe::ObjectPtrFromOwned<ContainerType>(src->v_obj);
+ TypeTraits<std::nullptr_t>::MoveToAny(nullptr, src);
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(std::move(obj_ptr));
+ }
+
+ TVM_FFI_INLINE static std::optional<TObjRef> TryCastFromAnyView(const TVMFFIAny* src) {
+ if constexpr (TObjRef::_type_is_nullable) {
+ if (src->type_index == TypeIndex::kTVMFFINone) {
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(nullptr);
+ }
+ }
+ if (src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
+ details::IsObjectInstance<ContainerType>(src->type_index)) {
+ return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(
+ details::ObjectUnsafe::ObjectPtrFromUnowned<ContainerType>(src->v_obj));
+ }
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return ContainerType::_type_key; }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":")" + std::string(ContainerType::_type_key) + R"("})";
+ }
+ };
+
+ template <typename TObjRef>
+ struct TypeTraits<TObjRef, std::enable_if_t<std::is_base_of_v<ObjectRef, TObjRef> &&
+ use_default_type_traits_v<TObjRef>>>
+ : public ObjectRefTypeTraitsBase<TObjRef> {};
+
+ template <typename ObjectRefType, typename... FallbackTypes>
+ struct ObjectRefWithFallbackTraitsBase : public ObjectRefTypeTraitsBase<ObjectRefType> {
+ TVM_FFI_INLINE static std::optional<ObjectRefType> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (auto opt_obj = ObjectRefTypeTraitsBase<ObjectRefType>::TryCastFromAnyView(src)) {
+ return opt_obj;
+ }
+ return TryFallbackTypes<FallbackTypes...>(src);
+ }
+
+ template <typename FallbackType, typename... Rest>
+ TVM_FFI_INLINE static std::optional<ObjectRefType> TryFallbackTypes(const TVMFFIAny* src) {
+ static_assert(!std::is_same_v<bool, FallbackType>,
+ "Using bool as FallbackType can cause bug because int will be detected as bool, "
+ "use tvm::ffi::StrictBool instead");
+ if (auto opt_fallback = TypeTraits<FallbackType>::TryCastFromAnyView(src)) {
+ return TypeTraits<ObjectRefType>::ConvertFallbackValue(*std::move(opt_fallback));
+ }
+ if constexpr (sizeof...(Rest) > 0) {
+ return TryFallbackTypes<Rest...>(src);
+ }
+ return std::nullopt;
+ }
+ };
+
+ template <typename TObject>
+ struct TypeTraits<TObject*, std::enable_if_t<std::is_base_of_v<Object, TObject>>>
+ : public TypeTraitsBase {
+ TVM_FFI_INLINE static void CopyToAnyView(TObject* src, TVMFFIAny* result) {
+ TVMFFIObject* obj_ptr = details::ObjectUnsafe::GetHeader(src);
+ result->type_index = obj_ptr->type_index;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_obj = obj_ptr;
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(TObject* src, TVMFFIAny* result) {
+ TVMFFIObject* obj_ptr = details::ObjectUnsafe::GetHeader(src);
+ result->type_index = obj_ptr->type_index;
+ result->zero_padding = 0;
+ TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
+ result->v_obj = obj_ptr;
+ details::ObjectUnsafe::IncRefObjectHandle(result->v_obj);
+ }
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ return src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
+ details::IsObjectInstance<TObject>(src->type_index);
+ }
+
+ TVM_FFI_INLINE static TObject* CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ if constexpr (!std::is_const_v<TObject>) {
+ static_assert(TObject::_type_mutable, "TObject must be mutable to enable cast from Any");
+ }
+ return details::ObjectUnsafe::RawObjectPtrFromUnowned<TObject>(src->v_obj);
+ }
+
+ TVM_FFI_INLINE static std::optional<TObject*> TryCastFromAnyView(const TVMFFIAny* src) {
+ if constexpr (!std::is_const_v<TObject>) {
+ static_assert(TObject::_type_mutable, "TObject must be mutable to enable cast from Any");
+ }
+ if (CheckAnyStrict(src)) return CopyFromAnyViewAfterCheck(src);
+ return std::nullopt;
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() { return TObject::_type_key; }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":")" + std::string(TObject::_type_key) + R"("})";
+ }
+ };
+
} // namespace ffi
} // namespace tvm
+
#endif // TVM_FFI_OBJECT_H_
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_optional.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_optional.h.rst
index 18b47a9e873..3d6b380eff4 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_optional.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_optional.h.rst
@@ -32,6 +32,7 @@ Program Listing for File optional.h
#ifndef TVM_FFI_OPTIONAL_H_
#define TVM_FFI_OPTIONAL_H_
+ #include <tvm/ffi/any.h>
#include <tvm/ffi/error.h>
#include <tvm/ffi/object.h>
#include <tvm/ffi/string.h>
@@ -51,57 +52,44 @@ Program Listing for File optional.h
template <typename T>
inline constexpr bool is_optional_type_v<Optional<T>> = true;
- // we can safely used ptr based optional for ObjectRef types
- // that do not have additional data members and virtual functions.
+ // Fallback specialization for types that do NOT enable Any storage
+ // (`TypeTraits<T>::storage_enabled == false`), such as non-owning view types
+ // that cannot be moved into an Any. These simply reuse std::optional<T>.
template <typename T>
- inline constexpr bool use_ptr_based_optional_v =
- (std::is_base_of_v<ObjectRef, T> && !is_optional_type_v<T>);
-
- // Specialization for non-ObjectRef types.
- // simply fallback to std::optional
- template <typename T>
- class Optional<T, std::enable_if_t<!use_ptr_based_optional_v<T> && !std::is_same_v<T, String> &&
- !std::is_same_v<T, Bytes>>> {
+ class Optional<T, std::enable_if_t<!TypeTraits<T>::storage_enabled>> {
public:
// default constructors.
Optional() = default;
// NOLINTBEGIN(google-explicit-constructor)
- Optional(const Optional<T>& other) : data_(other.data_) {}
- Optional(Optional<T>&& other) noexcept : data_(std::move(other.data_)) {}
+ Optional(const Optional& other) = default;
+ Optional(Optional&& other) noexcept = default;
Optional(std::optional<T> other) : data_(std::move(other)) {}
Optional(std::nullopt_t) {}
Optional(T other) : data_(std::move(other)) {}
// NOLINTEND(google-explicit-constructor)
- TVM_FFI_INLINE Optional<T>& operator=(const Optional<T>& other) {
- data_ = other.data_;
- return *this;
- }
-
- TVM_FFI_INLINE Optional<T>& operator=(Optional<T>&& other) noexcept {
- data_ = std::move(other.data_);
- return *this;
- }
+ Optional& operator=(const Optional& other) = default;
+ Optional& operator=(Optional&& other) noexcept = default;
- TVM_FFI_INLINE Optional<T>& operator=(T other) {
+ TVM_FFI_INLINE Optional& operator=(T other) {
data_ = std::move(other);
return *this;
}
- TVM_FFI_INLINE Optional<T>& operator=(std::nullopt_t) {
+ TVM_FFI_INLINE Optional& operator=(std::nullopt_t) {
data_ = std::nullopt;
return *this;
}
TVM_FFI_INLINE const T& value() const& {
- if (!data_.has_value()) {
+ if (TVM_FFI_PREDICT_FALSE(!data_.has_value())) {
TVM_FFI_THROW(RuntimeError) << "Back optional access";
}
return *data_;
}
TVM_FFI_INLINE T&& value() && {
- if (!data_.has_value()) {
+ if (TVM_FFI_PREDICT_FALSE(!data_.has_value())) {
TVM_FFI_THROW(RuntimeError) << "Back optional access";
}
return *std::move(data_);
@@ -116,10 +104,8 @@ Program Listing for File optional.h
TVM_FFI_INLINE bool has_value() const noexcept { return data_.has_value(); }
- TVM_FFI_INLINE bool operator==(const Optional<T>& other) const { return data_ == other.data_; }
-
- TVM_FFI_INLINE bool operator!=(const Optional<T>& other) const { return data_ != other.data_; }
-
+ TVM_FFI_INLINE bool operator==(const Optional& other) const { return data_ == other.data_; }
+ TVM_FFI_INLINE bool operator!=(const Optional& other) const { return data_ != other.data_; }
template <typename U>
TVM_FFI_INLINE bool operator==(const U& other) const {
return data_ == other;
@@ -138,251 +124,235 @@ Program Listing for File optional.h
std::optional<T> data_;
};
- // Specialization for String type, use nullptr to indicate nullopt
- template <typename T>
- class Optional<T, std::enable_if_t<std::is_same_v<T, String> || std::is_same_v<T, Bytes>>> {
- public:
- // default constructors.
- Optional() = default;
- // NOLINTBEGIN(google-explicit-constructor)
- Optional(const Optional<T>& other) : data_(other.data_) {}
- Optional(Optional<T>&& other) : data_(std::move(other.data_)) {}
- Optional(std::nullopt_t) {}
- Optional(T other) : data_(std::move(other)) {}
- // NOLINTEND(google-explicit-constructor)
-
- TVM_FFI_INLINE Optional<T>& operator=(const Optional<T>& other) {
- data_ = other.data_;
- return *this;
- }
-
- TVM_FFI_INLINE Optional<T>& operator=(Optional<T>&& other) {
- data_ = std::move(other.data_);
- return *this;
- }
-
- TVM_FFI_INLINE Optional<T>& operator=(T other) {
- data_ = std::move(other);
- return *this;
- }
-
- TVM_FFI_INLINE Optional<T>& operator=(std::nullopt_t) {
- T(details::BytesBaseCell(std::nullopt)).swap(data_);
- return *this;
- }
-
- TVM_FFI_INLINE const T& value() const& {
- if (data_.data_ == std::nullopt) {
- TVM_FFI_THROW(RuntimeError) << "Back optional access";
- }
- return data_;
- }
-
- TVM_FFI_INLINE String&& value() && {
- if (data_.data_ == std::nullopt) {
- TVM_FFI_THROW(RuntimeError) << "Back optional access";
- }
- return std::move(data_);
- }
-
- template <typename U = T>
- TVM_FFI_INLINE T value_or(U&& default_value) const {
- if (data_.data_ == std::nullopt) {
- return std::forward<U>(default_value);
- }
- return data_;
- }
-
- TVM_FFI_INLINE explicit operator bool() const noexcept { return data_.data_ != std::nullopt; }
-
- TVM_FFI_INLINE bool has_value() const noexcept { return data_.data_ != std::nullopt; }
-
- TVM_FFI_INLINE bool operator==(const Optional<T>& other) const {
- if (data_.data_ == std::nullopt) {
- return other.data_.data_ == std::nullopt;
- }
- if (other.data_.data_ == std::nullopt) {
- return false;
- }
- return data_ == other.data_;
- }
-
- TVM_FFI_INLINE bool operator!=(const Optional<T>& other) const { return !(*this == other); }
-
- template <typename U>
- TVM_FFI_INLINE bool operator==(const U& other) const {
- if constexpr (std::is_same_v<U, std::nullopt_t>) {
- return data_.data_ == std::nullopt;
- } else {
- if (data_.data_ == std::nullopt) {
- return false;
- }
- return data_ == other;
- }
- }
- template <typename U>
- TVM_FFI_INLINE bool operator!=(const U& other) const {
- if constexpr (std::is_same_v<U, std::nullopt_t>) {
- return data_.data_ != std::nullopt;
- } else {
- if (data_.data_ == std::nullopt) {
- return true;
- }
- return data_ != other;
- }
- }
-
- TVM_FFI_INLINE T&& operator*() && noexcept { return std::move(data_); }
- TVM_FFI_INLINE const T& operator*() const& noexcept { return data_; }
-
- private:
- // this is a private initializer
- T data_{details::BytesBaseCell(std::nullopt)};
- };
-
- // Specialization for ObjectRef types.
- // nullptr is treated as std::nullopt.
template <typename T>
- class Optional<T, std::enable_if_t<use_ptr_based_optional_v<T>>> : public ObjectRef {
+ class Optional<T, std::enable_if_t<TypeTraits<T>::storage_enabled>> {
public:
- using ContainerType = typename T::ContainerType;
Optional() = default;
// NOLINTBEGIN(google-explicit-constructor)
- Optional(const Optional<T>& other) : ObjectRef(other) {}
- Optional(Optional<T>&& other) noexcept : ObjectRef(std::move(other)) {}
- explicit Optional(ffi::UnsafeInit tag) : ObjectRef(tag) {}
Optional(std::nullopt_t) {}
+ Optional(const Optional& other) = default;
+ Optional(Optional&& other) noexcept = default;
+ Optional(const T& value) : data_(value) {}
+ Optional(T&& value) : data_(std::move(value)) {}
Optional(std::optional<T> other) {
if (other.has_value()) {
- *this = *std::move(other);
+ data_ = Any(*std::move(other));
}
}
- Optional(T other) : ObjectRef(std::move(other)) {}
// NOLINTEND(google-explicit-constructor)
- TVM_FFI_INLINE Optional<T>& operator=(T other) {
- ObjectRef::operator=(std::move(other));
- return *this;
- }
+ Optional& operator=(const Optional& other) = default;
+ Optional& operator=(Optional&& other) noexcept = default;
- TVM_FFI_INLINE Optional<T>& operator=(const Optional<T>& other) {
- data_ = other.data_;
+ TVM_FFI_INLINE Optional& operator=(T other) {
+ data_ = Any(std::move(other));
return *this;
}
- TVM_FFI_INLINE Optional<T>& operator=(std::nullptr_t) {
- data_ = nullptr;
+ TVM_FFI_INLINE Optional& operator=(std::nullopt_t) {
+ data_.reset();
return *this;
}
- TVM_FFI_INLINE Optional<T>& operator=(Optional<T>&& other) {
- data_ = std::move(other.data_);
+ TVM_FFI_INLINE Optional& operator=(std::nullptr_t) {
+ data_.reset();
return *this;
}
TVM_FFI_INLINE T value() const& {
- if (data_ == nullptr) {
+ if (TVM_FFI_PREDICT_FALSE(!has_value())) {
TVM_FFI_THROW(RuntimeError) << "Back optional access";
}
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<T>(data_);
+ // The invariant guarantees the stored value is exactly a T, so decode it
+ // directly with the low-level after-check path (no conversion/cast).
+ return details::AnyUnsafe::CopyFromAnyViewAfterCheck<T>(data_);
}
TVM_FFI_INLINE T value() && {
- if (data_ == nullptr) {
+ if (TVM_FFI_PREDICT_FALSE(!has_value())) {
TVM_FFI_THROW(RuntimeError) << "Back optional access";
}
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<T>(std::move(data_));
+ return details::AnyUnsafe::MoveFromAnyAfterCheck<T>(std::move(data_));
}
template <typename U = std::remove_cv_t<T>>
TVM_FFI_INLINE T value_or(U&& default_value) const {
- return data_ != nullptr ? details::ObjectUnsafe::ObjectRefFromObjectPtr<T>(data_)
- : T(std::forward<U>(default_value));
+ if (has_value()) {
+ return details::AnyUnsafe::CopyFromAnyViewAfterCheck<T>(data_);
+ }
+ return T(std::forward<U>(default_value));
}
- TVM_FFI_INLINE explicit operator bool() const { return data_ != nullptr; }
+ TVM_FFI_INLINE explicit operator bool() const noexcept { return has_value(); }
- TVM_FFI_INLINE bool has_value() const { return data_ != nullptr; }
+ TVM_FFI_INLINE bool has_value() const noexcept {
+ return data_.type_index() != TypeIndex::kTVMFFINone;
+ }
- TVM_FFI_INLINE T operator*() const& noexcept {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<T>(data_);
+ template <typename U>
+ TVM_FFI_INLINE auto as() const {
+ return data_.template as<U>();
}
- TVM_FFI_INLINE T operator*() && noexcept {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<T>(std::move(data_));
+ TVM_FFI_INLINE T operator*() const& {
+ return details::AnyUnsafe::CopyFromAnyViewAfterCheck<T>(data_);
+ }
+ TVM_FFI_INLINE T operator*() && {
+ return details::AnyUnsafe::MoveFromAnyAfterCheck<T>(std::move(data_));
}
+ // comparison with nullopt / nullptr
+ TVM_FFI_INLINE bool operator==(std::nullopt_t) const noexcept { return !has_value(); }
+ TVM_FFI_INLINE bool operator!=(std::nullopt_t) const noexcept { return has_value(); }
TVM_FFI_INLINE bool operator==(std::nullptr_t) const noexcept { return !has_value(); }
TVM_FFI_INLINE bool operator!=(std::nullptr_t) const noexcept { return has_value(); }
- // operator overloadings
- TVM_FFI_INLINE auto operator==(const Optional<T>& other) const {
+ // comparison with another Optional<T>
+ TVM_FFI_INLINE auto operator==(const Optional& other) const {
// support case where sub-class returns a symbolic ref type.
- return EQToOptional(other);
+ using RetType = decltype(std::declval<T>() == std::declval<T>());
+ if (data_.same_as(other.data_)) return RetType(true);
+ if (has_value() && other.has_value()) return **this == *other;
+ return RetType(false);
+ }
+ TVM_FFI_INLINE auto operator!=(const Optional& other) const {
+ using RetType = decltype(std::declval<T>() != std::declval<T>());
+ if (data_.same_as(other.data_)) return RetType(false);
+ if (has_value() && other.has_value()) return **this != *other;
+ return RetType(true);
}
- TVM_FFI_INLINE auto operator!=(const Optional<T>& other) const { return NEToOptional(other); }
+ // comparison with a std::optional<T>
TVM_FFI_INLINE auto operator==(const std::optional<T>& other) const {
- // support case where sub-class returns a symbolic ref type.
- return EQToOptional(other);
+ using RetType = decltype(std::declval<T>() == std::declval<T>());
+ if (has_value() && other.has_value()) return **this == *other;
+ return RetType(!has_value() && !other.has_value());
}
TVM_FFI_INLINE auto operator!=(const std::optional<T>& other) const {
- return NEToOptional(other);
- }
-
- TVM_FFI_INLINE auto operator==(const T& other) const {
- using RetType = decltype(value() == other);
- if (same_as(other)) return RetType(true);
- if (has_value()) return operator*() == other;
- return RetType(false);
+ using RetType = decltype(std::declval<T>() != std::declval<T>());
+ if (has_value() && other.has_value()) return **this != *other;
+ return RetType(has_value() != other.has_value());
}
- TVM_FFI_INLINE auto operator!=(const T& other) const { return !(*this == other); }
-
- template <typename U>
+ // comparison with a value of another type U
+ template <typename U, typename = std::enable_if_t<!is_optional_type_v<U> &&
+ !std::is_same_v<U, std::nullopt_t> &&
+ !std::is_same_v<U, std::nullptr_t>>>
TVM_FFI_INLINE auto operator==(const U& other) const {
- using RetType = decltype(value() == other);
+ using RetType = decltype(std::declval<T>() == std::declval<U>());
+ if constexpr (std::is_base_of_v<ObjectRef, T> && std::is_base_of_v<ObjectRef, U>) {
+ // support case where sub-class returns a symbolic ref type.
+ if (data_.same_as(other)) return RetType(true);
+ }
if (!has_value()) return RetType(false);
- return operator*() == other;
+ return **this == other;
}
-
- template <typename U>
+ template <typename U, typename = std::enable_if_t<!is_optional_type_v<U> &&
+ !std::is_same_v<U, std::nullopt_t> &&
+ !std::is_same_v<U, std::nullptr_t>>>
TVM_FFI_INLINE auto operator!=(const U& other) const {
- using RetType = decltype(value() != other);
+ using RetType = decltype(std::declval<T>() != std::declval<U>());
+ if constexpr (std::is_base_of_v<ObjectRef, T> && std::is_base_of_v<ObjectRef, U>) {
+ if (data_.same_as(other)) return RetType(false);
+ }
if (!has_value()) return RetType(true);
- return operator*() != other;
+ return **this != other;
}
- TVM_FFI_INLINE const ContainerType* get() const {
- return static_cast<ContainerType*>(data_.get());
+ TVM_FFI_INLINE bool same_as(const Optional& other) const { return data_.same_as(other.data_); }
+
+ template <typename U = T, typename = std::enable_if_t<std::is_base_of_v<ObjectRef, U>>>
+ TVM_FFI_INLINE bool same_as(const U& other) const {
+ return data_.same_as(other);
}
private:
- template <typename U>
- TVM_FFI_INLINE auto EQToOptional(const U& other) const {
- // support case where sub-class returns a symbolic ref type.
- using RetType = decltype(operator*() == *other);
- if (same_as(other)) return RetType(true);
- if (has_value() && other.has_value()) {
- return operator*() == *other;
+ friend struct TypeTraits<Optional<T>>;
+ // construct directly from an Any backing store.
+ explicit Optional(Any data) : data_(std::move(data)) {}
+ TVM_FFI_INLINE AnyView ToAnyView() const { return data_.operator AnyView(); }
+ TVM_FFI_INLINE Any MoveToAny() && { return std::move(data_); }
+ Any data_;
+ };
+
+ template <typename T>
+ inline constexpr bool use_default_type_traits_v<Optional<T>> = false;
+
+ template <typename T>
+ struct TypeTraits<Optional<T>> : public TypeTraitsBase {
+ // storage_enabled propagates from T: Optional<T> can live in an Any exactly
+ // when T can. This keeps nested Optional<Optional<T>> and Optional<T> used
+ // inside Variant<...>/containers Any-backed iff T is storage-enabled.
+ static constexpr bool storage_enabled = TypeTraits<T>::storage_enabled;
+
+ TVM_FFI_INLINE static void CopyToAnyView(const Optional<T>& src, TVMFFIAny* result) {
+ if constexpr (TypeTraits<T>::storage_enabled) {
+ // Storage-enabled: the Any already holds the exact representation.
+ *result = src.ToAnyView().CopyToTVMFFIAny();
} else {
- // one of them is nullptr.
- return RetType(false);
+ if (src.has_value()) {
+ TypeTraits<T>::CopyToAnyView(*src, result);
+ } else {
+ TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
+ }
}
}
- template <typename U>
- TVM_FFI_INLINE auto NEToOptional(const U& other) const {
- // support case where sub-class returns a symbolic ref type.
- using RetType = decltype(operator*() != *other);
- if (same_as(other)) return RetType(false);
- if (has_value() && other.has_value()) {
- return operator*() != *other;
+ TVM_FFI_INLINE static void MoveToAny(Optional<T> src, TVMFFIAny* result) {
+ if constexpr (TypeTraits<T>::storage_enabled) {
+ *result = details::AnyUnsafe::MoveAnyToTVMFFIAny(std::move(src).MoveToAny());
} else {
- // one of them is nullptr.
- return RetType(true);
+ if (src.has_value()) {
+ TypeTraits<T>::MoveToAny(*std::move(src), result);
+ } else {
+ TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
+ }
}
}
+
+ TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFINone) return true;
+ return TypeTraits<T>::CheckAnyStrict(src);
+ }
+
+ TVM_FFI_INLINE static Optional<T> CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
+ if constexpr (TypeTraits<T>::storage_enabled) {
+ return Optional<T>(Any(AnyView::CopyFromTVMFFIAny(*src)));
+ } else {
+ if (src->type_index == TypeIndex::kTVMFFINone) return Optional<T>(std::nullopt);
+ return Optional<T>(TypeTraits<T>::CopyFromAnyViewAfterCheck(src));
+ }
+ }
+
+ TVM_FFI_INLINE static Optional<T> MoveFromAnyAfterCheck(TVMFFIAny* src) {
+ if constexpr (TypeTraits<T>::storage_enabled) {
+ return Optional<T>(details::AnyUnsafe::MoveTVMFFIAnyToAny(src));
+ } else {
+ if (src->type_index == TypeIndex::kTVMFFINone) return Optional<T>(std::nullopt);
+ return Optional<T>(TypeTraits<T>::MoveFromAnyAfterCheck(src));
+ }
+ }
+
+ TVM_FFI_INLINE static std::optional<Optional<T>> TryCastFromAnyView(const TVMFFIAny* src) {
+ if (src->type_index == TypeIndex::kTVMFFINone) return Optional<T>(std::nullopt);
+ if (std::optional<T> opt = TypeTraits<T>::TryCastFromAnyView(src)) {
+ return Optional<T>(*std::move(opt));
+ }
+ // Important to be explicit here because nullopt can convert to
+ // std::optional<T>(nullopt), which would incorrectly signal success.
+ return std::optional<Optional<T>>(std::nullopt);
+ }
+
+ TVM_FFI_INLINE static std::string GetMismatchTypeInfo(const TVMFFIAny* src) {
+ return TypeTraits<T>::GetMismatchTypeInfo(src);
+ }
+
+ TVM_FFI_INLINE static std::string TypeStr() {
+ return "Optional<" + TypeTraits<T>::TypeStr() + ">";
+ }
+ TVM_FFI_INLINE static std::string TypeSchema() {
+ return R"({"type":"Optional","args":[)" + details::TypeSchema<T>::v() + "]}";
+ }
};
} // namespace ffi
} // namespace tvm
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_access_path.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_access_path.h.rst
index b39db4225e2..eb4b426745f 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_access_path.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_access_path.h.rst
@@ -158,8 +158,8 @@ Program Listing for File access_path.h
if (!(*lhs->step)->StepEqual(*(rhs->step))) {
return false;
}
- lhs = static_cast<const AccessPathObj*>(lhs->parent.get());
- rhs = static_cast<const AccessPathObj*>(rhs->parent.get());
+ lhs = lhs->parent.as<AccessPathObj>();
+ rhs = rhs->parent.as<AccessPathObj>();
// fast path for same pointer
if (lhs == rhs) return true;
TVM_FFI_ICHECK(lhs != nullptr);
@@ -243,7 +243,7 @@ Program Listing for File access_path.h
while (current->parent.has_value()) {
TVM_FFI_ICHECK(current->step.has_value());
reverse_steps.push_back(*(current->step));
- current = static_cast<const AccessPathObj*>(current->parent.get());
+ current = current->parent.as<AccessPathObj>();
TVM_FFI_ICHECK(current != nullptr);
}
return Array<AccessStep>(reverse_steps.rbegin(), reverse_steps.rend());
@@ -260,7 +260,7 @@ Program Listing for File access_path.h
const AccessPathObj* rhs_path = other.get();
while (rhs_path->depth > this->depth) {
TVM_FFI_ICHECK(rhs_path->parent.has_value());
- rhs_path = static_cast<const AccessPathObj*>(rhs_path->parent.get());
+ rhs_path = rhs_path->parent.as<AccessPathObj>();
}
return PathEqual(this, rhs_path);
}
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_accessor.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_accessor.h.rst
index c914cada2e7..a9994bd8450 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_accessor.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_accessor.h.rst
@@ -48,7 +48,8 @@ Program Listing for File accessor.h
TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeKeyToIndex(&type_key_array, &type_index));
const TypeInfo* info = TVMFFIGetTypeInfo(type_index);
for (int32_t i = 0; i < info->num_fields; ++i) {
- if (std::strncmp(info->fields[i].name.data, field_name, info->fields[i].name.size) == 0) {
+ if (std::strncmp(info->fields[i].name.data, field_name, info->fields[i].name.size) == 0 &&
+ field_name[info->fields[i].name.size] == '\0') {
return &(info->fields[i]);
}
}
@@ -147,7 +148,8 @@ Program Listing for File accessor.h
TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeKeyToIndex(&type_key_array, &type_index));
const TypeInfo* info = TVMFFIGetTypeInfo(type_index);
for (int32_t i = 0; i < info->num_methods; ++i) {
- if (std::strncmp(info->methods[i].name.data, method_name, info->methods[i].name.size) == 0) {
+ if (std::strncmp(info->methods[i].name.data, method_name, info->methods[i].name.size) == 0 &&
+ method_name[info->methods[i].name.size] == '\0') {
return &(info->methods[i]);
}
}
@@ -209,6 +211,7 @@ Program Listing for File accessor.h
inline constexpr const char* kNew = "__ffi_new__";
inline constexpr const char* kInit = "__ffi_init__";
inline constexpr const char* kConvert = "__ffi_convert__";
+ inline constexpr const char* kConvertTypeSchema = "__ffi_convert_type_schema__";
inline constexpr const char* kShallowCopy = "__ffi_shallow_copy__";
inline constexpr const char* kRepr = "__ffi_repr__";
inline constexpr const char* kHash = "__ffi_hash__";
@@ -221,9 +224,7 @@ Program Listing for File accessor.h
inline constexpr const char* kStructuralVisit = "__s_visit__";
inline constexpr const char* kDataToJson = "__data_to_json__";
inline constexpr const char* kDataFromJson = "__data_from_json__";
- inline constexpr const char* kEnumEntries = "__ffi_enum_entries__";
- inline constexpr const char* kEnumAttrs = "__ffi_enum_attrs__";
- inline constexpr const char* kEnumValueEntries = "__ffi_enum_value_entries__";
+ inline constexpr const char* kEnumState = "__ffi_enum__";
} // namespace type_attr
inline constexpr TVMFFIByteArray AsByteArray(const char* s) {
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_creator.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_creator.h.rst
index 28317e6355d..b11320ad129 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_creator.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_creator.h.rst
@@ -92,6 +92,7 @@ Program Listing for File creator.h
}
TVM_FFI_THROW(TypeError) << "Cannot cast from `" << TypeIndexToTypeKey(input_pod.type_index)
<< "` to `" << TypeTraits<TObjectRef>::TypeStr() << "`";
+ TVM_FFI_UNREACHABLE();
}
} // namespace details
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_enum_def.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_enum_def.h.rst
index ee4be8f15d1..6da7846c4b6 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_enum_def.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_enum_def.h.rst
@@ -45,7 +45,6 @@ Program Listing for File enum_def.h
#include <tvm/ffi/string.h>
#include <cstdint>
- #include <string>
#include <type_traits>
#include <utility>
@@ -56,78 +55,76 @@ Program Listing for File enum_def.h
template <typename EnumClsObj, typename = std::enable_if_t<std::is_base_of_v<EnumObj, EnumClsObj>>>
class EnumDef : public ReflectionDefBase {
public:
- explicit EnumDef(const char* instance_name)
- : type_index_(EnumClsObj::RuntimeTypeIndex()), name_(instance_name) {
- Dict<String, Enum> entries = EnsureEntriesDict();
- String name_str(name_);
- if (entries.count(name_str) != 0) {
- TVM_FFI_THROW(RuntimeError) << "Duplicate enum entry `" << name_ << "` for type `"
- << EnumClsObj::_type_key << "`";
- }
- ordinal_ = static_cast<int64_t>(entries.size());
- ObjectPtr<EnumClsObj> obj = make_object<EnumClsObj>();
- obj->_value = ordinal_;
- obj->_name = name_str;
- instance_ = Enum(ObjectPtr<EnumObj>(std::move(obj)));
- entries.Set(name_str, instance_);
- // Ensure the attrs dict exists so later ``set_attr`` calls can mutate it.
- EnsureAttrsDict();
+ explicit EnumDef(const char* str_index) : type_index_(EnumClsObj::_GetOrAllocRuntimeTypeIndex()) {
+ static_assert(!std::is_base_of_v<IntEnumObj, EnumClsObj>,
+ "IntEnum registration requires an explicit integer index");
+ EnumState state = EnsureState();
+ Register(state, static_cast<int64_t>(state->entries.size()), String(str_index));
+ }
+
+ EnumDef(const char* str_index, int64_t int_index)
+ : type_index_(EnumClsObj::_GetOrAllocRuntimeTypeIndex()) {
+ static_assert(std::is_base_of_v<IntEnumObj, EnumClsObj>,
+ "Explicit integer indices are reserved for IntEnum");
+ Register(EnsureState(), int_index, String(str_index));
}
template <typename T>
EnumDef& set_attr(const char* attr_name, T value) {
- Dict<String, List<Any>> attrs = EnsureAttrsDict();
- String attr_key(attr_name);
- List<Any> column;
- auto it = attrs.find(attr_key);
- if (it == attrs.end()) {
- column = List<Any>();
- attrs.Set(attr_key, column);
- } else {
- column = (*it).second;
- }
- while (static_cast<int64_t>(column.size()) <= ordinal_) {
- column.push_back(Any(nullptr));
- }
- column.Set(ordinal_, Any(std::move(value)));
+ Dict<String, Dict<ObjectRef, Any>> attrs = EnsureState()->attrs;
+ String key(attr_name);
+ Dict<ObjectRef, Any> column = attrs.Get(key).value_or(Dict<ObjectRef, Any>());
+ attrs.Set(key, column);
+ column.Set(instance_, Any(std::move(value)));
return *this;
}
- Enum instance() const { return instance_; }
-
- int64_t ordinal() const { return ordinal_; }
-
private:
- Dict<String, Enum> EnsureEntriesDict() {
- return EnsureDict<Dict<String, Enum>>(type_attr::kEnumEntries);
- }
-
- Dict<String, List<Any>> EnsureAttrsDict() {
- return EnsureDict<Dict<String, List<Any>>>(type_attr::kEnumAttrs);
+ void Register(const EnumState& state, int64_t int_index, String str_index) {
+ List<ObjectRef> entries = state->entries;
+ Dict<Any, ObjectRef> indexes = state->indexes;
+ Any int_key(int_index);
+ Any str_key(str_index);
+ if (indexes.count(int_key) || indexes.count(str_key)) {
+ TVM_FFI_THROW(ValueError) << "Duplicate enum index for type `" << EnumClsObj::_type_key
+ << "`";
+ }
+ ObjectPtr<EnumClsObj> obj = make_object<EnumClsObj>();
+ ::tvm::ffi::details::ObjectUnsafe::GetHeader(obj.get())->type_index = type_index_;
+ obj->_int_index = int_index;
+ obj->_str_index = std::move(str_index);
+ instance_ = Enum(ObjectPtr<EnumObj>(std::move(obj)));
+ entries.push_back(instance_);
+ indexes.Set(int_key, instance_);
+ indexes.Set(str_key, instance_);
}
- template <typename DictT>
- DictT EnsureDict(const char* attr_name) {
- TVMFFIByteArray name_array = {attr_name, std::char_traits<char>::length(attr_name)};
- const TVMFFITypeAttrColumn* column = TVMFFIGetTypeAttrColumn(&name_array);
- if (column != nullptr) {
- int32_t offset = type_index_ - column->begin_index;
- if (offset >= 0 && offset < column->size) {
- const TVMFFIAny* stored = &column->data[offset];
- if (stored->type_index != kTVMFFINone) {
- return AnyView::CopyFromTVMFFIAny(*stored).cast<DictT>();
- }
+ EnumState EnsureState() {
+ int32_t state_type_index = EnumStateObj::_GetOrAllocRuntimeTypeIndex();
+ TypeAttrColumn column(type_attr::kEnumState);
+ if (AnyView value = column[type_index_]; value != nullptr) {
+ if (value.type_index() != state_type_index) {
+ TVM_FFI_THROW(TypeError) << "Expected `" << EnumStateObj::_type_key
+ << "` in enum state column, but got `" << value.GetTypeKey()
+ << "`";
}
+ // Avoid cast<EnumState> here because it reads the same deferred inline type index.
+ TVMFFIAny value_any = value.CopyToTVMFFIAny();
+ return ::tvm::ffi::details::ObjectUnsafe::ObjectRefFromObjectPtr<EnumState>(
+ ::tvm::ffi::details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(value_any.v_obj));
}
- DictT fresh;
- TVMFFIAny value_any = AnyView(fresh).CopyToTVMFFIAny();
- TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeRegisterAttr(type_index_, &name_array, &value_any));
- return fresh;
+ ObjectPtr<EnumStateObj> state_obj = make_object<EnumStateObj>();
+ // GCC runs attribute constructors before dynamic initialization of inline type indices.
+ // Set the header explicitly so the state is not packed as `None` during static init.
+ ::tvm::ffi::details::ObjectUnsafe::GetHeader(state_obj.get())->type_index = state_type_index;
+ EnumState state(std::move(state_obj));
+ constexpr TVMFFIByteArray name = AsByteArray(type_attr::kEnumState);
+ TVMFFIAny value_any = AnyView(state).CopyToTVMFFIAny();
+ TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeRegisterAttr(type_index_, &name, &value_any));
+ return state;
}
int32_t type_index_;
- const char* name_;
- int64_t ordinal_;
Enum instance_;
};
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_overload.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_overload.h.rst
index 7d08f72be7b..25122add1cc 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_overload.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_overload.h.rst
@@ -411,18 +411,25 @@ Program Listing for File overload.h
auto method_name = std::string(type_key_) + "." + name;
- // if an overload method exists, register to existing overload function
+ // If an overload method exists, add the callable to the existing runtime
+ // dispatcher but still publish a TypeMethod entry for this signature.
+ // Stub generators consume TypeInfo::methods, so omitting later entries
+ // made an overloaded C++ method look like a single Python signature.
+ Function method;
if (const auto overload_it = registered_fields_.find(name);
overload_it != registered_fields_.end()) {
- ::tvm::ffi::details::OverloadBase* overload_ptr = overload_it->second;
- return overload_ptr->Register(NewOverload(std::move(method_name), std::forward<Func>(func)));
+ overload_it->second.overload->Register(
+ NewOverload(std::move(method_name), std::forward<Func>(func)));
+ method = overload_it->second.method;
+ } else {
+ // First registration creates the runtime overload dispatcher. Keep the
+ // Function alive so every reflected signature can reference it.
+ auto [new_method, overload_ptr] =
+ GetOverloadMethod(std::move(method_name), std::forward<Func>(func));
+ method = std::move(new_method);
+ registered_fields_.try_emplace(name, RegisteredMethod{overload_ptr, method});
}
- // first time registering overload method
- auto [method, overload_ptr] =
- GetOverloadMethod(std::move(method_name), std::forward<Func>(func));
- registered_fields_.try_emplace(name, overload_ptr);
-
info.method = AnyView(method).CopyToTVMFFIAny();
info.metadata_.emplace_back("type_schema", FuncInfo::TypeSchema());
// apply method info traits
@@ -432,7 +439,12 @@ Program Listing for File overload.h
TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeRegisterMethod(type_index_, &info));
}
- std::unordered_map<std::string, ::tvm::ffi::details::OverloadBase*> registered_fields_;
+ struct RegisteredMethod {
+ ::tvm::ffi::details::OverloadBase* overload;
+ Function method;
+ };
+
+ std::unordered_map<std::string, RegisteredMethod> registered_fields_;
};
} // namespace reflection
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_registry.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_registry.h.rst
index 02d0cb41184..76bbdc9cf2d 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_registry.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_reflection_registry.h.rst
@@ -54,6 +54,16 @@ Program Listing for File registry.h
namespace tvm {
namespace ffi {
namespace reflection {
+ namespace details {
+
+ template <typename T, typename = void>
+ struct HasContainerType : public std::false_type {};
+
+ template <typename T>
+ struct HasContainerType<T, std::void_t<typename T::ContainerType>> : public std::true_type {};
+
+ } // namespace details
+
using _MetadataType = std::vector<std::pair<String, Any>>; // NOLINT(bugprone-reserved-identifier)
struct FieldInfoBuilder : public TVMFFIFieldInfo {
_MetadataType metadata_;
@@ -300,6 +310,14 @@ Program Listing for File registry.h
return ffi::Function::FromTyped(WrapFunction(std::forward<Func>(func)), std::move(name));
}
+ template <typename Value>
+ TVM_FFI_INLINE static void RegisterTypeAttrValue(int32_t type_index, const char* name,
+ Value&& value) {
+ TVMFFIByteArray name_array = {name, std::char_traits<char>::length(name)};
+ TVMFFIAny value_any = AnyView(std::forward<Value>(value)).CopyToTVMFFIAny();
+ TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeRegisterAttr(type_index, &name_array, &value_any));
+ }
+
template <typename Func>
TVM_FFI_INLINE static Func&& WrapFunction(Func&& func) {
return std::forward<Func>(func);
@@ -505,6 +523,34 @@ Program Listing for File registry.h
return *this;
}
+ template <typename Value,
+ std::enable_if_t<std::is_convertible_v<Value&&, AnyView> ||
+ std::is_convertible_v<std::decay_t<Value>, AnyView>,
+ int> = 0>
+ TVM_FFI_INLINE ObjectDef& def_type_attr(const char* name, Value&& value) {
+ RegisterTypeAttrValue(type_index_, name, std::forward<Value>(value));
+ return *this;
+ }
+
+ template <typename Func, std::enable_if_t<!std::is_convertible_v<Func&&, AnyView> &&
+ !std::is_convertible_v<std::decay_t<Func>, AnyView>,
+ int> = 0>
+ TVM_FFI_INLINE ObjectDef& def_type_attr(const char* name, Func&& func) {
+ ffi::Function ffi_func =
+ GetMethod(std::string(type_key_) + "." + name, std::forward<Func>(func));
+ RegisterTypeAttrValue(type_index_, name, ffi_func);
+ return *this;
+ }
+
+ template <typename TSelf>
+ TVM_FFI_INLINE ObjectDef& def_convert() {
+ if constexpr (details::HasContainerType<TSelf>::value) {
+ static_assert(std::is_same_v<typename TSelf::ContainerType, Class>,
+ "TSelf::ContainerType must match ObjectDef's object type");
+ }
+ return def_type_attr(type_attr::kConvert, &details::FFIConvertFromAnyViewToObjectRef<TSelf>);
+ }
+
template <typename... Args, typename... Extra>
TVM_FFI_INLINE ObjectDef& def([[maybe_unused]] init<Args...> init_func, Extra&&... extra) {
has_explicit_init_ = true;
@@ -619,23 +665,39 @@ Program Listing for File registry.h
public:
template <typename... ExtraArgs>
explicit TypeAttrDef(ExtraArgs&&... extra_args)
- : type_index_(Class::RuntimeTypeIndex()), type_key_(Class::_type_key) {}
+ : type_index_(Class::_GetOrAllocRuntimeTypeIndex()), type_key_(Class::_type_key) {}
+
+ template <typename Value,
+ std::enable_if_t<std::is_convertible_v<Value&&, AnyView> ||
+ std::is_convertible_v<std::decay_t<Value>, AnyView>,
+ int> = 0>
+ TypeAttrDef& def(const char* name, Value&& value) {
+ RegisterTypeAttrValue(type_index_, name, std::forward<Value>(value));
+ return *this;
+ }
- template <typename Func>
+ template <typename Func, std::enable_if_t<!std::is_convertible_v<Func&&, AnyView> &&
+ !std::is_convertible_v<std::decay_t<Func>, AnyView>,
+ int> = 0>
TypeAttrDef& def(const char* name, Func&& func) {
- TVMFFIByteArray name_array = {name, std::char_traits<char>::length(name)};
ffi::Function ffi_func =
GetMethod(std::string(type_key_) + "." + name, std::forward<Func>(func));
- TVMFFIAny value_any = AnyView(ffi_func).CopyToTVMFFIAny();
- TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeRegisterAttr(type_index_, &name_array, &value_any));
+ RegisterTypeAttrValue(type_index_, name, ffi_func);
return *this;
}
+ template <typename TSelf>
+ TVM_FFI_INLINE TypeAttrDef& def_convert() {
+ if constexpr (details::HasContainerType<TSelf>::value) {
+ static_assert(std::is_same_v<typename TSelf::ContainerType, Class>,
+ "TSelf::ContainerType must match TypeAttrDef's object type");
+ }
+ return def(type_attr::kConvert, &details::FFIConvertFromAnyViewToObjectRef<TSelf>);
+ }
+
template <typename T>
TypeAttrDef& attr(const char* name, T value) {
- TVMFFIByteArray name_array = {name, std::char_traits<char>::length(name)};
- TVMFFIAny value_any = AnyView(value).CopyToTVMFFIAny();
- TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeRegisterAttr(type_index_, &name_array, &value_any));
+ RegisterTypeAttrValue(type_index_, name, std::move(value));
return *this;
}
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_tvm_ffi.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_tvm_ffi.h.rst
index 487ade04e1d..3cee131afc1 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_tvm_ffi.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_tvm_ffi.h.rst
@@ -43,6 +43,7 @@ Program Listing for File tvm_ffi.h
#include <tvm/ffi/container/tensor.h>
#include <tvm/ffi/container/tuple.h>
#include <tvm/ffi/container/variant.h>
+ #include <tvm/ffi/device.h>
#include <tvm/ffi/dtype.h>
#include <tvm/ffi/endian.h>
#include <tvm/ffi/enum.h>
diff --git a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_type_traits.h.rst b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_type_traits.h.rst
index 76b3b626925..cf8f85348d4 100644
--- a/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_type_traits.h.rst
+++ b/ffi/_sources/reference/cpp/generated/program_listing_file_tvm_ffi_type_traits.h.rst
@@ -33,10 +33,8 @@ Program Listing for File type_traits.h
#include <tvm/ffi/base_details.h>
#include <tvm/ffi/c_api.h>
- #include <tvm/ffi/error.h>
- #include <tvm/ffi/object.h>
- #include <limits>
+ #include <optional>
#include <string>
#include <type_traits>
#include <utility>
@@ -46,6 +44,53 @@ Program Listing for File type_traits.h
class Any;
+ using TypeIndex = TVMFFITypeIndex;
+ using TypeInfo = TVMFFITypeInfo;
+
+ struct StaticTypeKey {
+ static constexpr const char* kTVMFFIAny = "Any";
+ static constexpr const char* kTVMFFINone = "None";
+ static constexpr const char* kTVMFFIBool = "bool";
+ static constexpr const char* kTVMFFIInt = "int";
+ static constexpr const char* kTVMFFIFloat = "float";
+ static constexpr const char* kTVMFFIOpaquePtr = "void*";
+ static constexpr const char* kTVMFFIDataType = "DataType";
+ static constexpr const char* kTVMFFIDevice = "Device";
+ static constexpr const char* kTVMFFIDLTensorPtr = "DLTensor*";
+ static constexpr const char* kTVMFFIRawStr = "const char*";
+ static constexpr const char* kTVMFFIByteArrayPtr = "TVMFFIByteArray*";
+ static constexpr const char* kTVMFFIObjectRValueRef = "ObjectRValueRef";
+ static constexpr const char* kTVMFFISmallStr = "ffi.SmallStr";
+ static constexpr const char* kTVMFFISmallBytes = "ffi.SmallBytes";
+ static constexpr const char* kTVMFFIError = "ffi.Error";
+ static constexpr const char* kTVMFFIBytes = "ffi.Bytes";
+ static constexpr const char* kTVMFFIStr = "ffi.String";
+ static constexpr const char* kTVMFFIShape = "ffi.Shape";
+ static constexpr const char* kTVMFFITensor = "ffi.Tensor";
+ static constexpr const char* kTVMFFIObject = "ffi.Object";
+ static constexpr const char* kTVMFFIFunction = "ffi.Function";
+ static constexpr const char* kTVMFFIArray = "ffi.Array";
+ static constexpr const char* kTVMFFIList = "ffi.List";
+ static constexpr const char* kTVMFFIMap = "ffi.Map";
+ static constexpr const char* kTVMFFIModule = "ffi.Module";
+ static constexpr const char* kTVMFFIDict = "ffi.Dict";
+ static constexpr const char* kTVMFFIVisitInterrupt = "ffi.VisitInterrupt";
+ static constexpr const char* kTVMFFIOpaquePyObject = "ffi.OpaquePyObject";
+ };
+
+ inline std::string TypeIndexToTypeKey(int32_t type_index) {
+ const TypeInfo* type_info = TVMFFIGetTypeInfo(type_index);
+ return std::string(type_info->type_key.data, type_info->type_key.size);
+ }
+
+ template <typename TargetType, typename SourceType, typename = void>
+ inline constexpr bool type_subsumes_v =
+ std::is_base_of_v<TargetType, SourceType> || std::is_same_v<TargetType, SourceType>;
+
+
+ template <typename SourceType>
+ inline constexpr bool type_subsumes_v<Any, SourceType> = true;
+
template <typename, typename = void>
struct TypeTraits {
static constexpr bool convert_enabled = false;
@@ -86,11 +131,6 @@ Program Listing for File type_traits.h
static int32_t v() { return TypeToFieldStaticTypeIndex<T>::value; }
};
- template <typename T>
- struct TypeToRuntimeTypeIndex<T, std::enable_if_t<std::is_base_of_v<ObjectRef, T>>> {
- static int32_t v() { return T::ContainerType::RuntimeTypeIndex(); }
- };
-
// None
template <>
struct TypeTraits<std::nullptr_t> : public TypeTraitsBase {
@@ -224,26 +264,16 @@ Program Listing for File type_traits.h
}
};
- // Integer POD values
template <typename Int>
- struct TypeTraits<Int, std::enable_if_t<std::is_integral_v<Int>>> : public TypeTraitsBase {
+ struct TypeTraitsIntBase : public TypeTraitsBase {
static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIInt;
- TVM_FFI_INLINE static void CopyToAnyView(const Int& src, TVMFFIAny* result) {
- if constexpr (std::is_unsigned_v<Int> && sizeof(Int) >= sizeof(int64_t)) {
- if (src > static_cast<Int>(std::numeric_limits<int64_t>::max())) {
- TVM_FFI_THROW(OverflowError)
- << "Integer value " << src << " is too large to fit in int64_t. "
- << "Consider explicitly casting to int64_t first if this is intentional.";
- }
- }
+ TVM_FFI_INLINE static void CopyInt64ToAnyView(int64_t src, TVMFFIAny* result) {
result->type_index = TypeIndex::kTVMFFIInt;
result->zero_padding = 0;
- result->v_int64 = static_cast<int64_t>(src); // NOLINT(bugprone-signed-char-misuse)
+ result->v_int64 = src;
}
- TVM_FFI_INLINE static void MoveToAny(Int src, TVMFFIAny* result) { CopyToAnyView(src, result); }
-
TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
// NOTE: CheckAnyStrict is always strict and should be consistent with MoveToAny
return src->type_index == TypeIndex::kTVMFFIInt;
@@ -272,6 +302,16 @@ Program Listing for File type_traits.h
}
};
+ // Integer POD values
+ template <typename Int>
+ struct TypeTraits<Int, std::enable_if_t<std::is_integral_v<Int>>> : public TypeTraitsIntBase<Int> {
+ TVM_FFI_INLINE static void CopyToAnyView(const Int& src, TVMFFIAny* result) {
+ TypeTraitsIntBase<Int>::CopyInt64ToAnyView(static_cast<int64_t>(src), result);
+ }
+
+ TVM_FFI_INLINE static void MoveToAny(Int src, TVMFFIAny* result) { CopyToAnyView(src, result); }
+ };
+
// trait to check if a type is an integeral enum
// note that we need this trait so we can confirm underlying_type_t is an integral type
@@ -285,45 +325,15 @@ Program Listing for File type_traits.h
// Enum Integer POD values
template <typename IntEnum>
- struct TypeTraits<IntEnum, std::enable_if_t<is_integeral_enum_v<IntEnum>>> : public TypeTraitsBase {
- static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIInt;
-
+ struct TypeTraits<IntEnum, std::enable_if_t<is_integeral_enum_v<IntEnum>>>
+ : public TypeTraitsIntBase<IntEnum> {
TVM_FFI_INLINE static void CopyToAnyView(const IntEnum& src, TVMFFIAny* result) {
- result->type_index = TypeIndex::kTVMFFIInt;
- result->zero_padding = 0;
- result->v_int64 = static_cast<int64_t>(src);
+ TypeTraitsIntBase<IntEnum>::CopyInt64ToAnyView(static_cast<int64_t>(src), result);
}
TVM_FFI_INLINE static void MoveToAny(IntEnum src, TVMFFIAny* result) {
CopyToAnyView(src, result);
}
-
- TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
- // NOTE: CheckAnyStrict is always strict and should be consistent with MoveToAny
- return src->type_index == TypeIndex::kTVMFFIInt;
- }
-
- TVM_FFI_INLINE static IntEnum CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
- TVM_FFI_UNSAFE_ASSUME(src->type_index == TypeIndex::kTVMFFIInt);
- return static_cast<IntEnum>(src->v_int64);
- }
-
- TVM_FFI_INLINE static IntEnum MoveFromAnyAfterCheck(TVMFFIAny* src) {
- // POD type, we can just copy the value
- return CopyFromAnyViewAfterCheck(src);
- }
-
- TVM_FFI_INLINE static std::optional<IntEnum> TryCastFromAnyView(const TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFIInt || src->type_index == TypeIndex::kTVMFFIBool) {
- return static_cast<IntEnum>(src->v_int64);
- }
- return std::nullopt;
- }
-
- TVM_FFI_INLINE static std::string TypeStr() { return StaticTypeKey::kTVMFFIInt; }
- TVM_FFI_INLINE static std::string TypeSchema() {
- return R"({"type":")" + std::string(StaticTypeKey::kTVMFFIInt) + R"("})";
- }
};
// Float POD values
@@ -416,188 +426,6 @@ Program Listing for File type_traits.h
}
};
- // Device
- template <>
- struct TypeTraits<DLDevice> : public TypeTraitsBase {
- static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIDevice;
-
- TVM_FFI_INLINE static void CopyToAnyView(const DLDevice& src, TVMFFIAny* result) {
- result->type_index = TypeIndex::kTVMFFIDevice;
- result->zero_padding = 0;
- result->v_device = src;
- }
-
- TVM_FFI_INLINE static void MoveToAny(DLDevice src, TVMFFIAny* result) {
- result->type_index = TypeIndex::kTVMFFIDevice;
- result->zero_padding = 0;
- result->v_device = src;
- }
-
- TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
- return src->type_index == TypeIndex::kTVMFFIDevice;
- }
-
- TVM_FFI_INLINE static DLDevice CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
- TVM_FFI_UNSAFE_ASSUME(src->type_index == TypeIndex::kTVMFFIDevice);
- return src->v_device;
- }
-
- TVM_FFI_INLINE static DLDevice MoveFromAnyAfterCheck(TVMFFIAny* src) {
- // POD type, we can just copy the value
- return CopyFromAnyViewAfterCheck(src);
- }
-
- TVM_FFI_INLINE static std::optional<DLDevice> TryCastFromAnyView(const TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFIDevice) {
- return src->v_device;
- }
- return std::nullopt;
- }
-
- TVM_FFI_INLINE static std::string TypeStr() { return StaticTypeKey::kTVMFFIDevice; }
- TVM_FFI_INLINE static std::string TypeSchema() {
- return R"({"type":")" + std::string(StaticTypeKey::kTVMFFIDevice) + R"("})";
- }
- };
-
- // DLTensor*, requirement: not nullable, do not retain ownership
- template <>
- struct TypeTraits<DLTensor*> : public TypeTraitsBase {
- static constexpr bool storage_enabled = false;
- static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIDLTensorPtr;
-
- TVM_FFI_INLINE static void CopyToAnyView(DLTensor* src, TVMFFIAny* result) {
- TVM_FFI_ICHECK_NOTNULL(src);
- result->type_index = TypeIndex::kTVMFFIDLTensorPtr;
- result->zero_padding = 0;
- TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
- result->v_ptr = src;
- }
-
- TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
- return src->type_index == TypeIndex::kTVMFFIDLTensorPtr;
- }
-
- TVM_FFI_INLINE static DLTensor* CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
- TVM_FFI_UNSAFE_ASSUME(src->type_index == TypeIndex::kTVMFFIDLTensorPtr);
- return static_cast<DLTensor*>(src->v_ptr);
- }
-
- TVM_FFI_INLINE static void MoveToAny(DLTensor*, TVMFFIAny*) {
- TVM_FFI_THROW(RuntimeError)
- << "DLTensor* cannot be held in Any as it does not retain ownership, use Tensor instead";
- }
-
- TVM_FFI_INLINE static std::optional<DLTensor*> TryCastFromAnyView(const TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFIDLTensorPtr) {
- return static_cast<DLTensor*>(src->v_ptr);
- } else if (src->type_index == TypeIndex::kTVMFFITensor) {
- // Conversion from Tensor pointer to DLTensor
- // based on the assumption that Tensor always follows the TVMFFIObject header
- static_assert(sizeof(TVMFFIObject) == 24);
- return reinterpret_cast<DLTensor*>(reinterpret_cast<char*>(src->v_obj) +
- sizeof(TVMFFIObject));
- }
- return std::nullopt;
- }
-
- TVM_FFI_INLINE static std::string TypeStr() { return "DLTensor*"; }
- TVM_FFI_INLINE static std::string TypeSchema() { return R"({"type":"DLTensor*"})"; }
- };
-
- // Traits for ObjectRef, None to ObjectRef will always fail.
- // use std::optional<ObjectRef> instead for nullable references.
- template <typename TObjRef>
- struct ObjectRefTypeTraitsBase : public TypeTraitsBase {
- static constexpr int32_t field_static_type_index = TypeIndex::kTVMFFIObject;
- using ContainerType = typename TObjRef::ContainerType;
-
- TVM_FFI_INLINE static void CopyToAnyView(const TObjRef& src, TVMFFIAny* result) {
- if constexpr (TObjRef::_type_is_nullable) {
- if (!src.defined()) {
- TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
- return;
- }
- }
- TVMFFIObject* obj_ptr = details::ObjectUnsafe::TVMFFIObjectPtrFromObjectRef(src);
- result->type_index = obj_ptr->type_index;
- result->zero_padding = 0;
- TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
- result->v_obj = obj_ptr;
- }
-
- TVM_FFI_INLINE static void MoveToAny(TObjRef src, TVMFFIAny* result) {
- if constexpr (TObjRef::_type_is_nullable) {
- if (!src.defined()) {
- TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
- return;
- }
- }
- TVMFFIObject* obj_ptr = details::ObjectUnsafe::MoveObjectRefToTVMFFIObjectPtr(std::move(src));
- result->type_index = obj_ptr->type_index;
- result->zero_padding = 0;
- TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
- result->v_obj = obj_ptr;
- }
-
- TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
- if constexpr (TObjRef::_type_is_nullable) {
- if (src->type_index == TypeIndex::kTVMFFINone) return true;
- }
- return (src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
- details::IsObjectInstance<ContainerType>(src->type_index));
- }
-
- TVM_FFI_INLINE static TObjRef CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
- if constexpr (TObjRef::_type_is_nullable) {
- if (src->type_index == TypeIndex::kTVMFFINone) {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(nullptr);
- }
- }
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(
- details::ObjectUnsafe::ObjectPtrFromUnowned<Object>(src->v_obj));
- }
-
- TVM_FFI_INLINE static TObjRef MoveFromAnyAfterCheck(TVMFFIAny* src) {
- if constexpr (TObjRef::_type_is_nullable) {
- if (src->type_index == TypeIndex::kTVMFFINone) {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(nullptr);
- }
- }
- // move out the object pointer
- ObjectPtr<ContainerType> obj_ptr =
- details::ObjectUnsafe::ObjectPtrFromOwned<ContainerType>(src->v_obj);
- // reset the src to nullptr
- TypeTraits<std::nullptr_t>::MoveToAny(nullptr, src);
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(std::move(obj_ptr));
- }
-
- TVM_FFI_INLINE static std::optional<TObjRef> TryCastFromAnyView(const TVMFFIAny* src) {
- if constexpr (TObjRef::_type_is_nullable) {
- if (src->type_index == TypeIndex::kTVMFFINone) {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(nullptr);
- }
- }
- if (src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin) {
- if (details::IsObjectInstance<ContainerType>(src->type_index)) {
- return details::ObjectUnsafe::ObjectRefFromObjectPtr<TObjRef>(
- details::ObjectUnsafe::ObjectPtrFromUnowned<ContainerType>(src->v_obj));
- }
- }
- return std::nullopt;
- }
-
- TVM_FFI_INLINE static std::string TypeStr() { return ContainerType::_type_key; }
- TVM_FFI_INLINE static std::string TypeSchema() {
- return R"({"type":")" + std::string(ContainerType::_type_key) + R"("})";
- }
- };
-
- template <typename TObjRef>
- struct TypeTraits<TObjRef, std::enable_if_t<std::is_base_of_v<ObjectRef, TObjRef> &&
- use_default_type_traits_v<TObjRef>>>
- : public ObjectRefTypeTraitsBase<TObjRef> {};
-
template <typename T, typename... FallbackTypes>
struct FallbackOnlyTraitsBase : public TypeTraitsBase {
// disable container for FallbackOnlyTraitsBase
@@ -622,144 +450,24 @@ Program Listing for File type_traits.h
}
};
- template <typename ObjectRefType, typename... FallbackTypes>
- struct ObjectRefWithFallbackTraitsBase : public ObjectRefTypeTraitsBase<ObjectRefType> {
- TVM_FFI_INLINE static std::optional<ObjectRefType> TryCastFromAnyView(const TVMFFIAny* src) {
- if (auto opt_obj = ObjectRefTypeTraitsBase<ObjectRefType>::TryCastFromAnyView(src)) {
- return opt_obj;
- }
- // apply fallback types in TryCastFromAnyView
- return TryFallbackTypes<FallbackTypes...>(src);
- }
-
- template <typename FallbackType, typename... Rest>
- TVM_FFI_INLINE static std::optional<ObjectRefType> TryFallbackTypes(const TVMFFIAny* src) {
- static_assert(!std::is_same_v<bool, FallbackType>,
- "Using bool as FallbackType can cause bug because int will be detected as bool, "
- "use tvm::ffi::StrictBool instead");
- if (auto opt_fallback = TypeTraits<FallbackType>::TryCastFromAnyView(src)) {
- return TypeTraits<ObjectRefType>::ConvertFallbackValue(*std::move(opt_fallback));
- }
- if constexpr (sizeof...(Rest) > 0) {
- return TryFallbackTypes<Rest...>(src);
- }
- return std::nullopt;
- }
- };
-
- // Traits for weak pointer of object
- // NOTE: we require the weak pointer cast from
-
- template <typename TObject>
- struct TypeTraits<TObject*, std::enable_if_t<std::is_base_of_v<Object, TObject>>>
- : public TypeTraitsBase {
- TVM_FFI_INLINE static void CopyToAnyView(TObject* src, TVMFFIAny* result) {
- TVMFFIObject* obj_ptr = details::ObjectUnsafe::GetHeader(src);
- result->type_index = obj_ptr->type_index;
- result->zero_padding = 0;
- TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
- result->v_obj = obj_ptr;
- }
-
- TVM_FFI_INLINE static void MoveToAny(TObject* src, TVMFFIAny* result) {
- TVMFFIObject* obj_ptr = details::ObjectUnsafe::GetHeader(src);
- result->type_index = obj_ptr->type_index;
- result->zero_padding = 0;
- TVM_FFI_CLEAR_PTR_PADDING_IN_FFI_ANY(result);
- result->v_obj = obj_ptr;
- // needs to increase ref because original weak ptr do not own the code
- details::ObjectUnsafe::IncRefObjectHandle(result->v_obj);
- }
-
- TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
- return src->type_index >= TypeIndex::kTVMFFIStaticObjectBegin &&
- details::IsObjectInstance<TObject>(src->type_index);
- }
-
- TVM_FFI_INLINE static TObject* CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
- if constexpr (!std::is_const_v<TObject>) {
- static_assert(TObject::_type_mutable, "TObject must be mutable to enable cast from Any");
- }
- return details::ObjectUnsafe::RawObjectPtrFromUnowned<TObject>(src->v_obj);
- }
-
- TVM_FFI_INLINE static std::optional<TObject*> TryCastFromAnyView(const TVMFFIAny* src) {
- if constexpr (!std::is_const_v<TObject>) {
- static_assert(TObject::_type_mutable, "TObject must be mutable to enable cast from Any");
- }
- if (CheckAnyStrict(src)) return CopyFromAnyViewAfterCheck(src);
- return std::nullopt;
- }
-
- TVM_FFI_INLINE static std::string TypeStr() { return TObject::_type_key; }
- TVM_FFI_INLINE static std::string TypeSchema() {
- return R"({"type":")" + std::string(TObject::_type_key) + R"("})";
- }
- };
-
- template <typename T>
- inline constexpr bool use_default_type_traits_v<Optional<T>> = false;
-
- template <typename T>
- struct TypeTraits<Optional<T>> : public TypeTraitsBase {
- TVM_FFI_INLINE static void CopyToAnyView(const Optional<T>& src, TVMFFIAny* result) {
- if (src.has_value()) {
- TypeTraits<T>::CopyToAnyView(*src, result);
- } else {
- TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
- }
- }
-
- TVM_FFI_INLINE static void MoveToAny(Optional<T> src, TVMFFIAny* result) {
- if (src.has_value()) {
- TypeTraits<T>::MoveToAny(*std::move(src), result);
- } else {
- TypeTraits<std::nullptr_t>::CopyToAnyView(nullptr, result);
- }
- }
-
- TVM_FFI_INLINE static bool CheckAnyStrict(const TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFINone) return true;
- return TypeTraits<T>::CheckAnyStrict(src);
- }
-
- TVM_FFI_INLINE static Optional<T> CopyFromAnyViewAfterCheck(const TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFINone) {
- return Optional<T>(std::nullopt);
- }
- return TypeTraits<T>::CopyFromAnyViewAfterCheck(src);
- }
-
- TVM_FFI_INLINE static Optional<T> MoveFromAnyAfterCheck(TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFINone) {
- return Optional<T>(std::nullopt);
- }
- return TypeTraits<T>::MoveFromAnyAfterCheck(src);
- }
-
- TVM_FFI_INLINE static std::optional<Optional<T>> TryCastFromAnyView(const TVMFFIAny* src) {
- if (src->type_index == TypeIndex::kTVMFFINone) return Optional<T>(std::nullopt);
- if (std::optional<T> opt = TypeTraits<T>::TryCastFromAnyView(src)) {
- return Optional<T>(*std::move(opt));
- } else {
- // important to be explicit here
- // because nullopt can convert to std::optional<T>(nullopt) which indicate success
- // return std::optional<Optional<T>>(std::nullopt) to indicate failure
- return std::optional<Optional<T>>(std::nullopt);
- }
- }
+ } // namespace ffi
+ } // namespace tvm
- TVM_FFI_INLINE static std::string GetMismatchTypeInfo(const TVMFFIAny* src) {
- return TypeTraits<T>::GetMismatchTypeInfo(src);
+ #define TVM_FFI_DECLARE_OBJECT_INFO_LOOKUP(RegisteredKey, TypeDepth) \
+ static constexpr const char* _type_key = RegisteredKey; \
+ static constexpr int32_t _type_depth = TypeDepth; \
+ static constexpr bool _type_mutable = true; \
+ static constexpr bool _type_final = false; \
+ static constexpr uint32_t _type_child_slots = 0; \
+ static constexpr bool _type_child_slots_can_overflow = true; \
+ static int32_t RuntimeTypeIndex() { \
+ static const int32_t type_index = []() { \
+ constexpr TVMFFIByteArray key{RegisteredKey, sizeof(RegisteredKey) - 1}; \
+ int32_t result = -1; \
+ TVM_FFI_CHECK_SAFE_CALL(TVMFFITypeKeyToIndex(&key, &result)); \
+ return result; \
+ }(); \
+ return type_index; \
}
- TVM_FFI_INLINE static std::string TypeStr() {
- return "Optional<" + TypeTraits<T>::TypeStr() + ">";
- }
- TVM_FFI_INLINE static std::string TypeSchema() {
- return R"({"type":"Optional","args":[)" + details::TypeSchema<T>::v() + "]}";
- }
- };
- } // namespace ffi
- } // namespace tvm
#endif // TVM_FFI_TYPE_TRAITS_H_
diff --git a/ffi/_sources/reference/cpp/generated/structTVMFFICustomAllocator.rst b/ffi/_sources/reference/cpp/generated/structTVMFFICustomAllocator.rst
new file mode 100644
index 00000000000..ad15eaa2858
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/structTVMFFICustomAllocator.rst
@@ -0,0 +1,17 @@
+.. _exhale_struct_structTVMFFICustomAllocator:
+
+Struct TVMFFICustomAllocator
+============================
+
+- Defined in :ref:`file_tvm_ffi_c_api.h`
+
+
+Struct Documentation
+--------------------
+
+
+.. doxygenstruct:: TVMFFICustomAllocator
+ :project: tvm-ffi
+ :members:
+ :protected-members:
+ :undoc-members:
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/structTVMFFIObjectAllocHeader.rst b/ffi/_sources/reference/cpp/generated/structTVMFFIObjectAllocHeader.rst
new file mode 100644
index 00000000000..87e86785e50
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/structTVMFFIObjectAllocHeader.rst
@@ -0,0 +1,17 @@
+.. _exhale_struct_structTVMFFIObjectAllocHeader:
+
+Struct TVMFFIObjectAllocHeader
+==============================
+
+- Defined in :ref:`file_tvm_ffi_c_api.h`
+
+
+Struct Documentation
+--------------------
+
+
+.. doxygenstruct:: TVMFFIObjectAllocHeader
+ :project: tvm-ffi
+ :members:
+ :protected-members:
+ :undoc-members:
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1ObjectRefWithFallbackTraitsBase.rst b/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1ObjectRefWithFallbackTraitsBase.rst
index 26fea2c14e7..1bad646d8fd 100644
--- a/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1ObjectRefWithFallbackTraitsBase.rst
+++ b/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1ObjectRefWithFallbackTraitsBase.rst
@@ -3,7 +3,7 @@
Template Struct ObjectRefWithFallbackTraitsBase
===============================================
-- Defined in :ref:`file_tvm_ffi_type_traits.h`
+- Defined in :ref:`file_tvm_ffi_object.h`
Inheritance Relationships
diff --git a/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1StaticTypeKey.rst b/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1StaticTypeKey.rst
index ceea97ad533..4741e194177 100644
--- a/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1StaticTypeKey.rst
+++ b/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1StaticTypeKey.rst
@@ -3,7 +3,7 @@
Struct StaticTypeKey
====================
-- Defined in :ref:`file_tvm_ffi_object.h`
+- Defined in :ref:`file_tvm_ffi_type_traits.h`
Struct Documentation
diff --git a/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod.rst b/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod.rst
new file mode 100644
index 00000000000..d9a93b35c4c
--- /dev/null
+++ b/ffi/_sources/reference/cpp/generated/structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod.rst
@@ -0,0 +1,23 @@
+.. _exhale_struct_structtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef_1_1RegisteredMethod:
+
+Struct OverloadObjectDef::RegisteredMethod
+==========================================
+
+- Defined in :ref:`file_tvm_ffi_reflection_overload.h`
+
+
+Nested Relationships
+--------------------
+
+This struct is a nested type of :ref:`exhale_class_classtvm_1_1ffi_1_1reflection_1_1OverloadObjectDef`.
+
+
+Struct Documentation
+--------------------
+
+
+.. doxygenstruct:: tvm::ffi::reflection::OverloadObjectDef::RegisteredMethod
+ :project: tvm-ffi
+ :members:
+ :protected-members:
+ :undoc-members:
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/typedef_object_8h_1a7ba296d84188e5970ba854332a1f04a6.rst b/ffi/_sources/reference/cpp/generated/typedef_type__traits_8h_1a7ba296d84188e5970ba854332a1f04a6.rst
similarity index 51%
rename from ffi/_sources/reference/cpp/generated/typedef_object_8h_1a7ba296d84188e5970ba854332a1f04a6.rst
rename to ffi/_sources/reference/cpp/generated/typedef_type__traits_8h_1a7ba296d84188e5970ba854332a1f04a6.rst
index 8453e9c8180..256be723e62 100644
--- a/ffi/_sources/reference/cpp/generated/typedef_object_8h_1a7ba296d84188e5970ba854332a1f04a6.rst
+++ b/ffi/_sources/reference/cpp/generated/typedef_type__traits_8h_1a7ba296d84188e5970ba854332a1f04a6.rst
@@ -1,9 +1,9 @@
-.. _exhale_typedef_object_8h_1a7ba296d84188e5970ba854332a1f04a6:
+.. _exhale_typedef_type__traits_8h_1a7ba296d84188e5970ba854332a1f04a6:
Typedef tvm::ffi::TypeIndex
===========================
-- Defined in :ref:`file_tvm_ffi_object.h`
+- Defined in :ref:`file_tvm_ffi_type_traits.h`
Typedef Documentation
diff --git a/ffi/_sources/reference/cpp/generated/typedef_object_8h_1ae125f5f5a8a94c7340577c1959805295.rst b/ffi/_sources/reference/cpp/generated/typedef_type__traits_8h_1ae125f5f5a8a94c7340577c1959805295.rst
similarity index 50%
rename from ffi/_sources/reference/cpp/generated/typedef_object_8h_1ae125f5f5a8a94c7340577c1959805295.rst
rename to ffi/_sources/reference/cpp/generated/typedef_type__traits_8h_1ae125f5f5a8a94c7340577c1959805295.rst
index 97ec3389b15..e2e08e51f89 100644
--- a/ffi/_sources/reference/cpp/generated/typedef_object_8h_1ae125f5f5a8a94c7340577c1959805295.rst
+++ b/ffi/_sources/reference/cpp/generated/typedef_type__traits_8h_1ae125f5f5a8a94c7340577c1959805295.rst
@@ -1,9 +1,9 @@
-.. _exhale_typedef_object_8h_1ae125f5f5a8a94c7340577c1959805295:
+.. _exhale_typedef_type__traits_8h_1ae125f5f5a8a94c7340577c1959805295:
Typedef tvm::ffi::TypeInfo
==========================
-- Defined in :ref:`file_tvm_ffi_object.h`
+- Defined in :ref:`file_tvm_ffi_type_traits.h`
Typedef Documentation
diff --git a/ffi/_sources/reference/cpp/generated/unabridged_orphan.rst b/ffi/_sources/reference/cpp/generated/unabridged_orphan.rst
index 6a8220f5dc1..e53e07975d0 100644
--- a/ffi/_sources/reference/cpp/generated/unabridged_orphan.rst
+++ b/ffi/_sources/reference/cpp/generated/unabridged_orphan.rst
@@ -117,6 +117,11 @@ Files
file_tvm_ffi_extra_dataclass.h.rst
+.. toctree::
+ :maxdepth: 5
+
+ file_tvm_ffi_device.h.rst
+
.. toctree::
:maxdepth: 5
diff --git a/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a2235b3faf38b1017a13ef6178d9a8fa8.rst b/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a2235b3faf38b1017a13ef6178d9a8fa8.rst
deleted file mode 100644
index c0f5593917d..00000000000
--- a/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a2235b3faf38b1017a13ef6178d9a8fa8.rst
+++ /dev/null
@@ -1,14 +0,0 @@
-.. _exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a2235b3faf38b1017a13ef6178d9a8fa8:
-
-Variable tvm::ffi::reflection::type_attr::kEnumValueEntries
-===========================================================
-
-- Defined in :ref:`file_tvm_ffi_reflection_accessor.h`
-
-
-Variable Documentation
-----------------------
-
-
-.. doxygenvariable:: tvm::ffi::reflection::type_attr::kEnumValueEntries
- :project: tvm-ffi
\ No newline at end of file
diff --git a/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a73b8599796f9364537b3ac1091e6ca5a.rst b/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a877b4867a278823be18e6c7f7bff378e.rst
similarity index 55%
rename from ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a73b8599796f9364537b3ac1091e6ca5a.rst
rename to ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a877b4867a278823be18e6c7f7bff378e.rst
index 27d5bc18556..5e60b56f9c4 100644
--- a/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a73b8599796f9364537b3ac1091e6ca5a.rst
+++ b/ffi/_sources/reference/cpp/generated/variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a877b4867a278823be18e6c7f7bff378e.rst
@@ -1,6 +1,6 @@
-.. _exhale_variable_namespacetvm_1_1ffi_1_1reflection_1_1type__attr_1a73b8599796f9364537b3ac1091e6ca5a:
... 44820 lines suppressed ...