This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new d8a4e6d1a2 [FFI] Bring up latest tvm-ffi (#18802)
d8a4e6d1a2 is described below
commit d8a4e6d1a2330c81b0e1a08dbc14b62ee4c480e4
Author: Tianqi Chen <[email protected]>
AuthorDate: Fri Feb 20 11:10:03 2026 -0500
[FFI] Bring up latest tvm-ffi (#18802)
This PR brings up tvm-ffi dependency to latest
---
3rdparty/tvm-ffi | 2 +-
include/tvm/ir/config_schema.h | 21 ++++++++++++++-------
src/runtime/profiling.cc | 4 ++--
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/3rdparty/tvm-ffi b/3rdparty/tvm-ffi
index c78e8b4eef..35cbc3274c 160000
--- a/3rdparty/tvm-ffi
+++ b/3rdparty/tvm-ffi
@@ -1 +1 @@
-Subproject commit c78e8b4eefa076c457af97bd3930dd664aec71c3
+Subproject commit 35cbc3274cf4b02d8d2e34d2510be5b34d0046ea
diff --git a/include/tvm/ir/config_schema.h b/include/tvm/ir/config_schema.h
index 9720206b1d..7131d8e617 100644
--- a/include/tvm/ir/config_schema.h
+++ b/include/tvm/ir/config_schema.h
@@ -63,9 +63,11 @@ class ConfigSchema {
ffi::String type_str;
/*! \brief Per-option validator/coercer (Any -> Any). */
ffi::TypedFunction<ffi::Any(ffi::Any)> validator;
- /*! \brief Whether this option has a default value. */
+ /*! \brief Whether this option has a default value or factory. */
bool has_default = false;
- /*! \brief Default value (valid when has_default is true). */
+ /*! \brief Whether the default is produced by a factory function. */
+ bool default_from_factory = false;
+ /*! \brief Default value, or factory function () -> Any when
default_from_factory is true. */
ffi::Any default_value;
};
@@ -126,7 +128,11 @@ class ConfigSchema {
if (it != config.end()) {
result.Set(e.key, e.validator((*it).second));
} else if (e.has_default) {
- result.Set(e.key, e.default_value);
+ if (e.default_from_factory) {
+ result.Set(e.key, e.default_value.cast<ffi::Function>()());
+ } else {
+ result.Set(e.key, e.default_value);
+ }
}
// else: missing non-required option, stays absent
}
@@ -205,15 +211,16 @@ class ConfigSchema {
// reflection traits (notably refl::DefaultValue) are reused unchanged.
ffi::reflection::FieldInfoBuilder info{};
info.flags = 0;
- info.default_value = ffi::AnyView(nullptr).CopyToTVMFFIAny();
+ info.default_value_or_factory = ffi::AnyView(nullptr).CopyToTVMFFIAny();
info.doc = TVMFFIByteArray{nullptr, 0};
(ApplyTrait(&e, &info, std::forward<Traits>(traits)), ...);
if (info.flags & kTVMFFIFieldFlagBitMaskHasDefault) {
e.has_default = true;
- e.default_value = ffi::AnyView::CopyFromTVMFFIAny(info.default_value);
+ e.default_from_factory = (info.flags &
kTVMFFIFieldFlagBitMaskDefaultFromFactory) != 0;
+ e.default_value =
ffi::AnyView::CopyFromTVMFFIAny(info.default_value_or_factory);
// Release the extra ref created by CopyToTVMFFIAny in Apply
- if (info.default_value.type_index >=
TVMFFITypeIndex::kTVMFFIStaticObjectBegin) {
-
ffi::details::ObjectUnsafe::DecRefObjectHandle(info.default_value.v_obj);
+ if (info.default_value_or_factory.type_index >=
TVMFFITypeIndex::kTVMFFIStaticObjectBegin) {
+
ffi::details::ObjectUnsafe::DecRefObjectHandle(info.default_value_or_factory.v_obj);
}
}
return e;
diff --git a/src/runtime/profiling.cc b/src/runtime/profiling.cc
index 5409989d3b..91e2a3f7eb 100644
--- a/src/runtime/profiling.cc
+++ b/src/runtime/profiling.cc
@@ -478,7 +478,7 @@ ffi::String ReportNode::AsTable(bool sort, bool aggregate,
bool compute_col_sums
if (aggregate) {
std::unordered_map<std::string, std::vector<size_t>> aggregates;
for (size_t i = 0; i < calls.size(); i++) {
- auto& frame = calls[i];
+ auto frame = calls[i];
auto it = frame.find("Hash");
std::string name = frame["Name"].cast<ffi::String>();
if (it != frame.end()) {
@@ -508,7 +508,7 @@ ffi::String ReportNode::AsTable(bool sort, bool aggregate,
bool compute_col_sums
for (const std::string& metric : metrics) {
std::vector<ffi::Any> per_call;
for (auto i : p.second) {
- auto& call = calls[i];
+ auto call = calls[i];
auto it = std::find_if(call.begin(), call.end(),
[&metric](const std::pair<ffi::String,
ffi::Any>& call_metric) {
return std::string(call_metric.first) ==
metric;