Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dynamic Shape] Use SizeVar instead of Var when convert Any in the GetShape function #8555

Merged
merged 3 commits into from
Jul 30, 2021
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
3 changes: 3 additions & 0 deletions include/tvm/tir/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,9 @@ class AnyNode : public PrimExprNode {
/*! \brief Convert to var. */
Var ToVar() const { return Var("any_dim", DataType::Int(32)); }

/*! \brief Convert to SizeVar. */
SizeVar ToSizeVar() const { return SizeVar("any_dim", DataType::Int(32)); }

static constexpr const char* _type_key = "tir.Any";
TVM_DECLARE_FINAL_OBJECT_INFO(AnyNode, PrimExprNode);
};
Expand Down
3 changes: 2 additions & 1 deletion src/relay/backend/te_compiler_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ Array<IndexExpr> GetShape(const Array<IndexExpr>& shape) {
res.push_back(val);
#endif // TVM_INDEX_DEFAULT_I64
} else if (val->IsInstance<tir::AnyNode>()) {
res.push_back(val.as<tir::AnyNode>()->ToVar());
// currently all 'any' we meet in shape function are non-negative.
res.push_back(val.as<tir::AnyNode>()->ToSizeVar());
} else {
res.push_back(val);
}
Expand Down