Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3rdparty/tvm-ffi
Submodule tvm-ffi updated 155 files
6 changes: 6 additions & 0 deletions include/tvm/ir/name_supply.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ class NameSupplyNode : public Object {
std::string prefix_;

static constexpr const bool _type_mutable = true;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<NameSupplyNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("ir.NameSupply", NameSupplyNode, Object);

private:
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/meta_schedule/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ class PyDatabaseNode : public DatabaseNode {
// `f_query_schedule` is not registered
// `f_query_ir_module` is not registered
// `f_size` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PyDatabaseNode>();
}

bool HasWorkload(const IRModule& mod) final {
Expand Down
5 changes: 4 additions & 1 deletion include/tvm/meta_schedule/feature_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class FeatureExtractorNode : public runtime::Object {
virtual ~FeatureExtractorNode() = default;

static void RegisterReflection() {
// No fields to register
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<FeatureExtractorNode>();
}

/*!
Expand Down Expand Up @@ -79,6 +80,8 @@ class PyFeatureExtractorNode : public FeatureExtractorNode {
static void RegisterReflection() {
// `f_extract_from` is not registered
// `f_as_string` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PyFeatureExtractorNode>();
}

ffi::Array<tvm::runtime::Tensor> ExtractFrom(
Expand Down
5 changes: 4 additions & 1 deletion include/tvm/meta_schedule/measure_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class MeasureCallbackNode : public runtime::Object {
virtual ~MeasureCallbackNode() = default;

static void RegisterReflection() {
// No fields to register
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<MeasureCallbackNode>();
}

/*!
Expand Down Expand Up @@ -95,6 +96,8 @@ class PyMeasureCallbackNode : public MeasureCallbackNode {
static void RegisterReflection() {
// `f_apply` is not registered
// `f_as_string` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PyMeasureCallbackNode>();
}

void Apply(const TaskScheduler& task_scheduler, //
Expand Down
3 changes: 2 additions & 1 deletion include/tvm/meta_schedule/mutator.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class MutatorNode : public runtime::Object {
virtual ~MutatorNode() = default;

static void RegisterReflection() {
// No fields to register
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<MutatorNode>();
}

/*!
Expand Down
5 changes: 4 additions & 1 deletion include/tvm/meta_schedule/postproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class PostprocNode : public runtime::Object {
virtual ~PostprocNode() = default;

static void RegisterReflection() {
// No fields to register
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PostprocNode>();
}

/*!
Expand Down Expand Up @@ -199,6 +200,8 @@ class PyPostprocNode : public PostprocNode {
// `f_apply` is not registered
// `f_clone` is not registered
// `f_as_string` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PyPostprocNode>();
}

void InitializeWithTuneContext(const TuneContext& context) final;
Expand Down
4 changes: 2 additions & 2 deletions include/tvm/meta_schedule/profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class ProfilerNode : public runtime::Object {
ffi::Function total_timer;

static void RegisterReflection() {
// `stats_sec` is not registered
// `total_timer` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<ProfilerNode>();
}

static constexpr const bool _type_mutable = true;
Expand Down
9 changes: 9 additions & 0 deletions include/tvm/meta_schedule/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class RunnerFutureNode : public runtime::Object {
static void RegisterReflection() {
// `f_done` is not registered
// `f_result` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RunnerFutureNode>();
}

/*!
Expand Down Expand Up @@ -189,6 +191,11 @@ class RunnerNode : public runtime::Object {
*/
virtual ffi::Array<RunnerFuture> Run(ffi::Array<RunnerInput> runner_inputs) = 0;

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RunnerNode>();
}

static constexpr const bool _type_mutable = true;
TVM_FFI_DECLARE_OBJECT_INFO("meta_schedule.Runner", RunnerNode, runtime::Object);
};
Expand Down Expand Up @@ -222,6 +229,8 @@ class PyRunnerNode : public RunnerNode {

static void RegisterReflection() {
// `f_run` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PyRunnerNode>();
}

ffi::Array<RunnerFuture> Run(ffi::Array<RunnerInput> runner_inputs) final {
Expand Down
5 changes: 4 additions & 1 deletion include/tvm/meta_schedule/schedule_rule.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ScheduleRuleNode : public runtime::Object {
virtual ~ScheduleRuleNode() = default;

static void RegisterReflection() {
// No fields to register
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<ScheduleRuleNode>();
}

/*!
Expand Down Expand Up @@ -337,6 +338,8 @@ class PyScheduleRuleNode : public ScheduleRuleNode {
// `f_apply` is not registered
// `f_as_string` is not registered
// `f_clone` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PyScheduleRuleNode>();
}

void InitializeWithTuneContext(const TuneContext& context) final;
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/meta_schedule/search_strategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ class PySearchStrategyNode : public SearchStrategyNode {
// `f_generate_measure_candidates` is not registered
// `f_notify_runner_results` is not registered
// `f_clone` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PySearchStrategyNode>();
}

void InitializeWithTuneContext(const TuneContext& context) final;
Expand Down
2 changes: 2 additions & 0 deletions include/tvm/meta_schedule/space_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class PySpaceGeneratorNode : public SpaceGeneratorNode {
// `f_initialize_with_tune_context` is not registered
// `f_generate_design_space` is not registered
// `f_clone` is not registered
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<PySpaceGeneratorNode>();
}

void InitializeWithTuneContext(const TuneContext& context) final;
Expand Down
10 changes: 9 additions & 1 deletion include/tvm/relax/nested_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ struct TypeTraits<relax::NestedMsg<T>> : public TypeTraitsBase {
}

TVM_FFI_INLINE static relax::NestedMsg<T> MoveFromAnyAfterCheck(TVMFFIAny* src) {
return relax::NestedMsg<T>(details::AnyUnsafe::MoveTVMFFIAnyToAny(std::move(*src)));
return relax::NestedMsg<T>(details::AnyUnsafe::MoveTVMFFIAnyToAny(src));
}

static std::optional<relax::NestedMsg<T>> TryCastFromAnyView(const TVMFFIAny* src) {
Expand Down Expand Up @@ -673,6 +673,14 @@ struct TypeTraits<relax::NestedMsg<T>> : public TypeTraitsBase {
TVM_FFI_INLINE static std::string TypeStr() {
return "NestedMsg<" + details::Type2Str<T>::v() + ">";
}

TVM_FFI_INLINE static std::string TypeSchema() {
std::ostringstream oss;
oss << R"({"type":"NestedMsg","args":[)";
oss << details::TypeSchema<T>::v();
oss << "]}";
return oss.str();
}
};
} // namespace ffi
} // namespace tvm
Expand Down
4 changes: 4 additions & 0 deletions include/tvm/runtime/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,10 @@ struct TypeTraits<runtime::DataType> : public TypeTraitsBase {
}

TVM_FFI_INLINE static std::string TypeStr() { return ffi::StaticTypeKey::kTVMFFIDataType; }

TVM_FFI_INLINE static std::string TypeSchema() {
return R"({"type":")" + std::string(ffi::StaticTypeKey::kTVMFFIDataType) + R"("})";
}
};

} // namespace ffi
Expand Down
1 change: 1 addition & 0 deletions include/tvm/runtime/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Tensor : public tvm::ffi::Tensor {
static Tensor FromDLPackVersioned(DLManagedTensorVersioned* tensor) {
return tvm::ffi::Tensor::FromDLPackVersioned(tensor, kAllocAlignment, true);
}
inline const DLTensor* operator->() const { return this->get(); }
/*!
* \brief Copy data content from another array.
* \param other The source array to be copied from.
Expand Down
3 changes: 2 additions & 1 deletion include/tvm/tir/block_scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ class BlockScopeNode : public Object {
std::unordered_map<Buffer, ffi::Array<StmtSRef>, ObjectPtrHash, ObjectPtrEqual> buffer_writers;

static void RegisterReflection() {
// No fields to register as they are not visited
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<BlockScopeNode>();
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tir.BlockScope", BlockScopeNode, Object);

Expand Down
6 changes: 4 additions & 2 deletions include/tvm/tir/schedule/schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ enum class BufferIndexType : int32_t {
class BlockRVNode : public runtime::Object {
public:
static void RegisterReflection() {
// No fields to register as they are not visited
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<BlockRVNode>();
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tir.BlockRV", BlockRVNode, runtime::Object);
};
Expand All @@ -73,7 +74,8 @@ class BlockRV : public runtime::ObjectRef {
class LoopRVNode : public runtime::Object {
public:
static void RegisterReflection() {
// No fields to register as they are not visited
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<LoopRVNode>();
}
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("tir.LoopRV", LoopRVNode, runtime::Object);
};
Expand Down
3 changes: 3 additions & 0 deletions python/tvm/testing/_ffi_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"""FFI APIs for tvm.testing"""
import tvm_ffi

# must import testing before init_ffi_api
import tvm_ffi.testing


tvm_ffi.init_ffi_api("testing", __name__)
1 change: 1 addition & 0 deletions src/arith/presburger_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ PresburgerSet MakePresburgerSet(const PrimExpr& constraint) { return PresburgerS

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
PresburgerSetNode::RegisterReflection();
refl::GlobalDef().def("arith.PresburgerSet", MakePresburgerSet);
}

Expand Down
1 change: 1 addition & 0 deletions src/ir/name_supply.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ std::string NameSupplyNode::GetUniqueName(std::string name, bool add_underscore)

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
NameSupplyNode::RegisterReflection();
refl::GlobalDef()
.def("ir.NameSupply", [](ffi::String prefix) { return NameSupply(prefix); })
.def_method("ir.NameSupply_FreshName", &NameSupplyNode::FreshName)
Expand Down
7 changes: 7 additions & 0 deletions src/meta_schedule/measure_callback/add_to_database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ class AddToDatabaseNode : public MeasureCallbackNode {
/*args_info=*/candidate->args_info));
}
}

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<AddToDatabaseNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.AddToDatabase", AddToDatabaseNode,
MeasureCallbackNode);
};
Expand All @@ -67,6 +73,7 @@ MeasureCallback MeasureCallback::AddToDatabase() {

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<AddToDatabaseNode>();
refl::GlobalDef().def("meta_schedule.MeasureCallbackAddToDatabase",
MeasureCallback::AddToDatabase);
}
Expand Down
7 changes: 7 additions & 0 deletions src/meta_schedule/measure_callback/remove_build_artifact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class RemoveBuildArtifactNode : public MeasureCallbackNode {
}
}
}

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RemoveBuildArtifactNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.RemoveBuildArtifact", RemoveBuildArtifactNode,
MeasureCallbackNode);
};
Expand All @@ -48,6 +54,7 @@ MeasureCallback MeasureCallback::RemoveBuildArtifact() {

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
RemoveBuildArtifactNode::RegisterReflection();
refl::GlobalDef().def("meta_schedule.MeasureCallbackRemoveBuildArtifact",
MeasureCallback::RemoveBuildArtifact);
}
Expand Down
7 changes: 7 additions & 0 deletions src/meta_schedule/measure_callback/update_cost_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class UpdateCostModelNode : public MeasureCallbackNode {
}
cost_model->Update(task->ctx, pruned_candidate, pruned_runner_result);
}

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<UpdateCostModelNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.UpdateCostModel", UpdateCostModelNode,
MeasureCallbackNode);
};
Expand All @@ -65,6 +71,7 @@ MeasureCallback MeasureCallback::UpdateCostModel() {

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
UpdateCostModelNode::RegisterReflection();
refl::GlobalDef().def("meta_schedule.MeasureCallbackUpdateCostModel",
MeasureCallback::UpdateCostModel);
}
Expand Down
7 changes: 7 additions & 0 deletions src/meta_schedule/postproc/disallow_async_strided_mem_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ class DisallowAsyncStridedMemCopyNode : public PostprocNode {
ffi::make_object<DisallowAsyncStridedMemCopyNode>(*this);
return Postproc(n);
}

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<DisallowAsyncStridedMemCopyNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.DisallowAsyncStridedMemCopy",
DisallowAsyncStridedMemCopyNode, PostprocNode);

