[REFACTOR][ARITH] Unified IR, introduce arith subfolder. (#4722)
authorTianqi Chen <tqchen@users.noreply.github.com>
Thu, 16 Jan 2020 18:27:16 +0000 (10:27 -0800)
committerGitHub <noreply@github.com>
Thu, 16 Jan 2020 18:27:16 +0000 (10:27 -0800)
Spread the arithmetic.h into several components and move
into arith subfolder.

The arith namespace will be used for arithmetic expression
pattern detections and simplifications.

63 files changed:
CMakeLists.txt
include/tvm/arith/analyzer.h [moved from include/tvm/arithmetic.h with 55% similarity]
include/tvm/arith/bound.h [new file with mode: 0644]
include/tvm/arith/int_set.h [new file with mode: 0644]
include/tvm/arith/pattern.h [new file with mode: 0644]
include/tvm/build_module.h
include/tvm/operation.h
include/tvm/tensor.h
src/README.md
src/api/api_arith.cc
src/arith/analyzer.cc [moved from src/arithmetic/analyzer.cc with 98% similarity]
src/arith/bound_deducer.cc [moved from src/arithmetic/bound_deducer.cc with 99% similarity]
src/arith/canonical_simplify.cc [moved from src/arithmetic/canonical_simplify.cc with 99% similarity]
src/arith/compute_expr.h [moved from src/arithmetic/compute_expr.h with 96% similarity]
src/arith/const_fold.h [moved from src/arithmetic/const_fold.h with 99% similarity]
src/arith/const_int_bound.cc [moved from src/arithmetic/const_int_bound.cc with 99% similarity]
src/arith/detect_linear_equation.cc [moved from src/arithmetic/detect_linear_equation.cc with 99% similarity]
src/arith/domain_touched.cc [moved from src/arithmetic/domain_touched.cc with 100% similarity]
src/arith/int_operator.h [moved from src/arithmetic/int_operator.h with 97% similarity]
src/arith/int_set.cc [moved from src/arithmetic/int_set.cc with 99% similarity]
src/arith/interval_set.h [moved from src/arithmetic/int_set.h with 96% similarity]
src/arith/ir_mutator_with_analyzer.cc [moved from src/arithmetic/ir_mutator_with_analyzer.cc with 99% similarity]
src/arith/ir_mutator_with_analyzer.h [moved from src/arithmetic/ir_mutator_with_analyzer.h with 92% similarity]
src/arith/ir_visitor_with_analyzer.h [moved from src/arithmetic/ir_visitor_with_analyzer.h with 92% similarity]
src/arith/modular_set.cc [moved from src/arithmetic/modular_set.cc with 99% similarity]
src/arith/pattern_match.h [moved from src/arithmetic/pattern_match.h with 99% similarity]
src/arith/rewrite_simplify.cc [moved from src/arithmetic/rewrite_simplify.cc with 99% similarity]
src/arith/rewrite_simplify.h [moved from src/arithmetic/rewrite_simplify.h with 96% similarity]
src/arith/stmt_simplify.cc [moved from src/arithmetic/stmt_simplify.cc with 98% similarity]
src/codegen/codegen_c.cc
src/codegen/llvm/codegen_llvm.cc
src/codegen/llvm/codegen_llvm.h
src/codegen/spirv/codegen_spirv.cc
src/codegen/spirv/codegen_spirv.h
src/lang/buffer.cc
src/lang/expr_operator.cc
src/op/compute_op.cc
src/op/extern_op.cc
src/op/hybrid_op.cc
src/op/op_util.cc
src/op/tensor_compute_op.cc
src/pass/arg_binder.cc
src/pass/hoist_if_then_else.cc
src/pass/inject_copy_intrin.cc
src/pass/inject_double_buffer.cc
src/pass/inject_prefetch.cc
src/pass/inject_virtual_thread.cc
src/pass/loop_partition.cc
src/pass/lower_intrin.cc
src/pass/lower_thread_allreduce.cc
src/pass/lower_tvm_builtin.cc
src/pass/lower_warp_memory.cc
src/pass/storage_access.cc
src/pass/storage_flatten.cc
src/pass/storage_rewrite.cc
src/pass/tensor_core.cc
src/pass/unroll_loop.cc
src/pass/vectorize_loop.cc
src/relay/op/tensor/transform.cc
src/schedule/message_passing.cc
src/schedule/message_passing.h
src/schedule/schedule_dataflow_rewrite.cc
tests/cpp/pattern_match_test.cc

index 825da5a..f48e7d1 100644 (file)
@@ -129,7 +129,7 @@ file(GLOB COMPILER_SRCS
     src/ir/*.cc
     src/target/*.cc
     src/api/*.cc
-    src/arithmetic/*.cc
+    src/arith/*.cc
     src/autotvm/*.cc
     src/codegen/*.cc
     src/lang/*.cc
similarity index 55%
rename from include/tvm/arithmetic.h
rename to include/tvm/arith/analyzer.h
index a7b1233..78f1285 100644 (file)
  */
 
 /*!
- * \file tvm/arithmetic.h
- * \brief Algebra and set operations and simplifications.
+ * \file tvm/arith/analyzer.h
+ * \brief Algebra expression simplifications.
  */
-#ifndef TVM_ARITHMETIC_H_
-#define TVM_ARITHMETIC_H_
+#ifndef TVM_ARITH_ANALYZER_H_
+#define TVM_ARITH_ANALYZER_H_
 
 #include <tvm/support/with.h>
+#include <tvm/ir/expr.h>
+#include <tvm/arith/int_set.h>
 
 #include <vector>
 #include <unordered_map>
 #include <memory>
 #include <limits>
-#include "expr.h"
 
 namespace tvm {
-// forward delcare Tensor
-class Tensor;
-/*! \brief namespace of arithmetic */
+/*! \brief namespace of arithmetic analysis. */
 namespace arith {
 //-------------------------------------------------------
 // Base integer analysis API.
@@ -332,113 +331,6 @@ class ConstraintContext {
   std::function<void()> exit_;
 };
 
-//-----------------------------------------------
-// Integer set data structure.
-//
-// This is a API build on top of the base
-// integer analysis API to provide set analysis.
-//------------------------------------------------
-/*!
- * \brief Sign type of an integer expression.
- */
-enum SignType {
-  kPositive,
-  kNegative,
-  kZero,
-  kUnknown
-};
-
-/*!
- * \brief Base class of all IntSet containers.
- */
-struct IntSetNode : public Object {
-  static constexpr const char* _type_key = "IntSet";
-  TVM_DECLARE_BASE_OBJECT_INFO(IntSetNode, Object);
-};
-
-/*!
- * \brief Integer set class, represent a set of integers in one dimension.
- */
-class IntSet : public ObjectRef {
- public:
-  /*! \brief constructor */
-  IntSet() {}
-  // constructor from not container.
-  explicit IntSet(ObjectPtr<Object> n) : ObjectRef(n) {}
-  /*!
-   * \brief access the internal node container
-   * \return the pointer to the internal node container
-   */
-  inline const IntSetNode* operator->() const;
-  /*!
-   * \brief Find a range that covers the region.
-   * \param max_range The range to be covered.
-   * \return The covering range.
-   */
-  Range cover_range(Range max_range) const;
-  /*! \return Lower bound of the set */
-  PrimExpr min() const;
-  /*! \return upper bound of the set */
-  PrimExpr max() const;
-  /*! \return Whether the set represent nothing  */
-  bool is_nothing() const;
-  /*! \return Whether the set represent everything  */
-  bool is_everything() const;
-  /*! \return Whether the set is a single point */
-  bool is_single_point() const;
-  /*! \return Whether the set is proved to be bigger than 0 */
-  bool can_prove_positive() const;
-  /*! \return Whether the set is proved to be smaller than 0 */
-  bool can_prove_negative() const;
-  /*! \return Whether the set is proved to be smaller than or equal to 0 */
-  bool can_prove_non_positive() const;
-  /*! \return Whether the set is proved to be larger than or equal to 0 */
-  bool can_prove_non_negative() const;
-  /*! \return The sign of the elements in the integer set */
-  SignType sign_type() const;
-  /*!
-   * \brief The single point value, call only if is_single_point is true
-   * \return The point value.
-   */
-  PrimExpr point_value() const;
-  /*!
-   * \brief Try to match IntSet with range r.
-   *
-   * \note It is guanrateed that IntSet::range(r).match_range(r) == true
-   * \return true if we can prove they are the same.
-   */
-  bool match_range(const Range& r) const;
-  /*! \return The set contains nothing */
-  static IntSet nothing();
-  /*! \return The set contains everything */
-  static IntSet everything();
-  /*!
-   * \brief construct a point set.
-   * \param point The point in the set.
-   * \return construct a single point set
-   */
-  static IntSet single_point(PrimExpr point);
-  /*!
-   * \brief construct a integer set from vector expression.
-   * \param vec The vector expression, can also be single point.
-   * \return The result set containing the indices in the vector.
-   */
-  static IntSet vector(PrimExpr vec);
-  /*!
-   * \brief Construct a set representing a range.
-   * \param r The range
-   * \return constructed set.
-   */
-  static IntSet range(Range r);
-  /*!
-   * \brief Construct a set representing a interval.
-   * \param min The minimum value of the interval.
-   * \param max The maximum value of the interval.
-   * \return constructed set.
-   */
-  static IntSet interval(PrimExpr min, PrimExpr max);
-};
-
 /*!
  * \brief Integer set analyzer.
  */
@@ -545,157 +437,6 @@ class Analyzer {
   PrimExpr Simplify(const PrimExpr& expr);
 };
 
-//-----------------------------------------------
-// Integer set legacy API.
-//------------------------------------------------
-/*!
- * \brief Find an symbolic integer set that contains all possible values of
- *  e given the domain of each iteration variables.
- *
- * \param e The expression to be evaluated.
- * \param dom_map The domain of each variable.
- * \return An integer set that can cover all the possible values of e.
- */
-IntSet EvalSet(PrimExpr e,
-               const Map<IterVar, IntSet>& dom_map);
-/*!
- * \brief Same as EvalSet, but takes unordered_map
- *
- * \param e The expression to be evaluated.
- * \param dom_map The domain of each variable.
- * \return An integer set that can cover all the possible values of e.
- */
-IntSet EvalSet(PrimExpr e,
-               const std::unordered_map<const VarNode*, IntSet>& dom_map);
-
-/*!
- * \brief Find an symbolic integer set that contains is union over
- *  all the possible conditional values in dom_map.
- *
- * \param r The initial range.
- * \param dom_map The domain of each variable.
- * \return An integer set that can cover all the possible values.
- */
-IntSet EvalSet(Range r,
-               const Map<IterVar, IntSet>& dom_map);
-
-/*!
- * \brief Find an symbolic integer set that contains is union over
- *  all the possible conditional values in dom_map.
- *
- * \param s The initial set.
- * \param dom_map The domain of each variable.
- * \return An integer set that can cover all the possible values.
- */
-IntSet EvalSet(IntSet s,
-               const std::unordered_map<const VarNode*, IntSet>& dom_map);
-/*!
- * \brief Same as EvalSet, but takes unordered_map
- *
- * \param r The range to be evaluated.
- * \param dom_map The domain of each variable.
- * \return An integer set that can cover all the possible values of e.
- */
-IntSet EvalSet(Range r,
-               const std::unordered_map<const VarNode*, IntSet>& dom_map);
-
-/*! \brief Map from Expr to IntSet */
-using ExprIntSetMap = std::unordered_map<PrimExpr, IntSet, ObjectHash, ObjectEqual>;
-/*!
- * \brief Find the integer set of every sub-expression, given the
- *  domain of each iteration variables.
- *
- * \param e The expression to be evaluated.
- * \param dom_map The domain of each variable.
- * \return the map from the expression to its possible value.
- */
-ExprIntSetMap EvalSetForEachSubExpr(
-    PrimExpr e,
-    const std::unordered_map<const VarNode*, IntSet>& dom_map);
-
-/*!
- * \brief Create an union set of all sets
- * \param sets The sets to be unioned
- * \return the set after union
- */
-IntSet Union(const Array<IntSet>& sets);
-
-/*!
- * \brief Create an union set of all sets
- * \param sets The sets to be intersected
- * \return the set after intersected
- */
-IntSet Intersect(const Array<IntSet>& sets);
-
-/*!
- * \brief Deduce the bound of the target variable in a expression,
- *  give the domain of each variables. Return undefined IntSet to
- *  represent failure.
- *
- * \note The returned set may be smaller than set that
- *       contains all possible values of v that satisfies the bound.
- *
- * \param v The target variable to be deduced.
- * \param cond The conditional expression.
- * \param hint_map The domain of variable, used to help deduce.
- * \param relax_map The domain of each variable, used to relax the domain,
- *        The deduce bound must implies e for all value in relax_map
- * \return An integer set that always satisfies the condition.
- */
-IntSet DeduceBound(PrimExpr v, PrimExpr cond,
-                   const Map<Var, IntSet>& hint_map,
-                   const Map<Var, IntSet>& relax_map);
-/*!
- * \brief Same as DeduceBound with  unordered_map signature.
- *
- * \param v The target variable to be deduced.
- * \param cond The conditional expression.
- * \param hint_map The domain of variable, used to help deduce.
- * \param relax_map The domain of each variable, used to relax the domain,
- *        The deduce bound mush implies e for all value in relax_map
- * \return An integer set that always satisfies the condition.
- */
-IntSet DeduceBound(PrimExpr v, PrimExpr cond,
-                   const std::unordered_map<const VarNode*, IntSet>& hint_map,
-                   const std::unordered_map<const VarNode*, IntSet>& relax_map);
-
-/*!
- * \brief Infer a regular domain that covers all the calls or provides within the given statement.
- * \param body The given statement.
- * \param tensor The name of the calls or provides.
- * \param consider_calls If calls (read) are considered.
- * \param consider_provides If provides (write) are considered.
- * \return The domain that covers all the calls or provides within the given statement.
- */
-Domain DomainTouched(Stmt body, const Tensor &tensor, bool consider_calls, bool consider_provides);
-
-// Expression pattern detector.
-/*!
- * \brief Detect if e can be rewritten as e = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n]
- *  Where coeff[i] and base are invariant of var[j] for all i and j.
- *
- * \param e The expression to be detected.
- * \param vars List of variables to be used in detection.
- * \return [coeff[i]] if it is possible, empty array if it is not.
- */
-Array<PrimExpr> DetectLinearEquation(const PrimExpr& e,
-                                 const Array<Var>& vars);
-
-/*!
- * \brief Detect if expression corresponds to clip bound of the vars
- *
- * \param e The expression to be detected.
- * \param vars List of variables to be used in detection.
- * \return concat([min_value[i], max_value[i]]), None is returned if there is no min or max value
- *          return empty if the e does not match the pattern.
- */
-Array<PrimExpr> DetectClipBound(const PrimExpr& e,
-                            const Array<Var>& vars);
-
-// implementation
-inline const IntSetNode* IntSet::operator->() const {
-  return static_cast<const IntSetNode*>(get());
-}
 }  // namespace arith
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_H_
+#endif  // TVM_ARITH_ANALYZER_H_
diff --git a/include/tvm/arith/bound.h b/include/tvm/arith/bound.h
new file mode 100644 (file)
index 0000000..73c0733
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*!
+ * \file tvm/arith/bound.h
+ * \brief Bound deducers.
+ */
+#ifndef TVM_ARITH_BOUND_H_
+#define TVM_ARITH_BOUND_H_
+
+#include <tvm/node/container.h>
+#include <tvm/ir/expr.h>
+#include <tvm/arith/int_set.h>
+#include <tvm/expr.h>
+
+#include <unordered_map>
+
+namespace tvm {
+// forward delcare Tensor
+class Tensor;
+namespace arith {
+
+/*!
+ * \brief Deduce the bound of the target variable in a expression,
+ *  give the domain of each variables. Return undefined IntSet to
+ *  represent failure.
+ *
+ * \note The returned set may be smaller than set that
+ *       contains all possible values of v that satisfies the bound.
+ *
+ * \param v The target variable to be deduced.
+ * \param cond The conditional expression.
+ * \param hint_map The domain of variable, used to help deduce.
+ * \param relax_map The domain of each variable, used to relax the domain,
+ *        The deduce bound must implies e for all value in relax_map
+ * \return An integer set that always satisfies the condition.
+ */
+IntSet DeduceBound(PrimExpr v, PrimExpr cond,
+                   const Map<Var, IntSet>& hint_map,
+                   const Map<Var, IntSet>& relax_map);
+/*!
+ * \brief Same as DeduceBound with  unordered_map signature.
+ *
+ * \param v The target variable to be deduced.
+ * \param cond The conditional expression.
+ * \param hint_map The domain of variable, used to help deduce.
+ * \param relax_map The domain of each variable, used to relax the domain,
+ *        The deduce bound mush implies e for all value in relax_map
+ * \return An integer set that always satisfies the condition.
+ */
+IntSet DeduceBound(PrimExpr v, PrimExpr cond,
+                   const std::unordered_map<const VarNode*, IntSet>& hint_map,
+                   const std::unordered_map<const VarNode*, IntSet>& relax_map);
+
+/*!
+ * \brief Infer a regular domain that covers all the calls or provides within the given statement.
+ * \param body The given statement.
+ * \param tensor The name of the calls or provides.
+ * \param consider_calls If calls (read) are considered.
+ * \param consider_provides If provides (write) are considered.
+ * \return The domain that covers all the calls or provides within the given statement.
+ */
+Domain DomainTouched(Stmt body, const Tensor &tensor, bool consider_calls, bool consider_provides);
+
+}  // namespace arith
+}  // namespace tvm
+#endif  // TVM_ARITH_BOUND_H_
diff --git a/include/tvm/arith/int_set.h b/include/tvm/arith/int_set.h
new file mode 100644 (file)
index 0000000..ca06cfd
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/arith/int_set.h
+ * \brief Integer set
+ */
+#ifndef TVM_ARITH_INT_SET_H_
+#define TVM_ARITH_INT_SET_H_
+
+#include <tvm/ir/expr.h>
+#include <tvm/expr.h>
+#include <unordered_map>
+
+namespace tvm {
+namespace arith {
+
+//-----------------------------------------------
+// Integer set data structure.
+//
+// This is a API build on top of the base
+// integer analysis API to provide set analysis.
+//------------------------------------------------
+/*!
+ * \brief Sign type of an integer expression.
+ */
+enum SignType {
+  kPositive,
+  kNegative,
+  kZero,
+  kUnknown
+};
+
+/*!
+ * \brief Base class of all Integer set containers.
+ *        represent a set of integers in one dimension.
+ * \sa IntSet
+ */
+class IntSetNode : public Object {
+ public:
+  static constexpr const char* _type_key = "IntSet";
+  TVM_DECLARE_BASE_OBJECT_INFO(IntSetNode, Object);
+};
+
+/*!
+ * \brief Managed reference to IntSetNode.
+ * \sa IntSetNode
+ */
+class IntSet : public ObjectRef {
+ public:
+  /*! \brief constructor */
+  IntSet() {}
+  // constructor from not container.
+  explicit IntSet(ObjectPtr<Object> n) : ObjectRef(n) {}
+  /*!
+   * \brief access the internal node container
+   * \return the pointer to the internal node container
+   */
+  const IntSetNode* operator->() const {
+    return static_cast<const IntSetNode*>(get());
+  }
+  /*!
+   * \brief Find a range that covers the region.
+   * \param max_range The range to be covered.
+   * \return The covering range.
+   */
+  Range cover_range(Range max_range) const;
+  /*! \return Lower bound of the set */
+  PrimExpr min() const;
+  /*! \return upper bound of the set */
+  PrimExpr max() const;
+  /*! \return Whether the set represent nothing  */
+  bool is_nothing() const;
+  /*! \return Whether the set represent everything  */
+  bool is_everything() const;
+  /*! \return Whether the set is a single point */
+  bool is_single_point() const;
+  /*! \return Whether the set is proved to be bigger than 0 */
+  bool can_prove_positive() const;
+  /*! \return Whether the set is proved to be smaller than 0 */
+  bool can_prove_negative() const;
+  /*! \return Whether the set is proved to be smaller than or equal to 0 */
+  bool can_prove_non_positive() const;
+  /*! \return Whether the set is proved to be larger than or equal to 0 */
+  bool can_prove_non_negative() const;
+  /*! \return The sign of the elements in the integer set */
+  SignType sign_type() const;
+  /*!
+   * \brief The single point value, call only if is_single_point is true
+   * \return The point value.
+   */
+  PrimExpr point_value() const;
+  /*!
+   * \brief Try to match IntSet with range r.
+   *
+   * \note It is guanrateed that IntSet::range(r).match_range(r) == true
+   * \return true if we can prove they are the same.
+   */
+  bool match_range(const Range& r) const;
+  /*! \return The set contains nothing */
+  static IntSet nothing();
+  /*! \return The set contains everything */
+  static IntSet everything();
+  /*!
+   * \brief construct a point set.
+   * \param point The point in the set.
+   * \return construct a single point set
+   */
+  static IntSet single_point(PrimExpr point);
+  /*!
+   * \brief construct a integer set from vector expression.
+   * \param vec The vector expression, can also be single point.
+   * \return The result set containing the indices in the vector.
+   */
+  static IntSet vector(PrimExpr vec);
+  /*!
+   * \brief Construct a set representing a range.
+   * \param r The range
+   * \return constructed set.
+   */
+  static IntSet range(Range r);
+  /*!
+   * \brief Construct a set representing a interval.
+   * \param min The minimum value of the interval.
+   * \param max The maximum value of the interval.
+   * \return constructed set.
+   */
+  static IntSet interval(PrimExpr min, PrimExpr max);
+};
+
+//-----------------------------------------------
+// Integer set legacy API.
+//------------------------------------------------
+/*!
+ * \brief Find an symbolic integer set that contains all possible values of
+ *  e given the domain of each iteration variables.
+ *
+ * \param e The expression to be evaluated.
+ * \param dom_map The domain of each variable.
+ * \return An integer set that can cover all the possible values of e.
+ */
+IntSet EvalSet(PrimExpr e,
+               const Map<IterVar, IntSet>& dom_map);
+/*!
+ * \brief Same as EvalSet, but takes unordered_map
+ *
+ * \param e The expression to be evaluated.
+ * \param dom_map The domain of each variable.
+ * \return An integer set that can cover all the possible values of e.
+ */
+IntSet EvalSet(PrimExpr e,
+               const std::unordered_map<const VarNode*, IntSet>& dom_map);
+
+/*!
+ * \brief Find an symbolic integer set that contains is union over
+ *  all the possible conditional values in dom_map.
+ *
+ * \param r The initial range.
+ * \param dom_map The domain of each variable.
+ * \return An integer set that can cover all the possible values.
+ */
+IntSet EvalSet(Range r,
+               const Map<IterVar, IntSet>& dom_map);
+
+/*!
+ * \brief Find an symbolic integer set that contains is union over
+ *  all the possible conditional values in dom_map.
+ *
+ * \param s The initial set.
+ * \param dom_map The domain of each variable.
+ * \return An integer set that can cover all the possible values.
+ */
+IntSet EvalSet(IntSet s,
+               const std::unordered_map<const VarNode*, IntSet>& dom_map);
+/*!
+ * \brief Same as EvalSet, but takes unordered_map
+ *
+ * \param r The range to be evaluated.
+ * \param dom_map The domain of each variable.
+ * \return An integer set that can cover all the possible values of e.
+ */
+IntSet EvalSet(Range r,
+               const std::unordered_map<const VarNode*, IntSet>& dom_map);
+
+/*! \brief Map from Expr to IntSet */
+using ExprIntSetMap = std::unordered_map<PrimExpr, IntSet, ObjectHash, ObjectEqual>;
+/*!
+ * \brief Find the integer set of every sub-expression, given the
+ *  domain of each iteration variables.
+ *
+ * \param e The expression to be evaluated.
+ * \param dom_map The domain of each variable.
+ * \return the map from the expression to its possible value.
+ */
+ExprIntSetMap EvalSetForEachSubExpr(
+    PrimExpr e,
+    const std::unordered_map<const VarNode*, IntSet>& dom_map);
+
+/*!
+ * \brief Create an union set of all sets
+ * \param sets The sets to be unioned
+ * \return the set after union
+ */
+IntSet Union(const Array<IntSet>& sets);
+
+/*!
+ * \brief Create an union set of all sets
+ * \param sets The sets to be intersected
+ * \return the set after intersected
+ */
+IntSet Intersect(const Array<IntSet>& sets);
+
+}  // namespace arith
+}  // namespace tvm
+#endif  // TVM_ARITH_INT_SET_H_
diff --git a/include/tvm/arith/pattern.h b/include/tvm/arith/pattern.h
new file mode 100644 (file)
index 0000000..a531d30
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tvm/arith/pattern.h
+ * \brief Expression pattern detectors.
+ */
+#ifndef TVM_ARITH_PATTERN_H_
+#define TVM_ARITH_PATTERN_H_
+
+#include <tvm/node/container.h>
+#include <tvm/ir/expr.h>
+#include <tvm/expr.h>
+
+namespace tvm {
+namespace arith {
+/*!
+ * \brief Detect if e can be rewritten as e = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n]
+ *  Where coeff[i] and base are invariant of var[j] for all i and j.
+ *
+ * \param e The expression to be detected.
+ * \param vars List of variables to be used in detection.
+ * \return [coeff[i]] if it is possible, empty array if it is not.
+ */
+Array<PrimExpr> DetectLinearEquation(const PrimExpr& e,
+                                     const Array<Var>& vars);
+
+/*!
+ * \brief Detect if expression corresponds to clip bound of the vars
+ *
+ * \param e The expression to be detected.
+ * \param vars List of variables to be used in detection.
+ * \return concat([min_value[i], max_value[i]]), None is returned if there is no min or max value
+ *          return empty if the e does not match the pattern.
+ */
+Array<PrimExpr> DetectClipBound(const PrimExpr& e,
+                                const Array<Var>& vars);
+
+}  // namespace arith
+}  // namespace tvm
+#endif  // TVM_ARITH_PATTERN_H_
index 8919188..2990378 100644 (file)
@@ -25,7 +25,7 @@
 #define TVM_BUILD_MODULE_H_
 
 #include <tvm/target/target.h>
-
+#include <tvm/support/with.h>
 #include <string>
 #include <vector>
 #include <utility>
index 039e26e..54c98a3 100644 (file)
 #ifndef TVM_OPERATION_H_
 #define TVM_OPERATION_H_
 
+#include <tvm/arith/analyzer.h>
+
 #include <string>
 #include <vector>
 #include <unordered_map>
+
 #include "expr.h"
 #include "expr_operator.h"
 #include "tensor.h"
 #include "schedule.h"
-#include "arithmetic.h"
 #include "buffer.h"
 
 namespace tvm {
index 9962762..91c0c96 100644 (file)
@@ -25,6 +25,8 @@
 #define TVM_TENSOR_H_
 
 #include <tvm/node/container.h>
+#include <tvm/arith/bound.h>
+
 #include <string>
 #include <vector>
 #include <utility>
@@ -32,7 +34,6 @@
 
 #include "expr.h"
 #include "expr_operator.h"
-#include "arithmetic.h"
 
 namespace tvm {
 
index 6a7bf51..b0172b6 100644 (file)
@@ -26,7 +26,7 @@ There can be internal header files within each module that sit in src.
 - node: base infra for IR/AST nodes that is dialect independent.
 - api: API function registration.
 - lang: The definition of DSL related data structure.
-- arithmetic: Arithmetic expression and set simplification.
+- arith: Arithmetic expression and set simplification.
 - op: The detail implementations about each operation(compute, scan, placeholder).
 - schedule: The operations on the schedule graph before converting to IR.
 - pass: The optimization pass on the IR structure.
index 7150d27..b4020eb 100644 (file)
  *  Implementation of API functions related to arith
  * \file api_arith.cc
  */
+#include <tvm/arith/bound.h>
+#include <tvm/arith/int_set.h>
+#include <tvm/arith/pattern.h>
+#include <tvm/arith/analyzer.h>
+
 #include <tvm/expr.h>
 #include <tvm/ir.h>
 #include <tvm/runtime/registry.h>
similarity index 98%
rename from src/arithmetic/analyzer.cc
rename to src/arith/analyzer.cc
index e03e5e2..a36c409 100644 (file)
  */
 
 /*!
- * \file tvm/arithmetic/analyzer.cc
+ * \file tvm/arith/analyzer.cc
  */
 #include <tvm/ir.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
 
 namespace tvm {
similarity index 99%
rename from src/arithmetic/bound_deducer.cc
rename to src/arith/bound_deducer.cc
index 5128096..f1da23b 100644 (file)
 #include <tvm/expr.h>
 #include <tvm/ir_pass.h>
 #include <tvm/ir_functor_ext.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/runtime/registry.h>
 #include <tvm/packed_func_ext.h>
 
 
 #include <unordered_set>
 #include <unordered_map>
-#include "int_set.h"
+#include "interval_set.h"
 
 namespace tvm {
 namespace arith {
similarity index 99%
rename from src/arithmetic/canonical_simplify.cc
rename to src/arith/canonical_simplify.cc
index 90c6e48..b3cfc72 100644 (file)
@@ -21,7 +21,7 @@
  * \file canonical_simplify.cc
  * \brief Canonical form based simplification.
  */
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
 #include "const_fold.h"
 #include "pattern_match.h"
similarity index 96%
rename from src/arithmetic/compute_expr.h
rename to src/arith/compute_expr.h
index d78838f..b53543c 100644 (file)
@@ -21,8 +21,8 @@
  * \file compute_expr.h
  * \brief Utility to invoke certan compute operations.
  */
-#ifndef TVM_ARITHMETIC_COMPUTE_EXPR_H_
-#define TVM_ARITHMETIC_COMPUTE_EXPR_H_
+#ifndef TVM_ARITH_COMPUTE_EXPR_H_
+#define TVM_ARITH_COMPUTE_EXPR_H_
 
 #include <tvm/ir.h>
 #include <limits>
@@ -126,4 +126,4 @@ inline PrimExpr ComputeReduce(const Array<PrimExpr>& values, PrimExpr empty_valu
 
 }  // namespace arith
 }  // namespace tvm
-#endif   // TVM_ARITHMETIC_COMPUTE_EXPR_H_
+#endif   // TVM_ARITH_COMPUTE_EXPR_H_
similarity index 99%
rename from src/arithmetic/const_fold.h
rename to src/arith/const_fold.h
index d82ac89..0d8e2ab 100644 (file)
@@ -21,8 +21,8 @@
  * \file const_fold.h
  * \brief Centralized location for constant folding.
  */
-#ifndef TVM_ARITHMETIC_CONST_FOLD_H_
-#define TVM_ARITHMETIC_CONST_FOLD_H_
+#ifndef TVM_ARITH_CONST_FOLD_H_
+#define TVM_ARITH_CONST_FOLD_H_
 
 #include <tvm/ir.h>
 #include <tvm/expr_operator.h>
@@ -400,4 +400,4 @@ inline bool is_neg_inf(const PrimExpr& value) {
 
 }  // namespace arith
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_CONST_FOLD_H_
+#endif  // TVM_ARITH_CONST_FOLD_H_
similarity index 99%
rename from src/arithmetic/const_int_bound.cc
rename to src/arith/const_int_bound.cc
index c1cf1e0..460b9d9 100644 (file)
@@ -18,9 +18,9 @@
  */
 
 /*!
- * \file tvm/arithmetic/const_int_bound.cc
+ * \file tvm/arith/const_int_bound.cc
  */
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir_functor_ext.h>
 #include <algorithm>
 #include "int_operator.h"
similarity index 99%
rename from src/arithmetic/detect_linear_equation.cc
rename to src/arith/detect_linear_equation.cc
index 3de5557..81740a0 100644 (file)
@@ -24,7 +24,7 @@
 #include <tvm/expr.h>
 #include <tvm/ir_pass.h>
 #include <tvm/ir_functor_ext.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 
 namespace tvm {
 namespace arith {
similarity index 97%
rename from src/arithmetic/int_operator.h
rename to src/arith/int_operator.h
index fd51091..6e7f395 100644 (file)
@@ -21,8 +21,8 @@
  * \file int_operator.h
  * \brief Additional useful operators for integer.
  */
-#ifndef TVM_ARITHMETIC_INT_OPERATOR_H_
-#define TVM_ARITHMETIC_INT_OPERATOR_H_
+#ifndef TVM_ARITH_INT_OPERATOR_H_
+#define TVM_ARITH_INT_OPERATOR_H_
 
 #include <limits>
 
@@ -143,4 +143,4 @@ inline int64_t floormod(int64_t x, int64_t y) {
 
 }  // namespace arith
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_INT_OPERATOR_H_
+#endif  // TVM_ARITH_INT_OPERATOR_H_
similarity index 99%
rename from src/arithmetic/int_set.cc
rename to src/arith/int_set.cc
index 3ea6ee5..82f0d2b 100644 (file)
@@ -21,6 +21,7 @@
  * \file int_set.cc
  * \brief The integer set functions
  */
+#include <tvm/arith/int_set.h>
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/runtime/registry.h>
@@ -29,7 +30,7 @@
 #include <utility>
 #include <algorithm>
 #include <unordered_map>
-#include "int_set.h"
+#include "interval_set.h"
 #include "pattern_match.h"
 
 namespace tvm {
similarity index 96%
rename from src/arithmetic/int_set.h
rename to src/arith/interval_set.h
index b28f1cb..e931a7c 100644 (file)
  * \file int_set.h
  * \brief Internal data structure for integer set.
  */
-#ifndef TVM_ARITHMETIC_INT_SET_H_
-#define TVM_ARITHMETIC_INT_SET_H_
+#ifndef TVM_ARITH_INTERVAL_SET_H_
+#define TVM_ARITH_INTERVAL_SET_H_
 
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
 #include <limits>
 #include "const_fold.h"
@@ -141,4 +141,4 @@ TVM_DLL IntervalSet Intersect(Analyzer *analzyer, IntervalSet a, IntervalSet b);
 }  // namespace arith
 }  // namespace tvm
 
-#endif  // TVM_ARITHMETIC_INT_SET_H_
+#endif  // TVM_ARITH_INTERVAL_SET_H_
similarity index 99%
rename from src/arithmetic/ir_mutator_with_analyzer.cc
rename to src/arith/ir_mutator_with_analyzer.cc
index 1345e7e..7c1c30a 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 /*!
- * \file tvm/arithmetic/ir_mutator_with_analyzer.cc
+ * \file tvm/arith/ir_mutator_with_analyzer.cc
  */
 #include <tvm/ir_pass.h>
 #include <tvm/expr_operator.h>
similarity index 92%
rename from src/arithmetic/ir_mutator_with_analyzer.h
rename to src/arith/ir_mutator_with_analyzer.h
index a2297cb..10dc427 100644 (file)
  * \file tvm/arithmetic/ir_mutator_with_analyzer.h
  * \brief IR mutator base-class with an analyzer context.
  */
-#ifndef TVM_ARITHMETIC_IR_MUTATOR_WITH_ANALYZER_H_
-#define TVM_ARITHMETIC_IR_MUTATOR_WITH_ANALYZER_H_
+#ifndef TVM_ARITH_IR_MUTATOR_WITH_ANALYZER_H_
+#define TVM_ARITH_IR_MUTATOR_WITH_ANALYZER_H_
 
 #include <tvm/ir_functor_ext.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <utility>
 
 namespace tvm {
@@ -66,4 +66,4 @@ class IRMutatorWithAnalyzer : public ir::StmtExprMutator {
 
 }  // namespace arith
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_IR_MUTATOR_WITH_ANALYZER_H_
+#endif  // TVM_ARITH_IR_MUTATOR_WITH_ANALYZER_H_
similarity index 92%
rename from src/arithmetic/ir_visitor_with_analyzer.h
rename to src/arith/ir_visitor_with_analyzer.h
index 08be59b..8e5c0b1 100644 (file)
  * \brief IR visitor class with an analyzer context.
  */
 
-#ifndef TVM_ARITHMETIC_IR_VISITOR_WITH_ANALYZER_H_
-#define TVM_ARITHMETIC_IR_VISITOR_WITH_ANALYZER_H_
+#ifndef TVM_ARITH_IR_VISITOR_WITH_ANALYZER_H_
+#define TVM_ARITH_IR_VISITOR_WITH_ANALYZER_H_
 
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 
@@ -73,4 +73,4 @@ class IRVisitorWithAnalyzer final : public StmtExprVisitor {
 
 }  // namespace ir
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_IR_VISITOR_WITH_ANALYZER_H_
+#endif  // TVM_ARITH_IR_VISITOR_WITH_ANALYZER_H_
similarity index 99%
rename from src/arithmetic/modular_set.cc
rename to src/arith/modular_set.cc
index c818420..c79e94f 100644 (file)
@@ -21,7 +21,7 @@
  * \file modular_set.cc
  * \brief Modular set analysis
  */
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
 #include <tvm/ir_functor_ext.h>
 #include <limits>
similarity index 99%
rename from src/arithmetic/pattern_match.h
rename to src/arith/pattern_match.h
index a236e65..f6e6508 100644 (file)
@@ -62,8 +62,8 @@
  *       Please be aware that the filled value in a PVar
  *       can be overriden in the next call to Match.
  */
-#ifndef TVM_ARITHMETIC_PATTERN_MATCH_H_
-#define TVM_ARITHMETIC_PATTERN_MATCH_H_
+#ifndef TVM_ARITH_PATTERN_MATCH_H_
+#define TVM_ARITH_PATTERN_MATCH_H_
 
 #include <tvm/ir_pass.h>
 #include <tuple>
@@ -798,4 +798,4 @@ if_then_else(const Pattern<TCond>& cond,
 
 }  // namespace arith
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_PATTERN_MATCH_H_
+#endif  // TVM_ARITH_PATTERN_MATCH_H_
similarity index 99%
rename from src/arithmetic/rewrite_simplify.cc
rename to src/arith/rewrite_simplify.cc
index e6e1524..5f486cf 100644 (file)
@@ -22,7 +22,7 @@
  * \brief Rewrite-rule based simplification.
  */
 // Acknowledgement: Most rewrite-rules are from Halide.
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
 #include <algorithm>
 #include "const_fold.h"
similarity index 96%
rename from src/arithmetic/rewrite_simplify.h
rename to src/arith/rewrite_simplify.h
index 6b4193c..3255376 100644 (file)
  * \file rewrite_simplify.h
  * \brief Rewrite-rule based simplification.
  */
-#ifndef TVM_ARITHMETIC_REWRITE_SIMPLIFY_H_
-#define TVM_ARITHMETIC_REWRITE_SIMPLIFY_H_
+#ifndef TVM_ARITH_REWRITE_SIMPLIFY_H_
+#define TVM_ARITH_REWRITE_SIMPLIFY_H_
 
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
 #include <unordered_map>
 #include <vector>
@@ -141,4 +141,4 @@ class RewriteSimplifier::Impl : public IRMutatorWithAnalyzer {
 
 }  // namespace arith
 }  // namespace tvm
-#endif  // TVM_ARITHMETIC_REWRITE_SIMPLIFY_H_
+#endif  // TVM_ARITH_REWRITE_SIMPLIFY_H_
similarity index 98%
rename from src/arithmetic/stmt_simplify.cc
rename to src/arith/stmt_simplify.cc
index dcc7e5d..0b7a4b7 100644 (file)
@@ -23,9 +23,9 @@
  */
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/expr_operator.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include "ir_mutator_with_analyzer.h"
 
 namespace tvm {
index 5ecf970..3d41d08 100644 (file)
@@ -24,7 +24,7 @@
 #include <cctype>
 #include "codegen_c.h"
 #include "../pass/ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace codegen {
index 60d8146..d214add 100644 (file)
@@ -31,7 +31,7 @@
 #include "codegen_cpu.h"
 #include "../build_common.h"
 #include "../../pass/ir_util.h"
-#include "../../arithmetic/compute_expr.h"
+#include "../../arith/compute_expr.h"
 
 namespace tvm {
 namespace codegen {
index b269f24..34e1fb8 100644 (file)
 #define TVM_CODEGEN_LLVM_CODEGEN_LLVM_H_
 #ifdef TVM_LLVM_VERSION
 
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/codegen.h>
-#include <tvm/arithmetic.h>
 #include <memory>
 #include <utility>
 #include <vector>
index 985f681..91eee8c 100644 (file)
@@ -25,7 +25,7 @@
 #include <tvm/ir_pass.h>
 #include <string>
 #include "codegen_spirv.h"
-#include "../../arithmetic/compute_expr.h"
+#include "../../arith/compute_expr.h"
 
 namespace tvm {
 namespace codegen {
index 5aa7f9c..877bc71 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef TVM_CODEGEN_SPIRV_CODEGEN_SPIRV_H_
 #define TVM_CODEGEN_SPIRV_CODEGEN_SPIRV_H_
 
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/lowered_func.h>
index 925e3db..8c7108a 100644 (file)
@@ -26,7 +26,7 @@
 #include <tvm/ir_pass.h>
 #include <iterator>
 #include <stack>
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 
index 5b4f4d1..966087c 100644 (file)
@@ -25,7 +25,7 @@
 #include <tvm/expr_operator.h>
 #include <cmath>
 // Centralized header for constant folders.
-#include "../arithmetic/const_fold.h"
+#include "../arith/const_fold.h"
 
 namespace tvm {
 
index 7c8427a..b82bab5 100644 (file)
@@ -22,7 +22,7 @@
  * \file compute_op.cc
  */
 #include <tvm/operation.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
 #include <tvm/ir_functor_ext.h>
@@ -32,8 +32,8 @@
 #include "compute_op.h"
 #include "op_util.h"
 #include "../schedule/message_passing.h"
-#include "../arithmetic/compute_expr.h"
-#include "../arithmetic/int_set.h"
+#include "../arith/compute_expr.h"
+#include "../arith/interval_set.h"
 
 namespace tvm {
 
index 6fc54a8..fb9f491 100644 (file)
@@ -22,7 +22,7 @@
  * \file extern_op.cc
  */
 #include <tvm/operation.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <unordered_set>
 #include "op_util.h"
index c3be234..8687ad6 100644 (file)
@@ -22,7 +22,7 @@
  * \file hybrid_op.cc
  */
 #include <tvm/operation.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
index e108ad3..52d3b5a 100644 (file)
@@ -28,7 +28,7 @@
 #include <string>
 #include "op_util.h"
 #include "../schedule/message_passing.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace op {
index 08df8b7..4c758dd 100644 (file)
  * \file tensor_compute_op.cc
  */
 #include <tvm/operation.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
 #include <unordered_set>
 #include "./op_util.h"
 #include "./compute_op.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 using namespace ir;
index 0f350d2..3b3bf4b 100644 (file)
@@ -26,7 +26,7 @@
 #include <tvm/runtime/device_api.h>
 #include "ir_util.h"
 #include "arg_binder.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index aff7d3d..6d4df47 100644 (file)
  */
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/runtime/registry.h>
 #include <tvm/packed_func_ext.h>
 
 #include <unordered_map>
 #include <unordered_set>
 #include <queue>
-#include "../arithmetic/int_set.h"
+#include "../arith/interval_set.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index e41a868..af83f47 100644 (file)
  * \brief Replace certain copy with copy intrinsics.
  * \file copy_intrin_rewrite.cc
  */
+#include <tvm/arith/pattern.h>
 #include <tvm/ir.h>
 #include <tvm/packed_func_ext.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
-#include "../arithmetic/pattern_match.h"
+#include "../arith/pattern_match.h"
 
 namespace tvm {
 namespace ir {
index 9ed5606..691f6a7 100644 (file)
@@ -25,7 +25,7 @@
 #include <tvm/ir_functor_ext.h>
 #include <tvm/expr_operator.h>
 #include "ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index d7abed8..d877863 100644 (file)
@@ -24,7 +24,7 @@
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <unordered_set>
 
 namespace tvm {
index 83fc582..a0a67a7 100644 (file)
@@ -24,7 +24,7 @@
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
 #include <unordered_set>
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index adcd5ec..7af2240 100644 (file)
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <unordered_map>
 #include <unordered_set>
-#include "../arithmetic/int_set.h"
+#include "../arith/interval_set.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index 5684f4e..7172a4a 100644 (file)
@@ -29,8 +29,8 @@
 #include <tvm/expr_operator.h>
 #include <unordered_set>
 #include "ir_util.h"
-#include "../arithmetic/pattern_match.h"
-#include "../arithmetic/ir_mutator_with_analyzer.h"
+#include "../arith/pattern_match.h"
+#include "../arith/ir_mutator_with_analyzer.h"
 
 namespace tvm {
 namespace ir {
index d509169..7b1378f 100644 (file)
@@ -26,7 +26,7 @@
 #include <tvm/ir_pass.h>
 #include <unordered_set>
 #include "ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index 59a6473..13e2504 100644 (file)
@@ -26,7 +26,7 @@
 #include <tvm/ir_pass.h>
 #include <unordered_set>
 #include "ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index 6a1c3c4..8da07f0 100644 (file)
  */
 // Thanks to Andrew Adams and Vinod Grover for
 // explaining the concept of warp shuffle.
+#include <tvm/arith/pattern.h>
+#include <tvm/arith/analyzer.h>
+
 #include <tvm/ir.h>
 #include <tvm/ir_functor_ext.h>
 #include <tvm/ir_pass.h>
 #include <unordered_set>
 #include "ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index da153fc..43acbaf 100644 (file)
@@ -26,7 +26,7 @@
 #include <utility>
 #include "ir_util.h"
 #include "storage_access.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index a6d83a8..fc46ef3 100644 (file)
@@ -22,7 +22,7 @@
  */
 // Flattens storage from multi-dimensional array to 1D
 // buffer access as in Halide pipeline.
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/expr.h>
 #include <tvm/operation.h>
@@ -35,8 +35,8 @@
 #include <unordered_map>
 #include "ir_util.h"
 #include "arg_binder.h"
-#include "../arithmetic/compute_expr.h"
-#include "../arithmetic/ir_visitor_with_analyzer.h"
+#include "../arith/compute_expr.h"
+#include "../arith/ir_visitor_with_analyzer.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index 4908420..8b55dab 100644 (file)
@@ -22,6 +22,7 @@
  * \brief Memory access pattern analysis and optimization.
  *  Re-write data access to enable memory sharing when possible.
  */
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
 #include <tvm/ir_functor_ext.h>
@@ -30,7 +31,7 @@
 #include <unordered_set>
 #include <unordered_map>
 #include "ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index dad2780..c5c81ca 100644 (file)
@@ -33,7 +33,7 @@
 #include <tvm/runtime/device_api.h>
 #include <unordered_map>
 #include "ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 #include "../runtime/thread_storage_scope.h"
 
 namespace tvm {
index 26ad591..2658e76 100644 (file)
@@ -28,7 +28,7 @@
 #include <unordered_set>
 #include <unordered_map>
 #include <vector>
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index c9f3441..5e5e427 100644 (file)
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
 #include <tvm/ir_functor_ext.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <unordered_set>
 #include <unordered_map>
 #include <vector>
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace ir {
index 0d4e0a4..59bb432 100644 (file)
@@ -35,7 +35,7 @@
 #include <topi/nn.h>
 #include <vector>
 #include "../op_common.h"
-#include "../../../arithmetic/compute_expr.h"
+#include "../../../arith/compute_expr.h"
 #include "../../pass/infer_layout_util.h"
 #include "../../pass/pattern_util.h"
 #include "transform.h"
index 869e305..816ea44 100644 (file)
  * \file message_passing.cc
  * \brief The message passing domain.
  */
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <tvm/ir.h>
 #include <tvm/ir_pass.h>
 #include "message_passing.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 namespace schedule {
index 6661589..4b81bcc 100644 (file)
@@ -28,7 +28,7 @@
 #include <tvm/expr.h>
 #include <tvm/schedule.h>
 #include <tvm/operation.h>
-#include <tvm/arithmetic.h>
+#include <tvm/arith/analyzer.h>
 #include <unordered_map>
 #include <unordered_set>
 #include <vector>
index 3bad338..f06cf96 100644 (file)
@@ -27,7 +27,7 @@
 #include <unordered_set>
 #include "message_passing.h"
 #include "../pass/ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
 
 namespace tvm {
 
index 193f2f2..ffd710f 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #include <gtest/gtest.h>
-#include "../src/arithmetic/pattern_match.h"
+#include "../src/arith/pattern_match.h"
 
 TEST(Pattern, Basic) {
   using namespace tvm;