diff --git a/cmake/config.cmake b/cmake/config.cmake index 88bb3a42c3d0..7571a1766040 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -248,12 +248,12 @@ set(USE_SORT ON) # Whether to use Arm Compute Library (ACL) codegen # We provide 2 separate flags since we cannot build the ACL runtime on x86. -# This is useful for cases where you want to cross-compile a relay graph +# This is useful for cases where you want to cross-compile a graph # on x86 then run on AArch. # # An example of how to use this can be found here: docs/deploy/arm_compute_lib.rst. # -# USE_ARM_COMPUTE_LIB - Support for compiling a relay graph offloading supported +# USE_ARM_COMPUTE_LIB - Support for compiling a graph offloading supported # operators to Arm Compute Library. OFF/ON # USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR - Run Arm Compute Library annotated functions via the ACL # runtime. OFF/ON/"path/to/ACL" @@ -263,7 +263,7 @@ set(USE_ARM_COMPUTE_LIB_GRAPH_EXECUTOR OFF) # Whether to build with TensorRT codegen or runtime # Examples are available here: docs/deploy/tensorrt.rst. # -# USE_TENSORRT_CODEGEN - Support for compiling a relay graph where supported operators are +# USE_TENSORRT_CODEGEN - Support for compiling a graph where supported operators are # offloaded to TensorRT. OFF/ON # USE_TENSORRT_RUNTIME - Support for running TensorRT compiled modules, requires presence of # TensorRT library. OFF/ON/"path/to/TensorRT" diff --git a/cmake/modules/CUDA.cmake b/cmake/modules/CUDA.cmake index e9e552b92b70..f9dd4a890369 100644 --- a/cmake/modules/CUDA.cmake +++ b/cmake/modules/CUDA.cmake @@ -70,8 +70,8 @@ if(USE_CUDA) if(USE_CUDNN) message(STATUS "Build with cuDNN support") include_directories(SYSTEM ${CUDA_CUDNN_INCLUDE_DIRS}) - tvm_file_glob(GLOB CUDNN_RELAY_CONTRIB_SRC src/relay/backend/contrib/cudnn/*.cc src/relax/backend/contrib/cudnn/*.cc) - list(APPEND COMPILER_SRCS ${CUDNN_RELAY_CONTRIB_SRC}) + tvm_file_glob(GLOB CUDNN_RELAX_CONTRIB_SRC src/relax/backend/contrib/cudnn/*.cc) + list(APPEND COMPILER_SRCS ${CUDNN_RELAX_CONTRIB_SRC}) tvm_file_glob(GLOB CONTRIB_CUDNN_SRCS src/runtime/contrib/cudnn/*.cc) list(APPEND RUNTIME_SRCS ${CONTRIB_CUDNN_SRCS}) list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIBRARY}) @@ -95,7 +95,7 @@ if(USE_CUDA) if(USE_CUBLAS) message(STATUS "Build with cuBLAS support") - tvm_file_glob(GLOB CUBLAS_CONTRIB_SRC src/relay/backend/contrib/cublas/*.cc src/relax/backend/contrib/cublas/*.cc) + tvm_file_glob(GLOB CUBLAS_CONTRIB_SRC src/relax/backend/contrib/cublas/*.cc) list(APPEND COMPILER_SRCS ${CUBLAS_CONTRIB_SRC}) tvm_file_glob(GLOB CONTRIB_CUBLAS_SRCS src/runtime/contrib/cublas/*.cc) list(APPEND RUNTIME_SRCS ${CONTRIB_CUBLAS_SRCS}) diff --git a/cmake/modules/contrib/ArmComputeLib.cmake b/cmake/modules/contrib/ArmComputeLib.cmake index 681a425ea42e..f9ff5f6b163c 100644 --- a/cmake/modules/contrib/ArmComputeLib.cmake +++ b/cmake/modules/contrib/ArmComputeLib.cmake @@ -18,7 +18,7 @@ # We separate the codegen and runtime build since ACL can only be built # for AArch. In the world where we take the cross compilation approach, # which is common with arm devices, we need to be able to cross-compile -# a relay graph on x86 for AArch and then run the graph on AArch. +# a graph on x86 for AArch and then run the graph on AArch. if(USE_ARM_COMPUTE_LIB) tvm_file_glob(GLOB ACL_RUNTIME_MODULE src/runtime/contrib/arm_compute_lib/acl_runtime.cc) diff --git a/cmake/modules/contrib/BNNS.cmake b/cmake/modules/contrib/BNNS.cmake index 95c034b1b9ec..b224d881885b 100644 --- a/cmake/modules/contrib/BNNS.cmake +++ b/cmake/modules/contrib/BNNS.cmake @@ -17,9 +17,8 @@ if(USE_BNNS STREQUAL "ON") add_definitions(-DUSE_JSON_RUNTIME=1) - tvm_file_glob(GLOB BNNS_RELAY_CONTRIB_SRC src/relay/backend/contrib/bnns/*.cc) + tvm_file_glob(GLOB BNNS_RELAY_CONTRIB_SRC "") list(APPEND COMPILER_SRCS ${BNNS_RELAY_CONTRIB_SRC}) - list(APPEND COMPILER_SRCS ${JSON_RELAY_CONTRIB_SRC}) list(APPEND TVM_RUNTIME_LINKER_LIBS "-framework Accelerate") diff --git a/cmake/modules/contrib/DNNL.cmake b/cmake/modules/contrib/DNNL.cmake index 631b3e47aba1..e3d75677b547 100644 --- a/cmake/modules/contrib/DNNL.cmake +++ b/cmake/modules/contrib/DNNL.cmake @@ -21,7 +21,7 @@ if(IS_DIRECTORY ${USE_DNNL}) message(WARNING "Cannot find DNNL library at ${USE_DNNL}.") else() add_definitions(-DUSE_JSON_RUNTIME=1) - tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/relay/backend/contrib/dnnl/*.cc src/relax/backend/contrib/dnnl/*.cc) + tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/relax/backend/contrib/dnnl/*.cc) list(APPEND COMPILER_SRCS ${DNNL_CONTRIB_SRC}) list(APPEND TVM_RUNTIME_LINKER_LIBS ${EXTERN_LIBRARY_DNNL}) @@ -34,7 +34,7 @@ if(IS_DIRECTORY ${USE_DNNL}) endif() elseif((USE_DNNL STREQUAL "ON") OR (USE_DNNL STREQUAL "JSON")) add_definitions(-DUSE_JSON_RUNTIME=1) - tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/relay/backend/contrib/dnnl/*.cc src/relax/backend/contrib/dnnl/*.cc) + tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/relax/backend/contrib/dnnl/*.cc) list(APPEND COMPILER_SRCS ${DNNL_CONTRIB_SRC}) find_library(EXTERN_LIBRARY_DNNL dnnl) @@ -46,9 +46,6 @@ elseif((USE_DNNL STREQUAL "ON") OR (USE_DNNL STREQUAL "JSON")) list(APPEND RUNTIME_SRCS ${DNNL_CONTRIB_SRC}) message(STATUS "Build with DNNL JSON runtime: " ${EXTERN_LIBRARY_DNNL}) elseif(USE_DNNL STREQUAL "C_SRC") - tvm_file_glob(GLOB DNNL_RELAY_CONTRIB_SRC src/relay/backend/contrib/dnnl/*.cc) - list(APPEND COMPILER_SRCS ${DNNL_RELAY_CONTRIB_SRC}) - find_library(EXTERN_LIBRARY_DNNL dnnl) list(APPEND TVM_RUNTIME_LINKER_LIBS ${EXTERN_LIBRARY_DNNL}) tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/runtime/contrib/dnnl/dnnl.cc diff --git a/cmake/modules/contrib/Mrvl.cmake b/cmake/modules/contrib/Mrvl.cmake index 52907011e632..3a6228d2396e 100644 --- a/cmake/modules/contrib/Mrvl.cmake +++ b/cmake/modules/contrib/Mrvl.cmake @@ -24,9 +24,4 @@ if(USE_MRVL) src/runtime/contrib/mrvl/mrvl_sw_runtime_lib.cc ) list(APPEND RUNTIME_SRCS ${RUNTIME_MRVL_SRCS}) - file(GLOB COMPILER_MRVL_SRCS - src/relay/backend/contrib/mrvl/codegen.cc - src/relay/backend/contrib/mrvl/compiler_attr.cc - ) - list(APPEND COMPILER_SRCS ${COMPILER_MRVL_SRCS}) endif(USE_MRVL) diff --git a/cmake/modules/contrib/TensorRT.cmake b/cmake/modules/contrib/TensorRT.cmake index a749b6e80fd2..a9729ed99656 100644 --- a/cmake/modules/contrib/TensorRT.cmake +++ b/cmake/modules/contrib/TensorRT.cmake @@ -23,7 +23,7 @@ include (FindPackageHandleStandardArgs) if(USE_TENSORRT_CODEGEN) message(STATUS "Build with TensorRT codegen") - tvm_file_glob(GLOB COMPILER_TENSORRT_SRCS src/relay/backend/contrib/tensorrt/*.cc src/relax/backend/contrib/tensorrt/*.cc) + tvm_file_glob(GLOB COMPILER_TENSORRT_SRCS src/relax/backend/contrib/tensorrt/*.cc) set_source_files_properties(${COMPILER_TENSORRT_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations") tvm_file_glob(GLOB RUNTIME_TENSORRT_SRCS src/runtime/contrib/tensorrt/tensorrt_runtime.cc) set_source_files_properties(${RUNTIME_TENSORRT_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations") diff --git a/docs/arch/index.rst b/docs/arch/index.rst index 4df78f6c3cd1..c13a518a6263 100644 --- a/docs/arch/index.rst +++ b/docs/arch/index.rst @@ -114,7 +114,7 @@ Target Translation The target translation phase transforms an IRModule to the corresponding target executable format. For backends such as x86 and ARM, we use the LLVM IRBuilder to build in-memory LLVM IR. We can also generate source-level languages such as CUDA C and OpenCL. -Finally, we support direct translations of a Relay function (sub-graph) to specific targets via external code generators. +Finally, we support direct translations of a Relax function (sub-graph) to specific targets via external code generators. It is important that the final code generation phase is as lightweight as possible. Vast majority of transformations and lowering should be performed before the target translation phase. @@ -175,8 +175,8 @@ In summary, the key data structures in the compilation flows are: Most parts of the compilation are transformations among the key data structures. -- relay/transform and tir/transform are determinstic rule-based transformations -- auto_scheduler and autotvm contains the search-based transformations +- relax/transform and tir/transform are determinstic rule-based transformations +- meta-schedule contains the search-based transformations Finally, the compilation flow example is only a typical use-case of the TVM stack. We expose these key data structures and transformations to python and C++ APIs. As a result, you can use TVM just like the way you use numpy, @@ -247,7 +247,7 @@ The ability to save/store, and inspect an IR node provides a foundation for maki tvm/ir ------ The `tvm/ir` folder contains the unified data structure and interfaces across for all IR function variants. -The components in `tvm/ir` are shared by `tvm/relay` and `tvm/tir`, notable ones include +The components in `tvm/ir` are shared by `tvm/relax` and `tvm/tir`, notable ones include - IRModule - Type diff --git a/docs/arch/pass_infra.rst b/docs/arch/pass_infra.rst index 352b1524c477..1df8e2e105a7 100644 --- a/docs/arch/pass_infra.rst +++ b/docs/arch/pass_infra.rst @@ -20,7 +20,7 @@ Pass Infrastructure =================== -Both Relay and TVM IR contain a series of optimization passes which improve performance metrics +Both Relax and TVM IR contain a series of optimization passes which improve performance metrics of models such as mean inference, memory footprint, or power consumption for specific devices. There is a suite of standard optimizations as well as machine learning-specific optimizations including constant folding, dead code @@ -31,7 +31,7 @@ transformation using the analysis result collected during and/or before traversa However, as TVM evolves quickly, the need for a more systematic and efficient way to manage these passes is becoming apparent. In addition, a generic framework that manages the passes across different layers of the TVM stack (e.g. -Relay and tir) paves the way for developers to quickly prototype and plug the +Relax and tir) paves the way for developers to quickly prototype and plug the implemented passes into the system. This doc describes the design of such an infra that takes the advantage of the @@ -51,7 +51,7 @@ scheme through `Sequential`_ and `Block`_, respectively. With such constructs, these modern frameworks are able to conveniently add modules/layers to their containers and build up neural networks easily. -The design of the Relay pass infra is largely inspired by the hierarchical +The design of the TVM pass infra is largely inspired by the hierarchical pass manager used in LLVM and the block-style containers used in the popular deep learning frameworks. The major goals of the pass infra include: @@ -170,7 +170,7 @@ Pass Constructs ^^^^^^^^^^^^^^^ The pass infra is designed in a hierarchical manner, and it could work at -different granularities of Relay/tir programs. A pure virtual class ``PassNode`` is +different granularities of Relax/tir programs. A pure virtual class ``PassNode`` is introduced to serve as the base of the different optimization passes. This class contains several virtual methods that must be implemented by the subclasses at the level of modules, functions, or sequences of passes. @@ -200,7 +200,7 @@ Module-Level Passes Module level passes are geared mainly for global and inter-procedural optimizations (IPO), which are similar to the module pass used in LLVM. Some -typical passes in Relay that need the global picture of a module, such as +typical passes in Relax that need the global picture of a module, such as A-normal form conversion and lambda lifting, etc., fall into this set. At this level, users can even add and/or delete functions in a module. Note that all passes @@ -226,13 +226,13 @@ Function-Level Passes ^^^^^^^^^^^^^^^^^^^^^ Function-level passes are used to implement various intra-function level -optimizations for a given Relay/tir module. It fetches one function at a time from -the function list of a module for optimization and yields a rewritten Relay +optimizations for a given Relax/tir module. It fetches one function at a time from +the function list of a module for optimization and yields a rewritten Relax ``Function`` or tir ``PrimFunc``. Most of passes can be classified into this category, such as -common subexpression elimination and inference simplification in Relay as well as vectorization +common subexpression elimination and inference simplification in Relax as well as vectorization and flattening storage in tir, etc. -Note that the scope of passes at this level is either a Relay function or a tir primitive function. +Note that the scope of passes at this level is either a Relax function or a tir primitive function. Therefore, we cannot add or delete a function through these passes as they are not aware of the global information. diff --git a/include/tvm/ir/transform.h b/include/tvm/ir/transform.h index 5828d98206ad..503b2c8d141a 100644 --- a/include/tvm/ir/transform.h +++ b/include/tvm/ir/transform.h @@ -32,18 +32,18 @@ * - Reducing the effort required to implement new passes for compiler * developers, etc. * - * Similar to LLVM's pass manager, we designed the Relay/Relax pass manager to work + * Similar to LLVM's pass manager, we designed the Relax pass manager to work * different granularity, i.e. module level, function level, and even sequential * passe that contains a host of passes. * * However, we also extend the functionality of the traditional pass manager * with the consideration of requirements/convention from deep learning - * frameworks, such as Pytorch and Gluon, etc. Each pass in the Relay/Relax pass + * frameworks, such as Pytorch and Gluon, etc. Each pass in the Relax pass * manager performs the IRModule -> IRModule transformation. All * different types of passes, including the sequential-level pass object, are * essentially pass objects. This design, therefore, effectively provides users * a consistent and convenient interface, i.e. Pass, to play with. It offers a - * means to ease the development and testing of Relay/Relax passes. For example, with + * means to ease the development and testing of Relax passes. For example, with * the pass manager, external users will be able to have custom passes correctly * scheduled without having to modify a single handcrafted pass order. * @@ -387,7 +387,7 @@ class PassInfo : public ObjectRef { /*! * \brief PassNode is the base type of differnt types of optimization passes. * It is designed as a pure class and implemented by different pass subclasses - * at different granularity of Relay/Relax nodes. + * at different granularity of Relax nodes. */ class PassNode : public Object { public: @@ -460,7 +460,7 @@ class Pass : public ObjectRef { }; /*! - * \brief The SequentialNode contains a set of passes that transform Relay/Relax + * \brief The SequentialNode contains a set of passes that transform Relax * programs from one AST to another semantically equivalent one. * * One example of this level of pass is that the pass manager needs to correctly diff --git a/include/tvm/ir/type.h b/include/tvm/ir/type.h index 04a59c7c422f..5faaa31ca23b 100644 --- a/include/tvm/ir/type.h +++ b/include/tvm/ir/type.h @@ -21,7 +21,7 @@ * \file tvm/ir/type.h * \brief IR/AST nodes for the unified type system in TVM. * - * We use Relay's type system as the unified type system + * We use TVM's type system as the unified type system * throughout the stack. * * This file contains types that are common across IR variants. @@ -62,7 +62,7 @@ namespace tvm { /*! * \brief Type is the base type of all types. * - * Relay's type system contains following subclasses: + * TVM's type system contains following subclasses: * * - PrimType: type of primitive type values used in the low-level IR. * - FuncType: type of a function. diff --git a/include/tvm/meta_schedule/builder.h b/include/tvm/meta_schedule/builder.h index e41dc900a00d..cb8bd5ed9a68 100644 --- a/include/tvm/meta_schedule/builder.h +++ b/include/tvm/meta_schedule/builder.h @@ -40,7 +40,7 @@ class BuilderInputNode : public runtime::Object { IRModule mod; /*! \brief The target to be built for. */ Target target; - /*! \brief Parameters for Relay build module. */ + /*! \brief Parameters for Relax build module. */ Optional> params; void VisitAttrs(tvm::AttrVisitor* v) { @@ -63,7 +63,7 @@ class BuilderInput : public runtime::ObjectRef { * \brief Constructor of BuilderInput. * \param mod The IRModule to be built. * \param target The target to be built for. - * \param params Parameters for Relay build module. + * \param params Parameters for Relax build module. */ TVM_DLL explicit BuilderInput(IRModule mod, Target target, Optional> params = NullOpt); diff --git a/include/tvm/target/virtual_device.h b/include/tvm/target/virtual_device.h index 5c6db4bc24d6..3c8782a90e25 100644 --- a/include/tvm/target/virtual_device.h +++ b/include/tvm/target/virtual_device.h @@ -58,7 +58,7 @@ constexpr int kInvalidDeviceType = -1; * \brief Describes at compile time the constraints on where data is to be stored at runtime * down to the (virtual) device and memory scope level, and how to compile code to compute that * data. Used by the \p PlanDevices pass to collect and solve (virtual) device constraints for - * the whole Relay program. + * the whole Relax program. * * Is a quadruple of: * - A \p device_type (\p DLDeviceType). May be \p kInvalidDeviceType if unconstrained. @@ -79,7 +79,7 @@ constexpr int kInvalidDeviceType = -1; * then the function body is also executed on that device. * * - * By 'execution' we include both (fused) primitive operators, and all the Relay expressions + * By 'execution' we include both (fused) primitive operators, and all the Relax expressions * surrounding them which coordinates data and control flow. Again, typically non-primitive * operators must be executed on a 'CPU'-like device with good support for control flow. * diff --git a/include/tvm/topi/transform.h b/include/tvm/topi/transform.h index bada827c813d..faacd2ce5760 100644 --- a/include/tvm/topi/transform.h +++ b/include/tvm/topi/transform.h @@ -775,7 +775,7 @@ inline Tensor dynamic_strided_slice(const Tensor& x, const Array& begi arith::Analyzer analyzer; for (size_t i = 0; i < num_slice_axes; ++i) { - // Check ProducerLoad to keep backward compatibility for Relay. + // Check ProducerLoad to keep backward compatibility for Relax. if (!begin[i]->IsInstance() && !end[i]->IsInstance() && !strides[i]->IsInstance()) { out_shape.push_back( @@ -840,7 +840,7 @@ inline te::Tensor dynamic_strided_slice(const te::Tensor& x, const te::Tensor& b } /*! - * \brief Calculate the output shape of strided_slice, the entry point for Relay type relation + * \brief Calculate the output shape of strided_slice, the entry point for Relax type relation * * \param ishape The input tensor shape * \param begin The indices to begin with in the slicing diff --git a/python/gen_requirements.py b/python/gen_requirements.py index 32674e6a65e3..e31f870ca0d3 100644 --- a/python/gen_requirements.py +++ b/python/gen_requirements.py @@ -26,9 +26,9 @@ TVM can be roughly broken into these named pieces along the lines of Python dependencies: - "core": A core piece, which is intended to be buildable with very few external dependencies. Users - can use Relay, compile models, and run autotuning with this part. + can use Relax, compile models, and run autotuning with this part. - "importer-": Model importers, which convert models defined in various other tools (i.e. - TensorFlow, PyTorch, etc) into Relay models. + TensorFlow, PyTorch, etc) into Relax models. - Extra features (i.e. XGBoost in AutoTVM). These enhance TVM's functionality, but aren't required for basic operation. @@ -74,7 +74,7 @@ ], ), ), - # Relay frontends. + # frontends. ("importer-coreml", ("Requirements for the CoreML importer", ["coremltools"])), ( "importer-keras", diff --git a/python/setup.py b/python/setup.py index 30b1e2174d02..ad0ef6ffde49 100644 --- a/python/setup.py +++ b/python/setup.py @@ -206,11 +206,6 @@ def is_pure(self): setup_kwargs = {"include_package_data": True} -def get_package_data_files(): - # Relay standard libraries - return [] - - def long_description_contents(): with open(pathlib.Path(CURRENT_DIR).resolve().parent / "README.md", encoding="utf-8") as readme: description = readme.read() @@ -255,7 +250,6 @@ def long_description_contents(): extras_require=extras_require, packages=find_packages(), package_dir={"tvm": "tvm"}, - package_data={"tvm": get_package_data_files()}, distclass=BinaryDistribution, ext_modules=config_cython(), **setup_kwargs, diff --git a/python/tvm/__init__.py b/python/tvm/__init__.py index b853c4fa616e..d8d46f2ba012 100644 --- a/python/tvm/__init__.py +++ b/python/tvm/__init__.py @@ -66,7 +66,7 @@ # Contrib initializers from .contrib import rocm as _rocm, nvcc as _nvcc -# Relay and Relax contain modules that are only available in compiler package +# Relax contain modules that are only available in compiler package # Do not import them if TVM is built with runtime only if not _RUNTIME_ONLY: from . import relax diff --git a/python/tvm/contrib/cutlass/build.py b/python/tvm/contrib/cutlass/build.py index 9dba93072623..e12ce93e270b 100644 --- a/python/tvm/contrib/cutlass/build.py +++ b/python/tvm/contrib/cutlass/build.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. # pylint: disable=invalid-name, dangerous-default-value, arguments-differ -"""Driver for partitioning and building a Relay module for CUTLASS offload.""" +"""Driver for partitioning and building a Relax module for CUTLASS offload.""" import itertools import logging import multiprocessing @@ -298,7 +298,7 @@ def tune_cutlass_kernels( Parameters ---------- mod : IRModule - The Relay module with cutlass partitions. + The IRModule with cutlass partitions. sm : int An integer specifying the compute capability. For example, 75 for Turing and diff --git a/python/tvm/contrib/mrvl.py b/python/tvm/contrib/mrvl.py index 7004bb5b9db6..3cf393b34160 100644 --- a/python/tvm/contrib/mrvl.py +++ b/python/tvm/contrib/mrvl.py @@ -208,7 +208,7 @@ def get_nodes_json_string(graph_json): @tvm._ffi.register_func("tvm.mrvl.ModifyConstNames") def modify_const_names(nodes_json_str, consts_json_str): - """This takes the graph module returned by relay.build an generates nodes and constant + """This takes the graph module returned by build an generates nodes and constant meta data suitable for compilation by the back end. Parameters diff --git a/python/tvm/contrib/msc/framework/tensorflow/frontend/translate.py b/python/tvm/contrib/msc/framework/tensorflow/frontend/translate.py index 6eb13b6ce076..1accaba8595a 100644 --- a/python/tvm/contrib/msc/framework/tensorflow/frontend/translate.py +++ b/python/tvm/contrib/msc/framework/tensorflow/frontend/translate.py @@ -50,7 +50,7 @@ def from_tensorflow( build_config: dict The config for build MSCGraph. opt_config: dict - The config for optimize the relay before translate. + The config for optimize before translate. as_msc: bool Set to to return msc graph, otherwise relax mod diff --git a/python/tvm/contrib/msc/framework/torch/frontend/translate.py b/python/tvm/contrib/msc/framework/torch/frontend/translate.py index 32626b904c30..b11051376014 100644 --- a/python/tvm/contrib/msc/framework/torch/frontend/translate.py +++ b/python/tvm/contrib/msc/framework/torch/frontend/translate.py @@ -82,7 +82,7 @@ def from_torch( build_config: dict The config for build MSCGraph. opt_config: dict - The config for optimize the relay before translate. + The config for optimize before translate. as_msc: bool Set to to return msc graph, otherwise relax mod custom_convert_map: dict diff --git a/python/tvm/ir/transform.py b/python/tvm/ir/transform.py index c00a4de6dabb..7fe8402fe339 100644 --- a/python/tvm/ir/transform.py +++ b/python/tvm/ir/transform.py @@ -52,7 +52,7 @@ def __init__(self, opt_level, name, required=None, traceable=False): @tvm._ffi.register_object("transform.PassContext") class PassContext(tvm.runtime.Object): - """The basis where a Relay optimization/analysis runs on. + """The basis where a TVM optimization/analysis runs on. Each pass context contains a number of auxiliary information that is used to help an optimization pass. Such information includes the error reporter to record the errors of during the optimization, etc. diff --git a/python/tvm/ir/type.py b/python/tvm/ir/type.py index 914275415c89..3d372012b649 100644 --- a/python/tvm/ir/type.py +++ b/python/tvm/ir/type.py @@ -34,7 +34,7 @@ def __ne__(self, other): return not self.__eq__(other) def same_as(self, other): - """Compares two Relay types by referential equality.""" + """Compares two TVM types by referential equality.""" return super().__eq__(other) diff --git a/python/tvm/meta_schedule/builder/builder.py b/python/tvm/meta_schedule/builder/builder.py index fcab906e6207..221077cfbd6c 100644 --- a/python/tvm/meta_schedule/builder/builder.py +++ b/python/tvm/meta_schedule/builder/builder.py @@ -40,7 +40,7 @@ class BuilderInput(Object): target : Target The target to be built for. params: Optional[Dict[str, NDArray]] - The parameters for Relay build module + The parameters for Relax build module """ mod: IRModule @@ -62,7 +62,7 @@ def __init__( target : Target The target to be built for. params: Optional[Dict[str, NDArray]] - The parameters for Relay build module + The parameters for Relax build module """ self.__init_handle_by_constructor__( _ffi_api.BuilderInput, # type: ignore # pylint: disable=no-member diff --git a/python/tvm/relax/dpl/pattern.py b/python/tvm/relax/dpl/pattern.py index 0d38b6bc87fa..3d076e8fad35 100644 --- a/python/tvm/relax/dpl/pattern.py +++ b/python/tvm/relax/dpl/pattern.py @@ -198,9 +198,8 @@ def match(self, expr, var2val: Optional[Dict[Var, Expr]] = None) -> bool: Note ---- - Unlike Relay whose function is an expression, functions in Relax consist - of blocks of bindings that are not syntactically connected. We use a - mapping (i.e., var2val) to mitigate the gap. For example, when matching + Functions in Relax consist of blocks of bindings that are not syntactically connected. + We use a mapping (i.e., var2val) to mitigate the gap. For example, when matching "relax.add(lv0, lv1)", given var2val, we match lv0's bound expression when the recursive pattern matching goes to check lv0. The var2val mapping can be computed through the tvm.relax.analysis.get_var2val function. diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py index d5d25fb6c2ff..ec3fc28b1d8a 100644 --- a/python/tvm/testing/utils.py +++ b/python/tvm/testing/utils.py @@ -67,7 +67,6 @@ def test_something(): import copyreg import ctypes import functools -import hashlib import itertools import logging import os @@ -1878,47 +1877,6 @@ def install_request_hook(depth: int) -> None: request_hook.init() -def fetch_model_from_url( - url: str, - model_format: str, - sha256: str, -) -> Tuple[tvm.ir.module.IRModule, dict]: - """Testing function to fetch a model from a URL and return it as a Relay - model. Downloaded files are cached for future re-use. - - Parameters - ---------- - url : str - The URL or list of URLs to try downloading the model from. - - model_format: str - The file extension of the model format used. - - sha256 : str - The sha256 hex hash to compare the downloaded model against. - - Returns - ------- - (mod, params) : object - The Relay representation of the downloaded model. - """ - - rel_path = f"model_{sha256}.{model_format}" - file = tvm.contrib.download.download_testdata(url, rel_path, overwrite=False) - - # Check SHA-256 hash - file_hash = hashlib.sha256() - with open(file, "rb") as f: - for block in iter(lambda: f.read(2**24), b""): - file_hash.update(block) - - if file_hash.hexdigest() != sha256: - raise FileNotFoundError("SHA-256 hash for model does not match") - - tvmc_model = load_model(file, model_format) - return tvmc_model.mod, tvmc_model.params - - def _mark_parameterizations(*params, marker_fn, reason): """ Mark tests with a nodeid parameters that exactly matches one in params. diff --git a/python/tvm/tir/analysis/analysis.py b/python/tvm/tir/analysis/analysis.py index 72f18acca500..915b7f765c10 100644 --- a/python/tvm/tir/analysis/analysis.py +++ b/python/tvm/tir/analysis/analysis.py @@ -223,10 +223,6 @@ def estimate_tir_flops(stmt_or_mod: Union[Stmt, IRModule]) -> float: return _ffi_api.EstimateTIRFlops(stmt_or_mod) # type: ignore # pylint: disable=no-member -# NOTE: relay_func_type in the following two functions should be relay.FuncType however that would -# introduce a cycling dependency. We make do with Object. - - def undefined_vars(node: Union[Stmt, PrimExpr], defs: Optional[List[Var]] = None) -> List[Var]: """Find undefined vars in a TIR statement or expression. diff --git a/rust/tvm-rt/src/module.rs b/rust/tvm-rt/src/module.rs index b98d9c102baa..754ebf44262e 100644 --- a/rust/tvm-rt/src/module.rs +++ b/rust/tvm-rt/src/module.rs @@ -57,7 +57,7 @@ crate::external! { fn save_to_file(module: Module, name: TString, fmt: TString); // TODO(@jroesch): we need to refactor this - #[name("tvm.relay.module_export_library")] + #[name("tvm.relax.module_export_library")] fn export_library(module: Module, file_name: TString); } diff --git a/src/ir/transform.cc b/src/ir/transform.cc index 0ed80310eb97..a7208be9dd22 100644 --- a/src/ir/transform.cc +++ b/src/ir/transform.cc @@ -333,7 +333,7 @@ IRModule Pass::AssertImmutableModule(const IRModule& mod, const PassNode* node, /*! * \brief Module-level passes are designed to implement global * analysis/optimizations, i.e. interprocedural optimizations (IPO), etc. Passes - * at this level have the full control of a given Relay program including + * at this level have the full control of a given Relax program including * addition and deletion of functions. */ class ModulePassNode : public PassNode { diff --git a/src/node/structural_equal.cc b/src/node/structural_equal.cc index 614669a412d0..aadeb77f8841 100644 --- a/src/node/structural_equal.cc +++ b/src/node/structural_equal.cc @@ -381,7 +381,7 @@ class SEqualHandlerDefault::Impl { cfg->path_to_underline.push_back(first_mismatch_->value()->lhs_path); // The TVMScriptPrinter::Script will fallback to Repr printer, // if the root node to print is not supported yet, - // e.g. Relay nodes, ArrayNode, MapNode, etc. + // e.g. Relax nodes, ArrayNode, MapNode, etc. oss << ":" << std::endl << TVMScriptPrinter::Script(root_lhs_.value(), cfg); } } else { @@ -396,7 +396,7 @@ class SEqualHandlerDefault::Impl { cfg->path_to_underline.push_back(first_mismatch_->value()->rhs_path); // The TVMScriptPrinter::Script will fallback to Repr printer, // if the root node to print is not supported yet, - // e.g. Relay nodes, ArrayNode, MapNode, etc. + // e.g. Relax nodes, ArrayNode, MapNode, etc. oss << ":" << std::endl << TVMScriptPrinter::Script(root_rhs_.value(), cfg); } } else { diff --git a/src/relax/backend/contrib/cutlass/codegen.cc b/src/relax/backend/contrib/cutlass/codegen.cc index 980243cf8128..c1452c20ac5d 100644 --- a/src/relax/backend/contrib/cutlass/codegen.cc +++ b/src/relax/backend/contrib/cutlass/codegen.cc @@ -348,7 +348,7 @@ class CutlassModuleCodegen { private: std::pair> GenCutlassFunc(const Function& function, const Map& options) { - ICHECK(function.defined()) << "Input error: expect a Relay function."; + ICHECK(function.defined()) << "Input error: expect a Relax function."; auto sid = GetExtSymbol(function); func_names_.push_back(sid); diff --git a/src/relax/ir/dataflow_pattern.cc b/src/relax/ir/dataflow_pattern.cc index 220f4e0ab5b7..d8913c0c9f88 100644 --- a/src/relax/ir/dataflow_pattern.cc +++ b/src/relax/ir/dataflow_pattern.cc @@ -19,13 +19,12 @@ /*! * \file src/relax/ir/dataflow_pattern.cc - * \brief The dataflow pattern language for Relax (inherited from Relay). + * \brief The dataflow pattern language for Relax */ #include #include -#include #include #include diff --git a/src/relax/ir/dataflow_pattern_functor.cc b/src/relax/ir/dataflow_pattern_functor.cc index 620a2d58db63..2a0c73501850 100644 --- a/src/relax/ir/dataflow_pattern_functor.cc +++ b/src/relax/ir/dataflow_pattern_functor.cc @@ -19,7 +19,7 @@ /*! * \file src/tvm/relax/dataflow_matcher.cc - * \brief The dataflow pattern matcher for Relay. + * \brief The dataflow pattern matcher for Relax. */ #include diff --git a/src/relax/ir/transform.cc b/src/relax/ir/transform.cc index ddf252f2cce6..d80481cb0f67 100644 --- a/src/relax/ir/transform.cc +++ b/src/relax/ir/transform.cc @@ -34,7 +34,6 @@ namespace transform { TVM_REGISTER_PASS_CONFIG_OPTION("relax.fallback_device_type", IntImm); -// TODO(@yuchen): will need to dedup with FunctionPass in Relay when we upstream class FunctionPass; /*! diff --git a/src/runtime/const_loader_module.cc b/src/runtime/const_loader_module.cc index ecedaf6321c9..9831639a1657 100644 --- a/src/runtime/const_loader_module.cc +++ b/src/runtime/const_loader_module.cc @@ -21,7 +21,7 @@ * \file src/runtime/const_loader_module.cc * \brief A wrapper for initializing imported modules using constant NDArray. This * module is intended to be used by various runtime in the TVM stack, i.e. - * graph executor, relay VM, AOT runtime, and various user defined runtimes. It + * graph executor, relax VM, AOT runtime, and various user defined runtimes. It * paves the way to separate the code and metedata, which makes compilation * and/or interpretation more convenient. In addition, the clear separation of * code and constants significantly reduces the efforts for handling external @@ -34,9 +34,6 @@ #include #include -#include - -#include "meta_data.h" namespace tvm { namespace runtime { diff --git a/src/runtime/contrib/dnnl/dnnl.cc b/src/runtime/contrib/dnnl/dnnl.cc index 9ef464064753..54ee63548883 100644 --- a/src/runtime/contrib/dnnl/dnnl.cc +++ b/src/runtime/contrib/dnnl/dnnl.cc @@ -306,7 +306,6 @@ extern "C" void dnnl_bn(float* data, float* gamma, float* beta, float* mean, flo free(weight); } -// should comply with src/relay/backend/contrib/dnnl/codegen.cc #define DNNL_BINARY_ADD 0 #define DNNL_BINARY_MUL 1 diff --git a/src/runtime/contrib/dnnl/dnnl_json_runtime.cc b/src/runtime/contrib/dnnl/dnnl_json_runtime.cc index f0dfcc32c5db..09d93660f9db 100644 --- a/src/runtime/contrib/dnnl/dnnl_json_runtime.cc +++ b/src/runtime/contrib/dnnl/dnnl_json_runtime.cc @@ -422,7 +422,7 @@ class DNNLJSONRuntime : public JSONRuntimeBase { // dst_layout == "" means to use data_layout if (dst_layout.empty()) dst_layout = src_layout; - // Minus one for DNNL representation. No dilation for DNNL is 0, for relay is 1. + // Minus one for DNNL representation. No dilation for DNNL is 0, for relax is 1. for (auto& d : dilates) d--; // Take into account provided layout strings diff --git a/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc b/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc index 84b178b3139f..44b88022a7ce 100644 --- a/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc +++ b/src/runtime/contrib/mrvl/mrvl_hw_runtime.cc @@ -145,8 +145,8 @@ void get_tvmc_callbacks(const char* so_path, ml_tvmc_cb* obj) { /*! * \brief A json runtime that compiles the serialized JSON format to a binary for Marvell hardware and then runs the generated binary on the target hardware. - * \param symbol_name The name of the subgraph / relay function - * \param nodes_json The serialized JSON representation of relay function + * \param symbol_name The name of the subgraph / function + * \param nodes_json The serialized JSON representation of function * \param bin_code The binary code generated by the Marvell backend compiler for the subgraph * \param input_count Number of subgraph inputs * \param output_count Number of subgraph outputs diff --git a/src/runtime/contrib/mrvl/mrvl_runtime.cc b/src/runtime/contrib/mrvl/mrvl_runtime.cc index 337d81c8a0be..bd81df3cc21f 100644 --- a/src/runtime/contrib/mrvl/mrvl_runtime.cc +++ b/src/runtime/contrib/mrvl/mrvl_runtime.cc @@ -43,8 +43,8 @@ namespace contrib { /*! * \brief A json runtime that compiles the serialized JSON format to a binary for Marvell hardware and then runs the generated binary using the Marvell software simulator (MlModel). - * \param symbol_name The name of the subgraph / relay function - * \param nodes_json The serialized JSON representation of relay function + * \param symbol_name The name of the subgraph / function + * \param nodes_json The serialized JSON representation of function * \param bin_code The binary code generated by the Marvell compiler for the subgraph */ diff --git a/src/runtime/contrib/tensorrt/tensorrt_builder.cc b/src/runtime/contrib/tensorrt/tensorrt_builder.cc index 436a6db4c8d4..9bf793bd3e49 100644 --- a/src/runtime/contrib/tensorrt/tensorrt_builder.cc +++ b/src/runtime/contrib/tensorrt/tensorrt_builder.cc @@ -246,8 +246,8 @@ nvinfer1::ITensor* TensorRTBuilder::GetInputAsTensor(const TensorRTOpInput& inpu auto shape = input.weight_shape; // Remove batch dim when not in explicit batch mode. // Example: - // x = Relay dims (1, 32, 224, 224) which becomes TRT Dims (32, 224, 224) - // y = Relay dims (1, 32) + // x = dims (1, 32, 224, 224) which becomes TRT Dims (32, 224, 224) + // y = dims (1, 32) // z = add(x, y) // y needs to have TRT dims (32,), otherwise broadcasting will result in z having // TRT Dims(1, 32, 224, 224) when it should be (32, 224, 224). diff --git a/src/runtime/contrib/tensorrt/tensorrt_ops.cc b/src/runtime/contrib/tensorrt/tensorrt_ops.cc index 64a6d6687712..afb2a021f32a 100644 --- a/src/runtime/contrib/tensorrt/tensorrt_ops.cc +++ b/src/runtime/contrib/tensorrt/tensorrt_ops.cc @@ -18,7 +18,7 @@ /*! * \file runtime/contrib/tensorrt/tensorrt_ops.cc - * \brief Converters from Relay ops into TensorRT layers. Converters should + * \brief Converters from ops into TensorRT layers. Converters should * inherit from TensorRTOpConverter and implement the Convert() method. */ @@ -840,7 +840,7 @@ class UnaryOpConverter : public TensorRTOpConverter { ~UnaryOpConverter() = default; void Convert(TensorRTOpConverterParams* params) const { - // The following ops are supported by TRT but don't exist in relay yet: + // The following ops are supported by TRT but don't exist in TVM yet: // recip, tan, sinh, cosh, asin, acos, asinh, acosh, atanh static const std::unordered_map op_map = { {"exp", nvinfer1::UnaryOperation::kEXP}, diff --git a/src/runtime/contrib/tensorrt/tensorrt_ops.h b/src/runtime/contrib/tensorrt/tensorrt_ops.h index 950d9d183a7b..4918131ba97c 100644 --- a/src/runtime/contrib/tensorrt/tensorrt_ops.h +++ b/src/runtime/contrib/tensorrt/tensorrt_ops.h @@ -18,14 +18,13 @@ /*! * \file runtime/contrib/tensorrt/tensorrt_ops.h - * \brief Converters from Relay ops into TensorRT layers. Converters should + * \brief Converters from ops into TensorRT layers. Converters should * inherit from TensorRTOpConverter and implement the Convert() method. */ #ifndef TVM_RUNTIME_CONTRIB_TENSORRT_TENSORRT_OPS_H_ #define TVM_RUNTIME_CONTRIB_TENSORRT_TENSORRT_OPS_H_ -#include #include #include #include @@ -78,7 +77,7 @@ struct TensorRTOpInput { : tensor(nullptr), weight(weight), type(kWeight), weight_shape(shape) {} }; -/*! \brief Parameters to convert an Op from Relay to TensorRT. */ +/*! \brief Parameters to convert an Op to TensorRT. */ struct TensorRTOpConverterParams { /*! \brief The TRT network that the new layer should be added to. */ nvinfer1::INetworkDefinition* network; @@ -104,7 +103,7 @@ struct TensorRTOpConverterParams { std::string LayerName() const { return op_name + "(" + std::to_string(nid) + ")"; } }; -/*! \brief Base class for an op converter from Relay to TRT. */ +/*! \brief Base class for an op converter from Operator to TRT. */ class TensorRTOpConverter { public: virtual ~TensorRTOpConverter() = default; diff --git a/src/support/scalars.h b/src/support/scalars.h index adc449ffd682..6d2a6e868363 100644 --- a/src/support/scalars.h +++ b/src/support/scalars.h @@ -38,10 +38,10 @@ runtime::NDArray IntImmToNDArray(const IntImm& int_imm); runtime::NDArray FloatImmToNDArray(const FloatImm& float_imm); runtime::NDArray BoolToNDArray(bool value); -/*! \brief Returns Relay literal text for NDArray 'scalar'. */ +/*! \brief Returns literal text for NDArray 'scalar'. */ std::string NDArrayScalarToString(const runtime::NDArray& data); -/*! \brief Returns Relay literal text for given TIR immediate. */ +/*! \brief Returns literal text for given TIR immediate. */ std::string IntImmToString(const IntImm& int_imm); std::string FloatImmToString(const FloatImm& float_imm); diff --git a/src/target/llvm/codegen_hexagon.cc b/src/target/llvm/codegen_hexagon.cc index 7d71c9e119a4..1bfdcb6ac357 100644 --- a/src/target/llvm/codegen_hexagon.cc +++ b/src/target/llvm/codegen_hexagon.cc @@ -575,7 +575,7 @@ runtime::Module BuildHexagon(IRModule mod, Target target) { for (auto kv : mod->functions) { if (!kv.second->IsInstance()) { - // (@jroesch): we relax constraints here, Relay functions will just be ignored. + // (@jroesch): we relax constraints here, relax functions will just be ignored. DLOG(INFO) << "Can only lower IR Module with PrimFuncs, but got " << kv.second->GetTypeKey(); continue; } diff --git a/src/target/llvm/codegen_llvm.cc b/src/target/llvm/codegen_llvm.cc index ead0bdff3c0f..3fb08a17f750 100644 --- a/src/target/llvm/codegen_llvm.cc +++ b/src/target/llvm/codegen_llvm.cc @@ -742,7 +742,7 @@ std::unique_ptr CodeGenLLVM::CreateDebugInfo(llvm::Modul auto debug_info = llvm::make_unique(); debug_info->di_builder_ = llvm::make_unique(*module); #endif - // TODO(tulloch): pass this information through relay::Span classes to the IRModule instance? + // TODO(tulloch): pass this information through Span classes to the IRModule instance? debug_info->file_ = debug_info->di_builder_->createFile("IRModule.CodeGenLLVM", "."); const int runtime_version = 0; const bool is_optimized = false; diff --git a/tests/lint/cpplint.sh b/tests/lint/cpplint.sh index 39b86937adc9..84065e17b01d 100755 --- a/tests/lint/cpplint.sh +++ b/tests/lint/cpplint.sh @@ -26,7 +26,6 @@ python3 3rdparty/dmlc-core/scripts/lint.py --quiet tvm cpp \ --exclude_path "src/runtime/hexagon/rpc/hexagon_rpc.h" \ "src/runtime/hexagon/rpc/hexagon_rpc_skel.c" \ "src/runtime/hexagon/rpc/hexagon_rpc_stub.c" \ - "src/relay/backend/contrib/libtorch/libtorch_codegen.cc" if find src -name "*.cc" -exec grep -Hn '^#include $' {} +; then diff --git a/tests/python/contrib/test_hexagon/test_meta_schedule.py b/tests/python/contrib/test_hexagon/test_meta_schedule.py index 9f5ca587f8f1..c2a5109aff3c 100644 --- a/tests/python/contrib/test_hexagon/test_meta_schedule.py +++ b/tests/python/contrib/test_hexagon/test_meta_schedule.py @@ -23,7 +23,7 @@ import tvm.testing import tvm.topi.testing from tvm import meta_schedule as ms -from tvm import relay, te +from tvm import te from tvm.contrib.hexagon.meta_schedule import ( get_hexagon_local_builder, get_hexagon_rpc_runner, @@ -363,141 +363,5 @@ def test_vrmpy_dense_auto_tensorize(hexagon_launcher): verify_dense(sch, get_hexagon_target("v68"), m_size, n_size, k_size, session) -@tvm.testing.requires_hexagon -def test_conv2d_relay_auto_schedule(hexagon_launcher): - """Test conv2d using auto schedule.""" - if hexagon_launcher.is_simulator(): - pytest.skip("Tuning on simulator not supported.") - - i_size, o_size, h_size, w_size = 64, 64, 56, 56 - k_height_size = k_width_size = 3 - - strides = (1, 1) - padding = (1, 1) - - d_shape = (1, h_size, w_size, i_size) - w_shape = (k_height_size, k_width_size, i_size, o_size) - bias_shape = (1, 1, 1, w_shape[3]) - out_channel = w_shape[3] - - data = relay.var("data", shape=d_shape, dtype="float16") - weight = relay.var("weight", shape=w_shape, dtype="float16") - bias = relay.var("bias", shape=bias_shape, dtype="float16") - conv2d = relay.nn.conv2d( - data=data, - weight=weight, - kernel_size=(k_height_size, k_width_size), - channels=out_channel, - padding=padding, - strides=strides, - out_dtype="float16", - data_layout="NHWC", - kernel_layout="HWIO", - ) - mod = tvm.IRModule.from_expr(conv2d + bias) - mod = mod.with_attr("executor", relay.backend.Executor("graph", {"link-params": True})) - - data_np = np.random.randn(*d_shape).astype("float16") - weight_np = np.random.randn(*w_shape).astype("float16") - bias_np = np.random.randn(*bias_shape).astype("float16") - params = {"weight": weight_np, "bias": bias_np} - - ref = ( - relay.create_executor("graph", mod=mod, device=tvm.cpu(0), target="llvm") - .evaluate()(*[data_np, weight_np, bias_np]) - .numpy() - ) - - with tempfile.TemporaryDirectory() as work_dir: - target = get_hexagon_target("v69") - database = ms.relay_integration.tune_relay( - mod=mod, - params=params, - target=target, - max_trials_global=8, - strategy="replay-trace", - work_dir=work_dir, - builder=get_hexagon_local_builder(), - runner=get_hexagon_rpc_runner(hexagon_launcher, number=20), - ) - lib = ms.relay_integration.compile_relay( - database=database, - mod=mod, - params=params, - target=target, - ) - - with hexagon_launcher.create_session() as session: - rt_mod = session.get_executor_from_factory(lib) - - rt_mod.set_input("data", data_np) - - rt_mod.run() - - out = rt_mod.get_output(0).numpy() - # Fairly loose check since fp16 results between x86 and Hexagon have - # non-trivial difference. - assert np.mean(np.abs(ref - out)) < 0.5 - - -@tvm.testing.requires_hexagon -def test_dense_relay_auto_schedule(hexagon_launcher): - """ - This is for testing RewriteLayout postproc. Without this postproc, - dense on Hexagon is extremely slow. - """ - if hexagon_launcher.is_simulator(): - pytest.skip("Tuning on simulator not supported.") - - target_hexagon = tvm.target.hexagon("v69") - target = tvm.target.Target(target_hexagon, host=target_hexagon) - - data_shape = (128, 128) - weight_shape = (128, 128) - - data = relay.var("data", shape=data_shape, dtype="float16") - weight = relay.var("weight", shape=weight_shape, dtype="float16") - dense = relay.nn.dense(data, weight) - mod = tvm.IRModule.from_expr(dense) - mod = mod.with_attr("executor", relay.backend.Executor("graph", {"link-params": True})) - - weight_np = np.random.randn(*weight_shape).astype("float32") - - data_np = np.random.randn(*data_shape).astype("float32") - params = {"weight": weight_np} - ref = np.dot(data_np, weight_np.transpose()) - - with tempfile.TemporaryDirectory() as work_dir: - target = get_hexagon_target("v69") - database = ms.relay_integration.tune_relay( - mod=mod, - params=params, - target=target, - max_trials_global=8, - strategy="replay-trace", - work_dir=work_dir, - builder=get_hexagon_local_builder(), - runner=get_hexagon_rpc_runner(hexagon_launcher, number=20), - ) - lib = ms.relay_integration.compile_relay( - database=database, - mod=mod, - params=params, - target=target, - ) - - with hexagon_launcher.create_session() as session: - rt_mod = session.get_executor_from_factory(lib) - - rt_mod.set_input("data", data_np) - - rt_mod.run() - - out = rt_mod.get_output(0).numpy() - # Fairly loose check since fp16 results between x86 and Hexagon have - # non-trivial difference. - assert np.mean(np.abs(ref - out)) < 0.1 - - if __name__ == "__main__": tvm.testing.main() diff --git a/tests/python/contrib/test_hexagon/test_relax_integration.py b/tests/python/contrib/test_hexagon/test_relax_integration.py index 8b2960ab9e2a..5e1bfac3625e 100644 --- a/tests/python/contrib/test_hexagon/test_relax_integration.py +++ b/tests/python/contrib/test_hexagon/test_relax_integration.py @@ -20,6 +20,7 @@ import pytest import tvm.testing from tvm import relax, runtime +from tvm.relax.frontend import onnx from tvm.relax.testing import relay_translator from tvm.contrib.hexagon.session import Session @@ -47,6 +48,7 @@ def test_mobilenet_onnx(hexagon_session: Session): target_hexagon = tvm.target.hexagon("v68") target = tvm.target.Target(target_hexagon, host=target_hexagon) + relax_mod = onnx.from_onnx(onnx_model, shape_dict, freeze_params=True) relax_mod = relay_translator.from_relay(relay_mod["main"], target_hexagon) # Compile and run on Hexagon. diff --git a/tests/python/relax/test_transform_merge_composite_functions.py b/tests/python/relax/test_transform_merge_composite_functions.py index fccf5a2f5e8e..efa71648d486 100644 --- a/tests/python/relax/test_transform_merge_composite_functions.py +++ b/tests/python/relax/test_transform_merge_composite_functions.py @@ -993,9 +993,6 @@ def test_merge_producers_cyclic_dep(): def test_merge_compiler_regions_example(): - """ - A tricky example from https://discuss.tvm.apache.org/t/relay-improved-graph-partitioning-algorithm/5830 - """ check( MergeCompilerRegionsExample, MergeCompilerRegionsExampleRef, diff --git a/tests/python/tvmscript/test_tvmscript_roundtrip.py b/tests/python/tvmscript/test_tvmscript_roundtrip.py index 140136f74198..f73fe3bec657 100644 --- a/tests/python/tvmscript/test_tvmscript_roundtrip.py +++ b/tests/python/tvmscript/test_tvmscript_roundtrip.py @@ -3946,8 +3946,7 @@ class mod: def main(): # Should be equivalent to the bare "mod.subroutine()", but # that relies on `GlobalVar.__call__` returning the - # correct IR type. Previously, this instead returned a - # `relay.Call` object. + # correct IR type. tir.call_tir(mod.subroutine) @T.prim_func