From f14e7ac44fe471c6e203a0ddf6b7801e0eaa45b9 Mon Sep 17 00:00:00 2001 From: libing4752 Date: Mon, 5 Feb 2018 01:07:30 +0800 Subject: [PATCH] enhance pragma to support single point copy (#863) * modified schedule_dataflow_rewrite.cc to fix losing tensor problem * modified schedule_dataflow_rewrite.cc for lint scan * modified schedule_dataflow_rewrite.cc for lint scan * using tensor's value_index to index output of stage op * repare address offset for different kinds of dtype * bc * aaa * aaaaa * repare address for different dtypes * remove nonsense files * add whitespace of line 581 * use base alloc elem_type * enhance the testcast of basic buffer is 64bits,32bits,16bits,8bits * use extends[0]->type() as dtype of offset * clear program writes * enhance inject_copy_intin to support of pragma stmt with no loops * fix cpplint errors * fix cpplint error of ! * enhance detectLinearEquation to support with no loop vars * fix cpplint errors --- src/arithmetic/detect_linear_equation.cc | 31 ++++++++++--------- src/pass/inject_copy_intrin.cc | 26 +++++++++++----- .../unittest/test_pass_inject_copy_intrin.py | 20 ++++++++++++ 3 files changed, 55 insertions(+), 22 deletions(-) diff --git a/src/arithmetic/detect_linear_equation.cc b/src/arithmetic/detect_linear_equation.cc index 63f582160312..642a866866d2 100644 --- a/src/arithmetic/detect_linear_equation.cc +++ b/src/arithmetic/detect_linear_equation.cc @@ -123,25 +123,28 @@ class LinearEqDetector }; Array DetectLinearEquation(const Expr& e, const Array& vars) { - CHECK_GE(vars.size(), 1U); Expr base = e; Array coeff; - for (Var v : vars) { - LinearEqEntry ret; - if (!LinearEqDetector(v).Detect(base, &ret)) { - return Array(); + if (0 == vars.size()) { + coeff.push_back(make_const(Int(32), 1)); + } else { + for (Var v : vars) { + LinearEqEntry ret; + if (!LinearEqDetector(v).Detect(base, &ret)) { + return Array(); + } + coeff.push_back(ret.coeff); + base = std::move(ret.base); } - coeff.push_back(ret.coeff); - base = std::move(ret.base); - } - std::unordered_set vset; - for (size_t i = vars.size(); i != 1; --i) { - vset.insert(vars[i - 1].get()); - // The previous coeff contains the variable - if (ExprUseVar(coeff[i - 2], vset)) { - return Array(); + std::unordered_set vset; + for (size_t i = vars.size(); i != 1; --i) { + vset.insert(vars[i - 1].get()); + // The previous coeff contains the variable + if (ExprUseVar(coeff[i - 2], vset)) { + return Array(); + } } } coeff.push_back(base); diff --git a/src/pass/inject_copy_intrin.cc b/src/pass/inject_copy_intrin.cc index cafcddcb9dde..ba44253a0cd5 100644 --- a/src/pass/inject_copy_intrin.cc +++ b/src/pass/inject_copy_intrin.cc @@ -40,6 +40,7 @@ class CopyIntrinInjector : public IRMutator { private: bool MatchCopyPattern(Stmt stmt, Stmt *out) { Stmt body = stmt; + bool is_single_point_copy = false; // strip the loops std::vector loops; @@ -53,7 +54,10 @@ class CopyIntrinInjector : public IRMutator { const Select* select = store->value.as