diff --git a/CMakeLists.txt b/CMakeLists.txt index b472bcebb1e3..0a3c5131e14c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,7 +161,9 @@ file(GLOB_RECURSE RELAY_OP_SRCS src/relay/op/*.cc ) file(GLOB_RECURSE RELAY_PASS_SRCS - src/relay/pass/*.cc + src/relay/analysis/*.cc + src/relay/transforms/*.cc + src/relay/quantize/*.cc ) file(GLOB RELAY_BACKEND_SRCS src/relay/backend/*.cc diff --git a/python/tvm/relay/analysis.py b/python/tvm/relay/analysis.py index d0c172418fba..fc4a03753422 100644 --- a/python/tvm/relay/analysis.py +++ b/python/tvm/relay/analysis.py @@ -23,7 +23,6 @@ from tvm.ir import RelayExpr, IRModule from . import _analysis -from . import _make from .ty import Type from .feature import Feature @@ -237,7 +236,7 @@ def alpha_equal(lhs, rhs): result : bool True iff lhs is alpha equal to rhs. """ - return bool(_make._alpha_equal(lhs, rhs)) + return bool(_analysis._alpha_equal(lhs, rhs)) def assert_alpha_equal(lhs, rhs): @@ -251,7 +250,7 @@ def assert_alpha_equal(lhs, rhs): rhs : tvm.relay.Expr One of the input Expression. """ - _make._assert_alpha_equal(lhs, rhs) + _analysis._assert_alpha_equal(lhs, rhs) def graph_equal(lhs, rhs): @@ -273,7 +272,7 @@ def graph_equal(lhs, rhs): result : bool True iff lhs is data-flow equivalent to rhs. """ - return bool(_make._graph_equal(lhs, rhs)) + return bool(_analysis._graph_equal(lhs, rhs)) def assert_graph_equal(lhs, rhs): @@ -290,7 +289,7 @@ def assert_graph_equal(lhs, rhs): rhs : tvm.relay.Expr One of the input Expression. """ - _make._assert_graph_equal(lhs, rhs) + _analysis._assert_graph_equal(lhs, rhs) def collect_device_info(expr): diff --git a/src/printer/relay_text_printer.cc b/src/printer/relay_text_printer.cc index 86362e0a0419..2799be0896cf 100644 --- a/src/printer/relay_text_printer.cc +++ b/src/printer/relay_text_printer.cc @@ -38,7 +38,7 @@ #include #include "doc.h" #include "meta_data.h" -#include "../relay/pass/dependency_graph.h" +#include "../relay/analysis/dependency_graph.h" #include "../ir/attr_functor.h" namespace tvm { diff --git a/src/relay/ir/alpha_equal.cc b/src/relay/analysis/alpha_equal.cc similarity index 98% rename from src/relay/ir/alpha_equal.cc rename to src/relay/analysis/alpha_equal.cc index c622599dd89c..8a07a19b2af7 100644 --- a/src/relay/ir/alpha_equal.cc +++ b/src/relay/analysis/alpha_equal.cc @@ -18,7 +18,7 @@ */ /*! - * \file src/tvm/relay/ir/alpha_equal.cc + * \file src/relay/analysis/alpha_equal.cc * \brief Alpha equality check by deep comparing two nodes. */ #include @@ -593,8 +593,7 @@ bool AlphaEqual(const Expr& lhs, const Expr& rhs) { return AlphaEqualHandler(false, false).ExprEqual(lhs, rhs); } -// TODO(@jroesch): move to correct namespace? -TVM_REGISTER_GLOBAL("relay._make._alpha_equal") +TVM_REGISTER_GLOBAL("relay._analysis._alpha_equal") .set_body_typed([](ObjectRef a, ObjectRef b) { return AlphaEqualHandler(false, false).Equal(a, b); }); @@ -604,18 +603,18 @@ TVM_REGISTER_GLOBAL("ir.type_alpha_equal") return AlphaEqual(a, b); }); -TVM_REGISTER_GLOBAL("relay._make._assert_alpha_equal") +TVM_REGISTER_GLOBAL("relay._analysis._assert_alpha_equal") .set_body_typed([](ObjectRef a, ObjectRef b) { bool alpha_equal = AlphaEqualHandler(false, true).Equal(a, b); CHECK(alpha_equal) << AsText(a, true) << " and " << AsText(b, true) << " are not alpha equal"; }); -TVM_REGISTER_GLOBAL("relay._make._graph_equal") +TVM_REGISTER_GLOBAL("relay._analysis._graph_equal") .set_body_typed([](ObjectRef a, ObjectRef b) { return AlphaEqualHandler(true, false).Equal(a, b); }); -TVM_REGISTER_GLOBAL("relay._make._assert_graph_equal") +TVM_REGISTER_GLOBAL("relay._analysis._assert_graph_equal") .set_body_typed([](ObjectRef a, ObjectRef b) { bool graph_equal = AlphaEqualHandler(true, true).Equal(a, b); CHECK(graph_equal) << AsText(a, true) << " and " << AsText(b, true) << " are not graph equal"; diff --git a/src/relay/pass/call_graph.cc b/src/relay/analysis/call_graph.cc similarity index 99% rename from src/relay/pass/call_graph.cc rename to src/relay/analysis/call_graph.cc index 9c612eb552fc..b9ee8e148894 100644 --- a/src/relay/pass/call_graph.cc +++ b/src/relay/analysis/call_graph.cc @@ -18,7 +18,7 @@ */ /*! - * \file tvm/relay/pass/call_graph.cc + * \file src/relay/analysis/call_graph.cc * \brief Implementation of APIs to handle the call graph of a Relay module. */ diff --git a/src/relay/pass/call_graph.h b/src/relay/analysis/call_graph.h similarity index 98% rename from src/relay/pass/call_graph.h rename to src/relay/analysis/call_graph.h index 684e11a7600f..03c9283d0660 100644 --- a/src/relay/pass/call_graph.h +++ b/src/relay/analysis/call_graph.h @@ -18,15 +18,15 @@ */ /*! - * \file tvm/relay/pass/call_graph.h + * \file src/relay/analysis/call_graph.h * \brief Define data structures for the call graph of a IRModule. It borrows * the idea how LLVM constructs CallGraph. * * https://llvm.org/doxygen/CallGraph_8h_source.html */ -#ifndef TVM_RELAY_PASS_CALL_GRAPH_H_ -#define TVM_RELAY_PASS_CALL_GRAPH_H_ +#ifndef TVM_RELAY_ANALYSIS_CALL_GRAPH_H_ +#define TVM_RELAY_ANALYSIS_CALL_GRAPH_H_ #include #include @@ -510,4 +510,4 @@ class CallGraphEntry { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_CALL_GRAPH_H_ +#endif // TVM_RELAY_ANALYSIS_CALL_GRAPH_H_ diff --git a/src/relay/pass/dependency_graph.cc b/src/relay/analysis/dependency_graph.cc similarity index 98% rename from src/relay/pass/dependency_graph.cc rename to src/relay/analysis/dependency_graph.cc index 9dab38cd1c6a..7e48d12d0cf3 100644 --- a/src/relay/pass/dependency_graph.cc +++ b/src/relay/analysis/dependency_graph.cc @@ -18,8 +18,8 @@ */ /*! - * \file tvm/relay/pass/dependency_graph.cc - * \brief + * \file src/relay/analysis/dependency_graph.cc + * \brief Implementation of dependency graph APIs. */ #include "dependency_graph.h" #include diff --git a/src/relay/pass/dependency_graph.h b/src/relay/analysis/dependency_graph.h similarity index 90% rename from src/relay/pass/dependency_graph.h rename to src/relay/analysis/dependency_graph.h index 4f33e51c3727..5e2dc0c899d1 100644 --- a/src/relay/pass/dependency_graph.h +++ b/src/relay/analysis/dependency_graph.h @@ -18,16 +18,16 @@ */ /*! - * \file tvm/relay/pass/dependency_graph.h + * \file src/relay/analysis/dependency_graph.h * \brief create a dependency graph. */ -#ifndef TVM_RELAY_PASS_DEPENDENCY_GRAPH_H_ -#define TVM_RELAY_PASS_DEPENDENCY_GRAPH_H_ +#ifndef TVM_RELAY_ANALYSIS_DEPENDENCY_GRAPH_H_ +#define TVM_RELAY_ANALYSIS_DEPENDENCY_GRAPH_H_ #include #include #include -#include "let_list.h" +#include "../transforms/let_list.h" #include "../../support/arena.h" namespace tvm { @@ -72,4 +72,4 @@ class DependencyGraph { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_DEPENDENCY_GRAPH_H_ +#endif // TVM_RELAY_ANALYSIS_DEPENDENCY_GRAPH_H_ diff --git a/src/relay/pass/feature.cc b/src/relay/analysis/feature.cc similarity index 98% rename from src/relay/pass/feature.cc rename to src/relay/analysis/feature.cc index 43f28ae28452..a5a6f19209eb 100644 --- a/src/relay/pass/feature.cc +++ b/src/relay/analysis/feature.cc @@ -26,7 +26,7 @@ #include #include #include -#include "pass_util.h" +#include "../transforms/pass_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/kind_check.cc b/src/relay/analysis/kind_check.cc similarity index 100% rename from src/relay/pass/kind_check.cc rename to src/relay/analysis/kind_check.cc diff --git a/src/relay/pass/mac_count.cc b/src/relay/analysis/mac_count.cc similarity index 99% rename from src/relay/pass/mac_count.cc rename to src/relay/analysis/mac_count.cc index a03924d1c965..49fe2a3900b3 100644 --- a/src/relay/pass/mac_count.cc +++ b/src/relay/analysis/mac_count.cc @@ -31,7 +31,7 @@ #include #include #include -#include "pattern_util.h" +#include "../transforms/pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/match_exhaustion.cc b/src/relay/analysis/match_exhaustion.cc similarity index 100% rename from src/relay/pass/match_exhaustion.cc rename to src/relay/analysis/match_exhaustion.cc diff --git a/src/relay/pass/type_solver.cc b/src/relay/analysis/type_solver.cc similarity index 100% rename from src/relay/pass/type_solver.cc rename to src/relay/analysis/type_solver.cc diff --git a/src/relay/pass/type_solver.h b/src/relay/analysis/type_solver.h similarity index 98% rename from src/relay/pass/type_solver.h rename to src/relay/analysis/type_solver.h index 6eed5b708be6..8ccc2c7244b0 100644 --- a/src/relay/pass/type_solver.h +++ b/src/relay/analysis/type_solver.h @@ -21,8 +21,8 @@ * \file type_solver.h * \brief Solver logic for type inference. */ -#ifndef TVM_RELAY_PASS_TYPE_SOLVER_H_ -#define TVM_RELAY_PASS_TYPE_SOLVER_H_ +#ifndef TVM_RELAY_ANALYSIS_TYPE_SOLVER_H_ +#define TVM_RELAY_ANALYSIS_TYPE_SOLVER_H_ #include #include @@ -34,7 +34,6 @@ #include #include "../../support/arena.h" - namespace tvm { namespace relay { @@ -219,4 +218,4 @@ class TypeSolver { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_TYPE_SOLVER_H_ +#endif // TVM_RELAY_ANALYSIS_TYPE_SOLVER_H_ diff --git a/src/relay/pass/util.cc b/src/relay/analysis/util.cc similarity index 99% rename from src/relay/pass/util.cc rename to src/relay/analysis/util.cc index b3419668cf0d..88c89dfee6b6 100644 --- a/src/relay/pass/util.cc +++ b/src/relay/analysis/util.cc @@ -28,7 +28,7 @@ #include #include #include -#include "pass_util.h" +#include "../transforms/pass_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/well_formed.cc b/src/relay/analysis/well_formed.cc similarity index 100% rename from src/relay/pass/well_formed.cc rename to src/relay/analysis/well_formed.cc diff --git a/src/relay/backend/vm/compiler.cc b/src/relay/backend/vm/compiler.cc index e3c8d12a6e66..5ddcd170b5c3 100644 --- a/src/relay/backend/vm/compiler.cc +++ b/src/relay/backend/vm/compiler.cc @@ -40,7 +40,7 @@ #include #include "../utils.h" #include "../../backend/compile_engine.h" -#include "../../pass/pass_util.h" +#include "../../transforms/pass_util.h" #include "../../op/op_common.h" #include "compiler.h" diff --git a/src/relay/backend/vm/compiler.h b/src/relay/backend/vm/compiler.h index 19e1ee8781a8..f18e2c037459 100644 --- a/src/relay/backend/vm/compiler.h +++ b/src/relay/backend/vm/compiler.h @@ -41,7 +41,7 @@ #include "../../../runtime/vm/profiler/vm.h" #include "../../../runtime/vm/naive_allocator.h" #include "../../backend/compile_engine.h" -#include "../../pass/pass_util.h" +#include "../../transforms/pass_util.h" namespace tvm { namespace relay { diff --git a/src/relay/op/annotation/annotation.cc b/src/relay/op/annotation/annotation.cc index 36f592355a2c..ee9877ea4a6d 100644 --- a/src/relay/op/annotation/annotation.cc +++ b/src/relay/op/annotation/annotation.cc @@ -30,7 +30,7 @@ #include #include -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" #include "../type_relations.h" namespace tvm { diff --git a/src/relay/op/device_copy.cc b/src/relay/op/device_copy.cc index d15c85cabcad..7e0530c29476 100644 --- a/src/relay/op/device_copy.cc +++ b/src/relay/op/device_copy.cc @@ -33,7 +33,7 @@ #include #include "type_relations.h" -#include "../pass/infer_layout_util.h" +#include "../transforms/infer_layout_util.h" namespace tvm { namespace relay { diff --git a/src/relay/op/memory/memory.cc b/src/relay/op/memory/memory.cc index d15099b6b451..dcb50e680505 100644 --- a/src/relay/op/memory/memory.cc +++ b/src/relay/op/memory/memory.cc @@ -29,7 +29,7 @@ #include #include "../op_common.h" -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" #include "../type_relations.h" namespace tvm { diff --git a/src/relay/op/nn/bitserial.cc b/src/relay/op/nn/bitserial.cc index c9e05e1f5158..621fe777ff9c 100644 --- a/src/relay/op/nn/bitserial.cc +++ b/src/relay/op/nn/bitserial.cc @@ -27,7 +27,7 @@ #include #include "../op_common.h" -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" namespace tvm { namespace relay { diff --git a/src/relay/op/nn/convolution.cc b/src/relay/op/nn/convolution.cc index cd9b5ddc7fbf..5906d3ab9ae1 100644 --- a/src/relay/op/nn/convolution.cc +++ b/src/relay/op/nn/convolution.cc @@ -27,7 +27,7 @@ #include #include -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" #include "../op_common.h" #include "convolution.h" diff --git a/src/relay/op/nn/nn.cc b/src/relay/op/nn/nn.cc index 10fd4d975ce4..560d06f9fb79 100644 --- a/src/relay/op/nn/nn.cc +++ b/src/relay/op/nn/nn.cc @@ -33,7 +33,7 @@ #include #include #include "../type_relations.h" -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" #include "../op_common.h" #include "nn.h" diff --git a/src/relay/op/nn/pooling.cc b/src/relay/op/nn/pooling.cc index f174882f8a3e..2b02c829e997 100644 --- a/src/relay/op/nn/pooling.cc +++ b/src/relay/op/nn/pooling.cc @@ -27,7 +27,7 @@ #include #include #include -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" namespace tvm { namespace relay { diff --git a/src/relay/op/nn/sparse.cc b/src/relay/op/nn/sparse.cc index c01b760c4ad0..e7db1255c6f0 100644 --- a/src/relay/op/nn/sparse.cc +++ b/src/relay/op/nn/sparse.cc @@ -27,7 +27,7 @@ #include #include -#include "../../pass/infer_layout_util.h" +#include "../../transforms/infer_layout_util.h" namespace tvm { namespace relay { diff --git a/src/relay/op/op_common.h b/src/relay/op/op_common.h index d9846cf443f7..25293adea67b 100644 --- a/src/relay/op/op_common.h +++ b/src/relay/op/op_common.h @@ -32,7 +32,7 @@ #include #include #include "type_relations.h" -#include "../pass/infer_layout_util.h" +#include "../transforms/infer_layout_util.h" namespace tvm { namespace relay { diff --git a/src/relay/op/tensor/transform.cc b/src/relay/op/tensor/transform.cc index fa96d7fcbee7..2bdcbcf00a99 100644 --- a/src/relay/op/tensor/transform.cc +++ b/src/relay/op/tensor/transform.cc @@ -36,8 +36,8 @@ #include #include "../op_common.h" #include "../../../arith/compute_expr.h" -#include "../../pass/infer_layout_util.h" -#include "../../pass/pattern_util.h" +#include "../../transforms/infer_layout_util.h" +#include "../../transforms/pattern_util.h" #include "transform.h" namespace tvm { diff --git a/src/relay/qnn/op/add.cc b/src/relay/qnn/op/add.cc index 67ca10d8e110..b70954b1d64a 100644 --- a/src/relay/qnn/op/add.cc +++ b/src/relay/qnn/op/add.cc @@ -24,7 +24,7 @@ #include #include #include -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" #include "op_common.h" diff --git a/src/relay/qnn/op/concatenate.cc b/src/relay/qnn/op/concatenate.cc index 360543b219ab..3f4e315e1a3a 100644 --- a/src/relay/qnn/op/concatenate.cc +++ b/src/relay/qnn/op/concatenate.cc @@ -27,7 +27,7 @@ #include #include #include "../../op/tensor/transform.h" -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" namespace tvm { diff --git a/src/relay/qnn/op/convolution.cc b/src/relay/qnn/op/convolution.cc index 6626ce2c19fa..30308fdcd33d 100644 --- a/src/relay/qnn/op/convolution.cc +++ b/src/relay/qnn/op/convolution.cc @@ -28,7 +28,7 @@ #include #include #include "../../op/nn/convolution.h" -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" namespace tvm { diff --git a/src/relay/qnn/op/dense.cc b/src/relay/qnn/op/dense.cc index de3c4dbc7dc1..91f607279f17 100644 --- a/src/relay/qnn/op/dense.cc +++ b/src/relay/qnn/op/dense.cc @@ -27,7 +27,7 @@ #include #include #include "../../op/nn/nn.h" -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" namespace tvm { diff --git a/src/relay/qnn/op/dequantize.cc b/src/relay/qnn/op/dequantize.cc index 6233246d7bae..087ceac4f300 100644 --- a/src/relay/qnn/op/dequantize.cc +++ b/src/relay/qnn/op/dequantize.cc @@ -26,7 +26,7 @@ #include #include #include -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" namespace tvm { diff --git a/src/relay/qnn/op/mul.cc b/src/relay/qnn/op/mul.cc index 89193ed4556d..9ab5cadb5c25 100644 --- a/src/relay/qnn/op/mul.cc +++ b/src/relay/qnn/op/mul.cc @@ -24,7 +24,7 @@ #include #include #include -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" #include "op_common.h" diff --git a/src/relay/qnn/op/quantize.cc b/src/relay/qnn/op/quantize.cc index 66c40a27c437..d3f8ee5e5cee 100644 --- a/src/relay/qnn/op/quantize.cc +++ b/src/relay/qnn/op/quantize.cc @@ -26,7 +26,7 @@ #include #include #include -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" namespace tvm { diff --git a/src/relay/qnn/op/requantize.cc b/src/relay/qnn/op/requantize.cc index 7e99ad7938d9..9b2ed913b282 100644 --- a/src/relay/qnn/op/requantize.cc +++ b/src/relay/qnn/op/requantize.cc @@ -25,7 +25,7 @@ #include #include #include -#include "../../pass/pattern_util.h" +#include "../../transforms/pattern_util.h" #include "../util.h" namespace tvm { diff --git a/src/relay/qnn/util.cc b/src/relay/qnn/util.cc index fad37bcab98d..648de5349ce1 100644 --- a/src/relay/qnn/util.cc +++ b/src/relay/qnn/util.cc @@ -23,7 +23,7 @@ */ #include "util.h" -#include "../pass/pattern_util.h" +#include "../transforms/pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/quantize/annotate.cc b/src/relay/quantize/annotate.cc similarity index 100% rename from src/relay/pass/quantize/annotate.cc rename to src/relay/quantize/annotate.cc diff --git a/src/relay/pass/quantize/calibrate.cc b/src/relay/quantize/calibrate.cc similarity index 100% rename from src/relay/pass/quantize/calibrate.cc rename to src/relay/quantize/calibrate.cc diff --git a/src/relay/pass/quantize/partition.cc b/src/relay/quantize/partition.cc similarity index 98% rename from src/relay/pass/quantize/partition.cc rename to src/relay/quantize/partition.cc index 8fb65a4c7009..121e4316867b 100644 --- a/src/relay/pass/quantize/partition.cc +++ b/src/relay/quantize/partition.cc @@ -25,7 +25,7 @@ */ #include -#include "../pattern_util.h" +#include "../transforms/pattern_util.h" #include "./quantize.h" namespace tvm { diff --git a/src/relay/pass/quantize/quantize.cc b/src/relay/quantize/quantize.cc similarity index 100% rename from src/relay/pass/quantize/quantize.cc rename to src/relay/quantize/quantize.cc diff --git a/src/relay/pass/quantize/quantize.h b/src/relay/quantize/quantize.h similarity index 96% rename from src/relay/pass/quantize/quantize.h rename to src/relay/quantize/quantize.h index 4f6cd2d2d7bb..563f47f56933 100644 --- a/src/relay/pass/quantize/quantize.h +++ b/src/relay/quantize/quantize.h @@ -18,16 +18,16 @@ */ /*! - * \file tvm/relay/pass/quantize.h + * \file tvm/relay/quantize.h * \brief Header of definitions for quantization */ -#ifndef TVM_RELAY_PASS_QUANTIZE_QUANTIZE_H_ -#define TVM_RELAY_PASS_QUANTIZE_QUANTIZE_H_ +#ifndef TVM_RELAY_QUANTIZE_QUANTIZE_H_ +#define TVM_RELAY_QUANTIZE_QUANTIZE_H_ #include #include #include -#include "../pattern_util.h" +#include "../transforms/pattern_util.h" namespace tvm { namespace relay { @@ -163,4 +163,4 @@ struct QConfigContext { } // namespace quantize } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_QUANTIZE_QUANTIZE_H_ +#endif // TVM_RELAY_QUANTIZE_QUANTIZE_H_ diff --git a/src/relay/pass/quantize/realize.cc b/src/relay/quantize/realize.cc similarity index 99% rename from src/relay/pass/quantize/realize.cc rename to src/relay/quantize/realize.cc index ae37245025b5..e80b17c65331 100644 --- a/src/relay/pass/quantize/realize.cc +++ b/src/relay/quantize/realize.cc @@ -29,8 +29,8 @@ #include #include #include "./quantize.h" -#include "../pattern_util.h" -#include "../../qnn/util.h" +#include "../transforms/pattern_util.h" +#include "../qnn/util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/alter_op_layout.cc b/src/relay/transforms/alter_op_layout.cc similarity index 100% rename from src/relay/pass/alter_op_layout.cc rename to src/relay/transforms/alter_op_layout.cc diff --git a/src/relay/pass/annotate_target.cc b/src/relay/transforms/annotate_target.cc similarity index 98% rename from src/relay/pass/annotate_target.cc rename to src/relay/transforms/annotate_target.cc index 732206958aaf..f5bc6c2617ba 100644 --- a/src/relay/pass/annotate_target.cc +++ b/src/relay/transforms/annotate_target.cc @@ -18,7 +18,7 @@ */ /*! - * \file src/relay/pass/annotate_target.cc + * \file src/relay/transforms/annotate_target.cc * \brief Wraps a call with compiler_begin and compiler_end to indicate that * the op of this call node will use external compiler. */ diff --git a/src/relay/pass/canonicalize_cast.cc b/src/relay/transforms/canonicalize_cast.cc similarity index 100% rename from src/relay/pass/canonicalize_cast.cc rename to src/relay/transforms/canonicalize_cast.cc index dd899dfbaf9d..b65e94805e8c 100644 --- a/src/relay/pass/canonicalize_cast.cc +++ b/src/relay/transforms/canonicalize_cast.cc @@ -25,8 +25,8 @@ #include #include #include -#include "pattern_util.h" #include "pass_util.h" +#include "pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/canonicalize_ops.cc b/src/relay/transforms/canonicalize_ops.cc similarity index 100% rename from src/relay/pass/canonicalize_ops.cc rename to src/relay/transforms/canonicalize_ops.cc diff --git a/src/relay/pass/combine_parallel_conv2d.cc b/src/relay/transforms/combine_parallel_conv2d.cc similarity index 99% rename from src/relay/pass/combine_parallel_conv2d.cc rename to src/relay/transforms/combine_parallel_conv2d.cc index 5c9263722788..b4ac99709f93 100644 --- a/src/relay/pass/combine_parallel_conv2d.cc +++ b/src/relay/transforms/combine_parallel_conv2d.cc @@ -41,8 +41,8 @@ #include #include #include "./expr_subst.h" -#include "./pattern_util.h" #include "./combine_parallel_op.h" +#include "pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/combine_parallel_dense.cc b/src/relay/transforms/combine_parallel_dense.cc similarity index 99% rename from src/relay/pass/combine_parallel_dense.cc rename to src/relay/transforms/combine_parallel_dense.cc index fdd42be2c486..cd234bbd9fa9 100644 --- a/src/relay/pass/combine_parallel_dense.cc +++ b/src/relay/transforms/combine_parallel_dense.cc @@ -40,7 +40,7 @@ #include #include #include "./expr_subst.h" -#include "./pattern_util.h" +#include "pattern_util.h" #include "./combine_parallel_op_batch.h" namespace tvm { diff --git a/src/relay/pass/combine_parallel_op.cc b/src/relay/transforms/combine_parallel_op.cc similarity index 100% rename from src/relay/pass/combine_parallel_op.cc rename to src/relay/transforms/combine_parallel_op.cc diff --git a/src/relay/pass/combine_parallel_op.h b/src/relay/transforms/combine_parallel_op.h similarity index 97% rename from src/relay/pass/combine_parallel_op.h rename to src/relay/transforms/combine_parallel_op.h index 24f3884f4b11..0097e29b13ea 100644 --- a/src/relay/pass/combine_parallel_op.h +++ b/src/relay/transforms/combine_parallel_op.h @@ -22,8 +22,8 @@ * \file combine_parallel_op.h * \brief Abstract class to combine parallel ops and their successive element-wise ops. */ -#ifndef TVM_RELAY_PASS_COMBINE_PARALLEL_OP_H_ -#define TVM_RELAY_PASS_COMBINE_PARALLEL_OP_H_ +#ifndef TVM_RELAY_TRANSFORMS_COMBINE_PARALLEL_OP_H_ +#define TVM_RELAY_TRANSFORMS_COMBINE_PARALLEL_OP_H_ #include #include @@ -36,7 +36,7 @@ #include #include #include "./expr_subst.h" -#include "./pattern_util.h" +#include "pattern_util.h" namespace tvm { @@ -237,4 +237,4 @@ class ParallelOpCombiner { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_COMBINE_PARALLEL_OP_H_ +#endif // TVM_RELAY_TRANSFORMS_COMBINE_PARALLEL_OP_H_ diff --git a/src/relay/pass/combine_parallel_op_batch.cc b/src/relay/transforms/combine_parallel_op_batch.cc similarity index 99% rename from src/relay/pass/combine_parallel_op_batch.cc rename to src/relay/transforms/combine_parallel_op_batch.cc index a9eefaf50268..4252cfdec732 100644 --- a/src/relay/pass/combine_parallel_op_batch.cc +++ b/src/relay/transforms/combine_parallel_op_batch.cc @@ -53,9 +53,9 @@ #include #include #include "./expr_subst.h" -#include "./pattern_util.h" #include "./combine_parallel_op.h" #include "./combine_parallel_op_batch.h" +#include "pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/combine_parallel_op_batch.h b/src/relay/transforms/combine_parallel_op_batch.h similarity index 95% rename from src/relay/pass/combine_parallel_op_batch.h rename to src/relay/transforms/combine_parallel_op_batch.h index 7dcbe765de45..687660433946 100644 --- a/src/relay/pass/combine_parallel_op_batch.h +++ b/src/relay/transforms/combine_parallel_op_batch.h @@ -18,11 +18,11 @@ */ /*! - * \file combine_parallel_op_batch.cc + * \file combine_parallel_op_batch.h * \brief Combine parallel ops into a single batch op. */ -#ifndef TVM_RELAY_PASS_COMBINE_PARALLEL_OP_BATCH_H_ -#define TVM_RELAY_PASS_COMBINE_PARALLEL_OP_BATCH_H_ +#ifndef TVM_RELAY_TRANSFORMS_COMBINE_PARALLEL_OP_BATCH_H_ +#define TVM_RELAY_TRANSFORMS_COMBINE_PARALLEL_OP_BATCH_H_ #include #include @@ -34,8 +34,8 @@ #include #include #include "./expr_subst.h" -#include "./pattern_util.h" #include "./combine_parallel_op.h" +#include "pattern_util.h" namespace tvm { namespace relay { @@ -145,4 +145,4 @@ class ParallelOpBatchCombiner : public ParallelOpCombiner { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_COMBINE_PARALLEL_OP_BATCH_H_ +#endif // TVM_RELAY_TRANSFORMS_COMBINE_PARALLEL_OP_BATCH_H_ diff --git a/src/relay/pass/convert_layout.cc b/src/relay/transforms/convert_layout.cc similarity index 100% rename from src/relay/pass/convert_layout.cc rename to src/relay/transforms/convert_layout.cc diff --git a/src/relay/pass/de_duplicate.cc b/src/relay/transforms/de_duplicate.cc similarity index 100% rename from src/relay/pass/de_duplicate.cc rename to src/relay/transforms/de_duplicate.cc diff --git a/src/relay/pass/dead_code.cc b/src/relay/transforms/dead_code.cc similarity index 100% rename from src/relay/pass/dead_code.cc rename to src/relay/transforms/dead_code.cc diff --git a/src/relay/pass/device_annotation.cc b/src/relay/transforms/device_annotation.cc similarity index 99% rename from src/relay/pass/device_annotation.cc rename to src/relay/transforms/device_annotation.cc index c87acd021a0b..93aa10823b9c 100644 --- a/src/relay/pass/device_annotation.cc +++ b/src/relay/transforms/device_annotation.cc @@ -563,9 +563,6 @@ Map CollectDeviceAnnotationOps(const Expr& expr) { TVM_REGISTER_GLOBAL("relay._analysis.CollectDeviceInfo") .set_body_typed(CollectDeviceInfo); -TVM_REGISTER_GLOBAL("relay._analysis.RewriteDeviceAnnotation") -.set_body_typed(RewriteAnnotatedOps); - TVM_REGISTER_GLOBAL("relay._analysis.CollectDeviceAnnotationOps") .set_body_typed(CollectDeviceAnnotationOps); @@ -574,7 +571,7 @@ namespace transform { Pass RewriteAnnotatedOps(int fallback_device) { runtime::TypedPackedFunc pass_func = [=](Function f, IRModule m, PassContext pc) { - return Downcast(RewriteAnnotatedOps(f, fallback_device)); + return Downcast(relay::RewriteAnnotatedOps(f, fallback_device)); }; return CreateFunctionPass(pass_func, 1, "RewriteAnnotatedOps", {tir::StringImmNode::make("InferType")}); diff --git a/src/relay/pass/eliminate_common_subexpr.cc b/src/relay/transforms/eliminate_common_subexpr.cc similarity index 99% rename from src/relay/pass/eliminate_common_subexpr.cc rename to src/relay/transforms/eliminate_common_subexpr.cc index c041b7e6eb41..bb31d3222690 100644 --- a/src/relay/pass/eliminate_common_subexpr.cc +++ b/src/relay/transforms/eliminate_common_subexpr.cc @@ -30,7 +30,7 @@ #include #include #include -#include "./pattern_util.h" +#include "pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/eta_expand.cc b/src/relay/transforms/eta_expand.cc similarity index 100% rename from src/relay/pass/eta_expand.cc rename to src/relay/transforms/eta_expand.cc diff --git a/src/relay/pass/expr_subst.cc b/src/relay/transforms/expr_subst.cc similarity index 100% rename from src/relay/pass/expr_subst.cc rename to src/relay/transforms/expr_subst.cc diff --git a/src/relay/pass/expr_subst.h b/src/relay/transforms/expr_subst.h similarity index 89% rename from src/relay/pass/expr_subst.h rename to src/relay/transforms/expr_subst.h index 2ffefa25657d..849ffc2db9e2 100644 --- a/src/relay/pass/expr_subst.h +++ b/src/relay/transforms/expr_subst.h @@ -21,8 +21,8 @@ * \file expr_subst.h * \brief Utility functions for substituting expressions. */ -#ifndef TVM_RELAY_PASS_EXPR_SUBST_H_ -#define TVM_RELAY_PASS_EXPR_SUBST_H_ +#ifndef TVM_RELAY_TRANSFORMS_EXPR_SUBST_H_ +#define TVM_RELAY_TRANSFORMS_EXPR_SUBST_H_ #include #include @@ -34,4 +34,4 @@ Expr ExprSubst(const Expr& expr, } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_EXPR_SUBST_H_ +#endif // TVM_RELAY_TRANSFORMS_EXPR_SUBST_H_ diff --git a/src/relay/pass/fast_math.cc b/src/relay/transforms/fast_math.cc similarity index 100% rename from src/relay/pass/fast_math.cc rename to src/relay/transforms/fast_math.cc diff --git a/src/relay/pass/fold_constant.cc b/src/relay/transforms/fold_constant.cc similarity index 100% rename from src/relay/pass/fold_constant.cc rename to src/relay/transforms/fold_constant.cc diff --git a/src/relay/pass/fold_scale_axis.cc b/src/relay/transforms/fold_scale_axis.cc similarity index 100% rename from src/relay/pass/fold_scale_axis.cc rename to src/relay/transforms/fold_scale_axis.cc diff --git a/src/relay/pass/forward_rewrite.cc b/src/relay/transforms/forward_rewrite.cc similarity index 100% rename from src/relay/pass/forward_rewrite.cc rename to src/relay/transforms/forward_rewrite.cc diff --git a/src/relay/pass/fuse_ops.cc b/src/relay/transforms/fuse_ops.cc similarity index 99% rename from src/relay/pass/fuse_ops.cc rename to src/relay/transforms/fuse_ops.cc index fd8e6fd0f59f..0c74159d6ba5 100644 --- a/src/relay/pass/fuse_ops.cc +++ b/src/relay/transforms/fuse_ops.cc @@ -19,7 +19,7 @@ /*! * - * \file src/tvm/relay/pass/fuse_ops.cc + * \file src/relay/transforms/fuse_ops.cc * * \brief This is a backend-aware optimization pass. * Fuse necessary ops into a single one. @@ -29,10 +29,9 @@ #include #include #include -#include "./pattern_util.h" +#include "pattern_util.h" #include "../../support/arena.h" - namespace tvm { namespace relay { diff --git a/src/relay/pass/gradient.cc b/src/relay/transforms/gradient.cc similarity index 100% rename from src/relay/pass/gradient.cc rename to src/relay/transforms/gradient.cc diff --git a/src/relay/pass/infer_layout_util.h b/src/relay/transforms/infer_layout_util.h similarity index 98% rename from src/relay/pass/infer_layout_util.h rename to src/relay/transforms/infer_layout_util.h index 9ecd0bf1f45b..eeb61e389598 100644 --- a/src/relay/pass/infer_layout_util.h +++ b/src/relay/transforms/infer_layout_util.h @@ -24,8 +24,8 @@ custom layouts or other general weight pre-transformation. */ -#ifndef TVM_RELAY_PASS_INFER_LAYOUT_UTIL_H_ -#define TVM_RELAY_PASS_INFER_LAYOUT_UTIL_H_ +#ifndef TVM_RELAY_TRANSFORMS_INFER_LAYOUT_UTIL_H_ +#define TVM_RELAY_TRANSFORMS_INFER_LAYOUT_UTIL_H_ #include #include @@ -232,4 +232,4 @@ static inline std::tuple, Array, bool> InferCorrectLayouts } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_INFER_LAYOUT_UTIL_H_ +#endif // TVM_RELAY_TRANSFORMS_INFER_LAYOUT_UTIL_H_ diff --git a/src/relay/pass/inline.cc b/src/relay/transforms/inline.cc similarity index 99% rename from src/relay/pass/inline.cc rename to src/relay/transforms/inline.cc index 6c8caeede59a..914c718743b1 100644 --- a/src/relay/pass/inline.cc +++ b/src/relay/transforms/inline.cc @@ -18,7 +18,7 @@ */ /*! - * \file tvm/relay/pass/inline.cc + * \file src/relay/transforms/inline.cc * \brief Global function inliner. It contains the following steps: * * - Preprocessing: eligibility checking. Only inline the functions that can @@ -40,7 +40,7 @@ #include #include -#include "call_graph.h" +#include "../analysis/call_graph.h" using namespace tvm::runtime; diff --git a/src/relay/pass/legalize.cc b/src/relay/transforms/legalize.cc similarity index 100% rename from src/relay/pass/legalize.cc rename to src/relay/transforms/legalize.cc diff --git a/src/relay/pass/let_list.h b/src/relay/transforms/let_list.h similarity index 97% rename from src/relay/pass/let_list.h rename to src/relay/transforms/let_list.h index e37ffa9c48bf..1fb09478095b 100644 --- a/src/relay/pass/let_list.h +++ b/src/relay/transforms/let_list.h @@ -26,8 +26,8 @@ * if one instead write 'b = ll.Push(a + a); c = ll.Push(b + b); d = ll.Get(c + c);', * the AST will contain 2 'a', as b and c are now variables. */ -#ifndef TVM_RELAY_PASS_LET_LIST_H_ -#define TVM_RELAY_PASS_LET_LIST_H_ +#ifndef TVM_RELAY_TRANSFORMS_LET_LIST_H_ +#define TVM_RELAY_TRANSFORMS_LET_LIST_H_ #include #include @@ -149,4 +149,4 @@ class LetList { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_LET_LIST_H_ +#endif // TVM_RELAY_TRANSFORMS_LET_LIST_H_ diff --git a/src/relay/pass/merge_composite.cc b/src/relay/transforms/merge_composite.cc similarity index 99% rename from src/relay/pass/merge_composite.cc rename to src/relay/transforms/merge_composite.cc index 162bf3a2bba6..f1878255a52d 100644 --- a/src/relay/pass/merge_composite.cc +++ b/src/relay/transforms/merge_composite.cc @@ -18,7 +18,7 @@ */ /*! - * \file src/relay/pass/merge_composite.cc + * \file src/relay/transforms/merge_composite.cc * \brief Merges expressions matching patterns into functions marked * as 'composite'. This is primarily intended to be used alongside the * external codegen infrastructure to support the case where multiple diff --git a/src/relay/pass/partial_eval.cc b/src/relay/transforms/partial_eval.cc similarity index 100% rename from src/relay/pass/partial_eval.cc rename to src/relay/transforms/partial_eval.cc diff --git a/src/relay/pass/partition_graph.cc b/src/relay/transforms/partition_graph.cc similarity index 99% rename from src/relay/pass/partition_graph.cc rename to src/relay/transforms/partition_graph.cc index d9600bd24abb..30a4e5139adb 100644 --- a/src/relay/pass/partition_graph.cc +++ b/src/relay/transforms/partition_graph.cc @@ -18,7 +18,7 @@ */ /* - * \file src/relay/pass/partition_graph.cc + * \file src/relay/transforms/partition_graph.cc * * \brief Partition an input function into multiple functions according based * on the inserted annotation nodes (i.e. compiler_begin and compiler_end). diff --git a/src/relay/pass/pass_util.h b/src/relay/transforms/pass_util.h similarity index 96% rename from src/relay/pass/pass_util.h rename to src/relay/transforms/pass_util.h index 2d4722bc6759..963553b64cec 100644 --- a/src/relay/pass/pass_util.h +++ b/src/relay/transforms/pass_util.h @@ -19,11 +19,11 @@ /*! * - * \file tvm/relay/pass/pass_util.h + * \file tvm/relay/_transforms/pass_util.h * \brief Utilities for writing passes */ -#ifndef TVM_RELAY_PASS_PASS_UTIL_H_ -#define TVM_RELAY_PASS_PASS_UTIL_H_ +#ifndef TVM_RELAY_TRANSFORMS_PASS_UTIL_H_ +#define TVM_RELAY_TRANSFORMS_PASS_UTIL_H_ #include #include @@ -167,4 +167,4 @@ struct TreeBranchNode : TreeNode { } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_PASS_UTIL_H_ +#endif // TVM_RELAY_TRANSFORMS_PASS_UTIL_H_ diff --git a/src/relay/pass/pattern_util.h b/src/relay/transforms/pattern_util.h similarity index 99% rename from src/relay/pass/pattern_util.h rename to src/relay/transforms/pattern_util.h index 85750f5e2601..e59d5c9bb38b 100644 --- a/src/relay/pass/pattern_util.h +++ b/src/relay/transforms/pattern_util.h @@ -19,12 +19,12 @@ /*! * - * \file tvm/relay/pass/pattern_util.h + * \file tvm/relay/_pattern_util.h * \brief Header of internal operator functions * These can be used for writing passes. */ -#ifndef TVM_RELAY_PASS_PATTERN_UTIL_H_ -#define TVM_RELAY_PASS_PATTERN_UTIL_H_ +#ifndef TVM_RELAY_TRANSFORMS_PATTERN_UTIL_H_ +#define TVM_RELAY_TRANSFORMS_PATTERN_UTIL_H_ #include #include @@ -606,4 +606,4 @@ Expr CastHint(Expr data, DataType dtype); } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_PATTERN_UTIL_H_ +#endif // TVM_RELAY_TRANSFORMS_PATTERN_UTIL_H_ diff --git a/src/relay/pass/print_ir.cc b/src/relay/transforms/print_ir.cc similarity index 97% rename from src/relay/pass/print_ir.cc rename to src/relay/transforms/print_ir.cc index e7ed89b6829d..cf06b5004d3d 100644 --- a/src/relay/pass/print_ir.cc +++ b/src/relay/transforms/print_ir.cc @@ -19,7 +19,7 @@ /*! * - * \file src/relay/pass/print_ir.cc + * \file src/relay/transforms/print_ir.cc * * \brief Print the module IR to help debugging. */ diff --git a/src/relay/pass/simplify_inference.cc b/src/relay/transforms/simplify_inference.cc similarity index 99% rename from src/relay/pass/simplify_inference.cc rename to src/relay/transforms/simplify_inference.cc index fbbe63570771..bc7c15e8dea4 100644 --- a/src/relay/pass/simplify_inference.cc +++ b/src/relay/transforms/simplify_inference.cc @@ -25,7 +25,7 @@ #include #include #include -#include "./pattern_util.h" +#include "pattern_util.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/to_a_normal_form.cc b/src/relay/transforms/to_a_normal_form.cc similarity index 99% rename from src/relay/pass/to_a_normal_form.cc rename to src/relay/transforms/to_a_normal_form.cc index c75afd12e9dc..785162c5fb02 100644 --- a/src/relay/pass/to_a_normal_form.cc +++ b/src/relay/transforms/to_a_normal_form.cc @@ -29,9 +29,9 @@ #include #include #include "let_list.h" -#include "../../support/arena.h" #include "pass_util.h" -#include "dependency_graph.h" +#include "../../support/arena.h" +#include "../analysis/dependency_graph.h" namespace tvm { namespace relay { diff --git a/src/relay/pass/to_cps.cc b/src/relay/transforms/to_cps.cc similarity index 100% rename from src/relay/pass/to_cps.cc rename to src/relay/transforms/to_cps.cc diff --git a/src/relay/pass/to_graph_normal_form.cc b/src/relay/transforms/to_graph_normal_form.cc similarity index 100% rename from src/relay/pass/to_graph_normal_form.cc rename to src/relay/transforms/to_graph_normal_form.cc diff --git a/src/relay/pass/transform_layout.h b/src/relay/transforms/transform_layout.h similarity index 98% rename from src/relay/pass/transform_layout.h rename to src/relay/transforms/transform_layout.h index f18f5d26f248..7204a7ed4f63 100644 --- a/src/relay/pass/transform_layout.h +++ b/src/relay/transforms/transform_layout.h @@ -23,8 +23,8 @@ * \brief Common infrastructure for transforming the layouts. This is used for AlterOpLayout and * ConvertLayout pass. */ -#ifndef TVM_RELAY_PASS_TRANSFORM_LAYOUT_H_ -#define TVM_RELAY_PASS_TRANSFORM_LAYOUT_H_ +#ifndef TVM_RELAY_TRANSFORMS_TRANSFORM_LAYOUT_H_ +#define TVM_RELAY_TRANSFORMS_TRANSFORM_LAYOUT_H_ #include #include @@ -367,4 +367,4 @@ Expr LayoutRewriter(const Call& ref_call, const Array& new_args, const Obj } // namespace relay } // namespace tvm -#endif // TVM_RELAY_PASS_TRANSFORM_LAYOUT_H_ +#endif // TVM_RELAY_TRANSFORMS_TRANSFORM_LAYOUT_H_ diff --git a/src/relay/pass/type_infer.cc b/src/relay/transforms/type_infer.cc similarity index 99% rename from src/relay/pass/type_infer.cc rename to src/relay/transforms/type_infer.cc index ed5f91a3f1e0..3a16d8ff793b 100644 --- a/src/relay/pass/type_infer.cc +++ b/src/relay/transforms/type_infer.cc @@ -43,8 +43,8 @@ #include #include #include -#include "./pass_util.h" -#include "type_solver.h" +#include "pass_util.h" +#include "../analysis/type_solver.h" namespace tvm { namespace relay {