Expand All @@ -188,6 +194,7 @@ Postproc Postproc::DisallowAsyncStridedMemCopy() {

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
DisallowAsyncStridedMemCopyNode::RegisterReflection();
refl::GlobalDef().def("meta_schedule.PostprocDisallowAsyncStridedMemCopy",
Postproc::DisallowAsyncStridedMemCopy);
}
Expand Down
7 changes: 7 additions & 0 deletions src/meta_schedule/postproc/disallow_dynamic_loop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class DisallowDynamicLoopNode : public PostprocNode {
ObjectPtr<DisallowDynamicLoopNode> n = ffi::make_object<DisallowDynamicLoopNode>(*this);
return Postproc(n);
}

static void RegisterReflection() {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<DisallowDynamicLoopNode>();
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.DisallowDynamicLoop", DisallowDynamicLoopNode,
PostprocNode);
};
Expand All @@ -85,6 +91,7 @@ Postproc Postproc::DisallowDynamicLoop() {

TVM_FFI_STATIC_INIT_BLOCK() {
namespace refl = tvm::ffi::reflection;
DisallowDynamicLoopNode::RegisterReflection();
refl::GlobalDef().def("meta_schedule.PostprocDisallowDynamicLoop", Postproc::DisallowDynamicLoop);
}

Expand Down
1 change: 1 addition & 0 deletions src/meta_schedule/postproc/rewrite_cooperative_fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class RewriteCooperativeFetchNode : public PostprocNode {
ObjectPtr<RewriteCooperativeFetchNode> n = ffi::make_object<RewriteCooperativeFetchNode>(*this);
return Postproc(n);
}

TVM_FFI_DECLARE_OBJECT_INFO_FINAL("meta_schedule.RewriteCooperativeFetch",
RewriteCooperativeFetchNode, PostprocNode);

Expand Down
Loading
Loading