[LANG] Support for Tuple Inputs of Reducer and ComputeOp#175
[LANG] Support for Tuple Inputs of Reducer and ComputeOp#175ZihengJiang merged 16 commits intoapache:masterfrom ZihengJiang:dev
Conversation
|
|
||
| /*! \brief whether two array have the same content */ | ||
| template<typename T> | ||
| bool IsSame(const Array<T>& a, const Array<T>& b) { |
| n->reduce_axis = n->body.as<ir::Reduce>()->axis; | ||
| if (n->body[0]->is_type<ir::Reduce>()) { | ||
| // batch reduction should have the same axis | ||
| n->reduce_axis = n->body[0].as<ir::Reduce>()->axis; |
| CHECK_EQ(self.operator->(), this); | ||
| Expr new_body = op::ReplaceTensor(this->body, rmap); | ||
| if (!new_body.same_as(this->body)) { | ||
| Array<Expr> new_body = ReplaceTensor(this->body, rmap); |
There was a problem hiding this comment.
Try to do it simply in a for loop, check the way we do it ir mutator
There was a problem hiding this comment.
Maybe we can add a Array<NodeRef> UpdateArray(Array<NodeRef> arr, std::function<NodeRef(NodeRef)> fupdate) function?
|
|
||
| if (IsCrossThreadReduction(this, stage)) { | ||
| LOG(INFO) << stage; | ||
| // specially handle cross thread reduction. |
| namespace ir { | ||
|
|
||
| template<typename T> | ||
| inline Array<T> UpdateArray(Array<T> arr, std::function<T(T)> fupdate) { |
There was a problem hiding this comment.
simply use F fupdate, use a template argument for fupdate
| } else { | ||
| return Array<Expr>(new_arr); | ||
| } | ||
| std::function<Expr(Expr)> fupdate = [m] (Expr e) { return m->Mutate(e); }; |
There was a problem hiding this comment.
auto fupdate, std::function and lambda are different, lambda is more specialized and can trigger inline
| if (!is_one(reduce->condition)) { | ||
| *provide = IfThenElse::make(reduce->condition, *provide); | ||
| for (size_t i = 0; i < size; ++i) { | ||
| provides->at(i) = IfThenElse::make(reduce->condition, provides->at(i)); |
There was a problem hiding this comment.
can we have one common condition for all the bodies?
| size_t size = self->body.size(); | ||
| CHECK_GT(size, 0); | ||
| std::vector<const Reduce*> reduces(size); | ||
| for (size_t i = 0; i < size; ++i) { |
There was a problem hiding this comment.
if we assume common reduce, vector is not necessary?
There was a problem hiding this comment.
reduces is used for type
| /*! | ||
| * \brief update array with an unary function | ||
| * \param arr array | ||
| * \param fupdate an unary function |
There was a problem hiding this comment.
add \tparam to document the template argument
|
|
||
| std::unordered_set<const Variable*> reduce_set; | ||
| for (size_t i = 2; i < call->args.size(); ++i) { | ||
| for (size_t i = 2+2*size; i < call->args.size(); ++i) { |
| } | ||
| } else if (op.as<ComputeOpNode>()) { | ||
| std::unordered_map<const Node*, TensorDimKey> vmap; | ||
| std::unordered_map<const Node*, std::vector<TensorDimKey>> vmap; |
There was a problem hiding this comment.
for compatiblity of older compiler
| reduce_stage->leaf_iter_vars = reduce_stage->all_iter_vars; | ||
| reduce_stage->relations = Array<IterVarRelation>(); | ||
| return factor_tensor; | ||
| return factor_tensors[0]; |
There was a problem hiding this comment.
We need to return array of Exprs?
| Array<IterVar> rdom, | ||
| Expr condition = const_true()); | ||
| Expr condition = const_true(), | ||
| int value_index = 0); |
There was a problem hiding this comment.
remove the default value, to be safe
| where = convert(True) | ||
| if size == 1: | ||
| return _make.Reduce(combiner, expr, axis, where, 0) | ||
| return [_make.Reduce(combiner, expr, axis, where, i) |
| Returns | ||
| ------- | ||
| tfactor : Tensor | ||
| tfactor : Tensor or Array<Tensor> |
| CHECK(axis[i].defined()); | ||
| } | ||
| n->type = source.type(); | ||
| n->type = source[value_index].type(); |
There was a problem hiding this comment.
if argument is passing by value, do std::move to save copy constructor
| return outputs; | ||
| } | ||
|
|
||
| bool CheckReduce(const ir::Reduce* a, const ir::Reduce* b) { |
| Var res_handle("reduce_temp", Handle()); | ||
| Array<Expr> freduce_args; | ||
| freduce_args.push_back(reduce->source); | ||
| freduce_args.push_back(make_const(UInt(32), size)); |
There was a problem hiding this comment.
let us update comment in the intrinsic def to clarify the new convention
| body = AttrStmt::make( | ||
| res_handle, attr::storage_scope, StringImm::make("local"), body); | ||
| Stmt body = Block::make(reduce_body, assign_body); | ||
| for (int idx = size - 1; idx >= 0; --idx) { |
There was a problem hiding this comment.
keep revserse iteration style consistent
for (i = size; i !=0; --i)
This avoid certain case when reverse iteration is unsigned
| Type type, | ||
| Var shared_buf, | ||
| const std::vector<Type>& types, | ||
| Array<Var> shared_bufs, |
There was a problem hiding this comment.
if we don't copy the value, pass by const ref
| """ | ||
| return _api_internal._ScheduleRFactor(self, tensor, axis) | ||
| factored = _api_internal._ScheduleRFactor(self, tensor, axis) | ||
| if len(factored) == 1: |
There was a problem hiding this comment.
return factored[0] if len(factored) == 1 else factored
* fix for composed symbol * fix * clean up * fix exception type
* fix for composed symbol * fix * clean up * fix exception type
* fix for composed symbol * fix * clean up * fix exception type
* fix for composed symbol * fix * clean up * fix exception type
…e#14523) (apache#175) This PR enhances CanProve to handle symbolic bound. Such analysis is essential to eliminate predicates in dynamic shape workloads. We also the int set analysis singlepoint check to avoid recursion and improve the overall analysis speed. Added CanProveSinglePoint to serve previous stronger checks. The new CanProve comes with additinal strength argument that can only be used in top-level setting with stronger analysis. Added comment for future implementation efficiency. Testcases are added to cover the cases. Co-authored-by: Tianqi Chen <tqchen@users.noreply.github.com>
…e#14523) (apache#175) This PR enhances CanProve to handle symbolic bound. Such analysis is essential to eliminate predicates in dynamic shape workloads. We also the int set analysis singlepoint check to avoid recursion and improve the overall analysis speed. Added CanProveSinglePoint to serve previous stronger checks. The new CanProve comes with additinal strength argument that can only be used in top-level setting with stronger analysis. Added comment for future implementation efficiency. Testcases are added to cover the cases. Co-authored-by: Tianqi Chen <tqchen@users.noreply.github.com>
…ache#175) Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v3...v4.1.7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Upstream : https://github.com/apache/tvm-ffi.git Branch : main New HEAD : e10d1ed7c2e3b69847348effd4ed9d310a300af8 Subject : doc: Migrate `.pyi` docstrings into Cython (apache#175) Author : Junru Shao <junrushao@apache.org> Date : 2025-10-20T07:14:34-07:00 Delta : 1 commit(s) since 0729193f475c Compare : apache/tvm-ffi@0729193...e10d1ed This commit updates the tvm-ffi submodule to the latest upstream HEAD.
Upstream : https://github.com/apache/tvm-ffi.git Branch : main New HEAD : e10d1ed7c2e3b69847348effd4ed9d310a300af8 Subject : doc: Migrate `.pyi` docstrings into Cython (apache#175) Author : Junru Shao <junrushao@apache.org> Date : 2025-10-20T07:14:34-07:00 Delta : 1 commit(s) since 0729193f475c Compare : apache/tvm-ffi@0729193...e10d1ed This commit updates the tvm-ffi submodule to the latest upstream HEAD.
#173