src/ir/*.cc
src/target/*.cc
src/api/*.cc
- src/arithmetic/*.cc
+ src/arith/*.cc
src/autotvm/*.cc
src/codegen/*.cc
src/lang/*.cc
*/
/*!
- * \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.
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.
*/
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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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_
#define TVM_BUILD_MODULE_H_
#include <tvm/target/target.h>
-
+#include <tvm/support/with.h>
#include <string>
#include <vector>
#include <utility>
#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 {
#define TVM_TENSOR_H_
#include <tvm/node/container.h>
+#include <tvm/arith/bound.h>
+
#include <string>
#include <vector>
#include <utility>
#include "expr.h"
#include "expr_operator.h"
-#include "arithmetic.h"
namespace tvm {
- 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.
* 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>
*/
/*!
- * \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 {
#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 {
* \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"
* \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>
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_COMPUTE_EXPR_H_
+#endif // TVM_ARITH_COMPUTE_EXPR_H_
* \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>
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_CONST_FOLD_H_
+#endif // TVM_ARITH_CONST_FOLD_H_
*/
/*!
- * \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"
#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 {
* \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>
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_INT_OPERATOR_H_
+#endif // TVM_ARITH_INT_OPERATOR_H_
* \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>
#include <utility>
#include <algorithm>
#include <unordered_map>
-#include "int_set.h"
+#include "interval_set.h"
#include "pattern_match.h"
namespace tvm {
* \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"
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_INT_SET_H_
+#endif // TVM_ARITH_INTERVAL_SET_H_
*/
/*!
- * \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>
* \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 {
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_IR_MUTATOR_WITH_ANALYZER_H_
+#endif // TVM_ARITH_IR_MUTATOR_WITH_ANALYZER_H_
* \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>
} // namespace ir
} // namespace tvm
-#endif // TVM_ARITHMETIC_IR_VISITOR_WITH_ANALYZER_H_
+#endif // TVM_ARITH_IR_VISITOR_WITH_ANALYZER_H_
* \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>
* 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>
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_PATTERN_MATCH_H_
+#endif // TVM_ARITH_PATTERN_MATCH_H_
* \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"
* \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>
} // namespace arith
} // namespace tvm
-#endif // TVM_ARITHMETIC_REWRITE_SIMPLIFY_H_
+#endif // TVM_ARITH_REWRITE_SIMPLIFY_H_
*/
#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 {
#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 {
#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 {
#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>
#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 {
#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>
#include <tvm/ir_pass.h>
#include <iterator>
#include <stack>
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
namespace tvm {
#include <tvm/expr_operator.h>
#include <cmath>
// Centralized header for constant folders.
-#include "../arithmetic/const_fold.h"
+#include "../arith/const_fold.h"
namespace tvm {
* \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>
#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 {
* \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"
* \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>
#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 {
* \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;
#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 {
*/
#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 {
* \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 {
#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 {
#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 {
#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 {
#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 {
#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 {
#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 {
#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 {
*/
// 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 {
#include <utility>
#include "ir_util.h"
#include "storage_access.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
namespace tvm {
namespace ir {
*/
// 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>
#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 {
* \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>
#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 {
#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 {
#include <unordered_set>
#include <unordered_map>
#include <vector>
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
namespace tvm {
namespace ir {
#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 {
#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"
* \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 {
#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>
#include <unordered_set>
#include "message_passing.h"
#include "../pass/ir_util.h"
-#include "../arithmetic/compute_expr.h"
+#include "../arith/compute_expr.h"
namespace tvm {
*/
#include <gtest/gtest.h>
-#include "../src/arithmetic/pattern_match.h"
+#include "../src/arith/pattern_match.h"
TEST(Pattern, Basic) {
using namespace tvm;