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
9 changes: 0 additions & 9 deletions docs/arch/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,6 @@ Each ``Object`` subclass will override this to register its members. Here is an
refl::ObjectDef<IntImmNode>().def_ro("value", &IntImmNode::value);
}

bool SEqualReduce(const IntImmNode* other, SEqualReducer equal) const {
return equal(dtype, other->dtype) && equal(value, other->value);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(dtype);
hash_reduce(value);
}

static constexpr const char* _type_key = "ir.IntImm";
TVM_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode);
};
Expand Down
4 changes: 0 additions & 4 deletions ffi/include/tvm/ffi/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@ class Object {
static constexpr int32_t _type_depth = 0;
// the structural equality and hash kind of the type
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindUnsupported;
// extra fields used by plug-ins for attribute visiting
// and structural information
static constexpr const bool _type_has_method_sequal_reduce = false;
static constexpr const bool _type_has_method_shash_reduce = false;
// The following functions are provided by macro
// TVM_FFI_DECLARE_BASE_OBJECT_INFO and TVM_DECLARE_FINAL_OBJECT_INFO
/*!
Expand Down
2 changes: 0 additions & 2 deletions ffi/tests/cpp/testing_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,9 @@ class TCustomFuncObj : public Object {
bool SEqual(const TCustomFuncObj* other,
ffi::TypedFunction<bool(AnyView, AnyView, bool, AnyView)> cmp) const {
if (!cmp(params, other->params, true, "params")) {
std::cout << "custom s_equal failed params" << std::endl;
return false;
}
if (!cmp(body, other->body, false, "body")) {
std::cout << "custom s_equal failed body" << std::endl;
return false;
}
return true;
Expand Down
8 changes: 0 additions & 8 deletions include/tvm/arith/analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ class ConstIntBoundNode : public Object {
.def_ro("max_value", &ConstIntBoundNode::max_value);
}

bool SEqualReduce(const ConstIntBoundNode* other, SEqualReducer equal) const {
return equal(min_value, other->min_value) && equal(max_value, other->max_value);
}

/*! \brief Number to represent +inf */
static const constexpr int64_t kPosInf = std::numeric_limits<int64_t>::max();
/*!
Expand Down Expand Up @@ -219,10 +215,6 @@ class ModularSetNode : public Object {
.def_ro("base", &ModularSetNode::base);
}

bool SEqualReduce(const ModularSetNode* other, SEqualReducer equal) const {
return equal(coeff, other->coeff) && equal(base, other->base);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const char* _type_key = "arith.ModularSet";
TVM_DECLARE_FINAL_OBJECT_INFO(ModularSetNode, Object);
Expand Down
2 changes: 1 addition & 1 deletion include/tvm/arith/int_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ enum SignType { kPositive, kNegative, kZero, kUnknown };
class IntSetNode : public Object {
public:
static constexpr const char* _type_key = "ir.IntSet";
static constexpr bool _type_has_method_sequal_reduce = false;

TVM_DECLARE_BASE_OBJECT_INFO(IntSetNode, Object);
};

Expand Down
41 changes: 3 additions & 38 deletions include/tvm/arith/int_solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,8 @@ class IntGroupBoundsNode : public Object {
.def_ro("upper", &IntGroupBoundsNode::upper);
}

bool SEqualReduce(const IntGroupBoundsNode* other, SEqualReducer eq) const {
return eq(coef, other->coef) && eq(lower, other->lower) && eq(equal, other->equal) &&
eq(upper, other->upper);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(coef);
hash_reduce(lower);
hash_reduce(equal);
hash_reduce(upper);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const bool _type_has_method_sequal_reduce = true;

static constexpr const char* _type_key = "arith.IntGroupBounds";
TVM_DECLARE_FINAL_OBJECT_INFO(IntGroupBoundsNode, Object);
};
Expand Down Expand Up @@ -163,19 +151,8 @@ class IntConstraintsNode : public Object {
.def_ro("relations", &IntConstraintsNode::relations);
}

bool SEqualReduce(const IntConstraintsNode* other, SEqualReducer equal) const {
return equal(variables, other->variables) && equal(ranges, other->ranges) &&
equal(relations, other->relations);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(variables);
hash_reduce(ranges);
hash_reduce(relations);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const bool _type_has_method_sequal_reduce = true;

static constexpr const char* _type_key = "arith.IntConstraints";
TVM_DECLARE_FINAL_OBJECT_INFO(IntConstraintsNode, Object);
};
Expand Down Expand Up @@ -228,20 +205,8 @@ class IntConstraintsTransformNode : public Object {
.def_ro("dst_to_src", &IntConstraintsTransformNode::dst_to_src);
}

bool SEqualReduce(const IntConstraintsTransformNode* other, SEqualReducer equal) const {
return equal(src, other->src) && equal(dst, other->dst) &&
equal(src_to_dst, other->src_to_dst) && equal(dst_to_src, other->dst_to_src);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(src);
hash_reduce(dst);
hash_reduce(src_to_dst);
hash_reduce(dst_to_src);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const bool _type_has_method_sequal_reduce = true;

static constexpr const char* _type_key = "arith.IntConstraintsTransform";
TVM_DECLARE_FINAL_OBJECT_INFO(IntConstraintsTransformNode, Object);
};
Expand Down
35 changes: 1 addition & 34 deletions include/tvm/arith/iter_affine_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,8 @@ class IterMarkNode : public Object {
.def_ro("extent", &IterMarkNode::extent);
}

bool SEqualReduce(const IterMarkNode* other, SEqualReducer equal) const {
equal->MarkGraphNode();
return equal(source, other->source) && equal(extent, other->extent);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce->MarkGraphNode();
hash_reduce(source);
hash_reduce(extent);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindDAGNode;
static constexpr const bool _type_has_method_sequal_reduce = true;
static constexpr const bool _type_has_method_shash_reduce = true;

static constexpr const char* _type_key = "arith.IterMark";
TVM_DECLARE_FINAL_OBJECT_INFO(IterMarkNode, Object);
};
Expand Down Expand Up @@ -165,18 +153,6 @@ class IterSplitExprNode : public IterMapExprNode {
.def_ro("scale", &IterSplitExprNode::scale);
}

bool SEqualReduce(const IterSplitExprNode* other, SEqualReducer equal) const {
return equal(source, other->source) && equal(lower_factor, other->lower_factor) &&
equal(extent, other->extent) && equal(scale, other->scale);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(source);
hash_reduce(lower_factor);
hash_reduce(extent);
hash_reduce(scale);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const char* _type_key = "arith.IterSplitExpr";
TVM_DECLARE_FINAL_OBJECT_INFO(IterSplitExprNode, IterMapExprNode);
Expand Down Expand Up @@ -232,15 +208,6 @@ class IterSumExprNode : public IterMapExprNode {
.def_ro("base", &IterSumExprNode::base);
}

bool SEqualReduce(const IterSumExprNode* other, SEqualReducer equal) const {
return equal(args, other->args) && equal(base, other->base);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(args);
hash_reduce(base);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const char* _type_key = "arith.IterSumExpr";
TVM_DECLARE_FINAL_OBJECT_INFO(IterSumExprNode, IterMapExprNode);
Expand Down
37 changes: 2 additions & 35 deletions include/tvm/ir/attrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ class AttrFieldInfoNode : public Object {

static constexpr const char* _type_key = "ir.AttrFieldInfo";
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr bool _type_has_method_sequal_reduce = false;
static constexpr bool _type_has_method_shash_reduce = false;

TVM_DECLARE_FINAL_OBJECT_INFO(AttrFieldInfoNode, Object);
};

Expand Down Expand Up @@ -123,8 +122,7 @@ class BaseAttrsNode : public Object {
bool allow_unknown = false) = 0;

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const bool _type_has_method_sequal_reduce = true;
static constexpr const bool _type_has_method_shash_reduce = true;

static constexpr const char* _type_key = "ir.Attrs";
TVM_DECLARE_BASE_OBJECT_INFO(BaseAttrsNode, Object);
};
Expand Down Expand Up @@ -154,11 +152,6 @@ class DictAttrsNode : public BaseAttrsNode {
rfl::ObjectDef<DictAttrsNode>().def_ro("__dict__", &DictAttrsNode::dict);
}

bool SEqualReduce(const DictAttrsNode* other, SEqualReducer equal) const {
return equal(dict, other->dict);
}

void SHashReduce(SHashReducer hash_reduce) const { hash_reduce(dict); }
void InitByPackedArgs(const ffi::PackedArgs& args, bool allow_unknown) final;

// type info
Expand Down Expand Up @@ -394,32 +387,6 @@ class AttrsNodeReflAdapter : public BaseAttrsNode {
LOG(FATAL) << "`" << DerivedType::_type_key << "` uses new reflection mechanism for init";
}

bool SEqualReduce(const DerivedType* other, SEqualReducer equal) const {
const TVMFFITypeInfo* type_info = TVMFFIGetTypeInfo(DerivedType::RuntimeTypeIndex());
bool success = true;
ffi::reflection::ForEachFieldInfoWithEarlyStop(
type_info, [&](const TVMFFIFieldInfo* field_info) {
ffi::reflection::FieldGetter field_getter(field_info);
ffi::Any field_value = field_getter(self());
ffi::Any other_field_value = field_getter(other);
if (!equal.AnyEqual(field_value, other_field_value)) {
success = false;
return true;
}
return false;
});
return success;
}

void SHashReduce(SHashReducer hash_reducer) const {
const TVMFFITypeInfo* type_info = TVMFFIGetTypeInfo(DerivedType::RuntimeTypeIndex());
ffi::reflection::ForEachFieldInfo(type_info, [&](const TVMFFIFieldInfo* field_info) {
ffi::reflection::FieldGetter field_getter(field_info);
ffi::Any field_value = field_getter(self());
hash_reducer(field_value);
});
}

private:
DerivedType* self() const {
return const_cast<DerivedType*>(static_cast<const DerivedType*>(this));
Expand Down
9 changes: 0 additions & 9 deletions include/tvm/ir/diagnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ class DiagnosticNode : public Object {
.def_ro("message", &DiagnosticNode::message);
}

bool SEqualReduce(const DiagnosticNode* other, SEqualReducer equal) const {
return equal(this->level, other->level) && equal(this->span, other->span) &&
equal(this->message, other->message);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const char* _type_key = "Diagnostic";
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticNode, Object);
Expand Down Expand Up @@ -211,10 +206,6 @@ class DiagnosticContextNode : public Object {
.def_ro("diagnostics", &DiagnosticContextNode::diagnostics);
}

bool SEqualReduce(const DiagnosticContextNode* other, SEqualReducer equal) const {
return equal(module, other->module) && equal(diagnostics, other->diagnostics);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const char* _type_key = "DiagnosticContext";
TVM_DECLARE_FINAL_OBJECT_INFO(DiagnosticContextNode, Object);
Expand Down
13 changes: 1 addition & 12 deletions include/tvm/ir/env_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,9 @@ class EnvFuncNode : public Object {
.def_ro("func", &EnvFuncNode::func, refl::AttachFieldFlag::SEqHashIgnore());
}

bool SEqualReduce(const EnvFuncNode* other, SEqualReducer equal) const {
// name uniquely identifies the env function.
return name == other->name;
}

void SHashReduce(SHashReducer hash_reduce) const {
// Name uniquely identifies the env function.
hash_reduce(name);
}

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const char* _type_key = "ir.EnvFunc";
static constexpr bool _type_has_method_sequal_reduce = true;
static constexpr bool _type_has_method_shash_reduce = true;

TVM_DECLARE_FINAL_OBJECT_INFO(EnvFuncNode, Object);
};

Expand Down
46 changes: 4 additions & 42 deletions include/tvm/ir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ class BaseExprNode : public Object {
static constexpr const char* _type_key = "ir.BaseExpr";

static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const bool _type_has_method_sequal_reduce = true;
static constexpr const bool _type_has_method_shash_reduce = true;

static constexpr const uint32_t _type_child_slots = 64;
TVM_DECLARE_BASE_OBJECT_INFO(BaseExprNode, Object);
};
Expand Down Expand Up @@ -468,16 +467,6 @@ class GlobalVarNode : public RelaxExprNode {
refl::ObjectDef<GlobalVarNode>().def_ro("name_hint", &GlobalVarNode::name_hint);
}

bool SEqualReduce(const GlobalVarNode* other, SEqualReducer equal) const {
// name matters for global var.
return equal(name_hint, other->name_hint) && equal.FreeVarEqualImpl(this, other);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(name_hint);
hash_reduce.FreeVarHashImpl(this);
}

bool SEqual(const GlobalVarNode* other,
ffi::TypedFunction<bool(AnyView, AnyView, bool, AnyView)> equal) const {
return equal(name_hint, other->name_hint, false, "name_hint");
Expand Down Expand Up @@ -519,15 +508,6 @@ class IntImmNode : public PrimExprNode {
refl::ObjectDef<IntImmNode>().def_ro("value", &IntImmNode::value);
}

bool SEqualReduce(const IntImmNode* other, SEqualReducer equal) const {
return equal(dtype, other->dtype) && equal(value, other->value);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(dtype);
hash_reduce(value);
}

static constexpr const char* _type_key = "ir.IntImm";
TVM_DECLARE_FINAL_OBJECT_INFO(IntImmNode, PrimExprNode);
};
Expand Down Expand Up @@ -565,15 +545,6 @@ class FloatImmNode : public PrimExprNode {
refl::ObjectDef<FloatImmNode>().def_ro("value", &FloatImmNode::value);
}

bool SEqualReduce(const FloatImmNode* other, SEqualReducer equal) const {
return equal(dtype, other->dtype) && equal(value, other->value);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(dtype);
hash_reduce(value);
}

static constexpr const char* _type_key = "ir.FloatImm";
TVM_DECLARE_FINAL_OBJECT_INFO(FloatImmNode, PrimExprNode);
};
Expand Down Expand Up @@ -713,22 +684,13 @@ class RangeNode : public Object {
namespace refl = tvm::ffi::reflection;
refl::ObjectDef<RangeNode>()
.def_ro("min", &RangeNode::min)
.def_ro("extent", &RangeNode::extent);
}

bool SEqualReduce(const RangeNode* other, SEqualReducer equal) const {
return equal(min, other->min) && equal(extent, other->extent);
}

void SHashReduce(SHashReducer hash_reduce) const {
hash_reduce(min);
hash_reduce(extent);
.def_ro("extent", &RangeNode::extent)
.def_ro("span", &RangeNode::span, refl::AttachFieldFlag::SEqHashIgnore());
}

static constexpr const char* _type_key = "ir.Range";
static constexpr TVMFFISEqHashKind _type_s_eq_hash_kind = kTVMFFISEqHashKindTreeNode;
static constexpr const bool _type_has_method_sequal_reduce = true;
static constexpr const bool _type_has_method_shash_reduce = true;

TVM_DECLARE_FINAL_OBJECT_INFO(RangeNode, Object);
};

Expand Down
Loading
Loading