diff --git a/CMakeLists.txt b/CMakeLists.txt index c52f3b363a8a..4eb2468e4e2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,7 +334,7 @@ tvm_file_glob(GLOB RUNTIME_SRCS src/runtime/memory/*.cc src/runtime/disco/*.cc src/runtime/minrpc/*.cc - src/runtime/relax_vm/*.cc + src/runtime/vm/*.cc ) set(TVM_RUNTIME_EXT_OBJS "") diff --git a/cmake/modules/CUDA.cmake b/cmake/modules/CUDA.cmake index 84261c6ea0ae..64f41d65fae4 100644 --- a/cmake/modules/CUDA.cmake +++ b/cmake/modules/CUDA.cmake @@ -138,8 +138,8 @@ if(USE_CUDA) endif(USE_NVTX) # Add CUDA builtins to RelaxVM - tvm_file_glob(GLOB RELAX_VM_CUDA_BUILTIN_SRC_CC src/runtime/relax_vm/cuda/*.cc) - list(APPEND RUNTIME_SRCS ${RELAX_VM_CUDA_BUILTIN_SRC_CC}) + tvm_file_glob(GLOB VM_CUDA_BUILTIN_SRC_CC src/runtime/vm/cuda/*.cc) + list(APPEND RUNTIME_SRCS ${VM_CUDA_BUILTIN_SRC_CC}) else(USE_CUDA) list(APPEND COMPILER_SRCS src/target/opt/build_cuda_off.cc) endif(USE_CUDA) diff --git a/cmake/modules/Hexagon.cmake b/cmake/modules/Hexagon.cmake index 75b0094ed611..2c153bbac96c 100644 --- a/cmake/modules/Hexagon.cmake +++ b/cmake/modules/Hexagon.cmake @@ -126,8 +126,8 @@ if(BUILD_FOR_HEXAGON) "${TVMRT_SOURCE_DIR}/hexagon/*.cc" ) # Add builtins to RelaxVM - tvm_file_glob(GLOB RELAX_VM_BUILTIN_SRC_CC src/runtime/relax_vm/hexagon/*.cc) - list(APPEND RUNTIME_SRCS ${RELAX_VM_BUILTIN_SRC_CC}) + tvm_file_glob(GLOB VM_BUILTIN_SRC_CC src/runtime/vm/hexagon/*.cc) + list(APPEND RUNTIME_SRCS ${VM_BUILTIN_SRC_CC}) else() file_glob_append(RUNTIME_HEXAGON_SRCS "${TVMRT_SOURCE_DIR}/hexagon/hexagon_module.cc" diff --git a/docs/reference/api/python/index.rst b/docs/reference/api/python/index.rst index 2e0a9c7f2fb9..a233c69a0173 100644 --- a/docs/reference/api/python/index.rst +++ b/docs/reference/api/python/index.rst @@ -35,7 +35,7 @@ Python API runtime/runtime runtime/ndarray - runtime/relax_vm + runtime/vm runtime/disco runtime/profiling diff --git a/docs/reference/api/python/runtime/relax_vm.rst b/docs/reference/api/python/runtime/vm.rst similarity index 93% rename from docs/reference/api/python/runtime/relax_vm.rst rename to docs/reference/api/python/runtime/vm.rst index 75afcb7939ab..2d7b980f864f 100644 --- a/docs/reference/api/python/runtime/relax_vm.rst +++ b/docs/reference/api/python/runtime/vm.rst @@ -15,7 +15,7 @@ specific language governing permissions and limitations under the License. -tvm.runtime.relax_vm +tvm.runtime.vm -------------------- -.. automodule:: tvm.runtime.relax_vm +.. automodule:: tvm.runtime.vm :members: diff --git a/include/tvm/relax/exec_builder.h b/include/tvm/relax/exec_builder.h index 81d6d4eb379e..16223d6bfb80 100644 --- a/include/tvm/relax/exec_builder.h +++ b/include/tvm/relax/exec_builder.h @@ -28,8 +28,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -38,7 +38,7 @@ namespace tvm { namespace relax { -namespace vm = tvm::runtime::relax_vm; +namespace vm = tvm::runtime::vm; class ExecBuilder; diff --git a/include/tvm/runtime/relax_vm/builtin.h b/include/tvm/runtime/vm/builtin.h similarity index 92% rename from include/tvm/runtime/relax_vm/builtin.h rename to include/tvm/runtime/vm/builtin.h index b994e44ae88d..3c4429b12250 100644 --- a/include/tvm/runtime/relax_vm/builtin.h +++ b/include/tvm/runtime/vm/builtin.h @@ -18,15 +18,15 @@ */ /*! - * \file tvm/runtime/relax_vm/builtin.h + * \file tvm/runtime/vm/builtin.h * \brief Builtin runtime APIs. */ -#ifndef TVM_RUNTIME_RELAX_VM_BUILTIN_H_ -#define TVM_RUNTIME_RELAX_VM_BUILTIN_H_ +#ifndef TVM_RUNTIME_VM_BUILTIN_H_ +#define TVM_RUNTIME_VM_BUILTIN_H_ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! * \brief Op code used in built-in match-shape function. @@ -83,7 +83,7 @@ enum class MakeShapeCode : int { kLoadShape = 1, }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_BUILTIN_H_ +#endif // TVM_RUNTIME_VM_BUILTIN_H_ diff --git a/include/tvm/runtime/relax_vm/bytecode.h b/include/tvm/runtime/vm/bytecode.h similarity index 97% rename from include/tvm/runtime/relax_vm/bytecode.h rename to include/tvm/runtime/vm/bytecode.h index 4526c6fffa1d..bc84578fd5d5 100644 --- a/include/tvm/runtime/relax_vm/bytecode.h +++ b/include/tvm/runtime/vm/bytecode.h @@ -18,11 +18,11 @@ */ /*! - * \file tvm/runtime/relax_vm/bytecode.h + * \file tvm/runtime/vm/bytecode.h * \brief The bytecode for the virtual machine. */ -#ifndef TVM_RUNTIME_RELAX_VM_BYTECODE_H_ -#define TVM_RUNTIME_RELAX_VM_BYTECODE_H_ +#ifndef TVM_RUNTIME_VM_BYTECODE_H_ +#define TVM_RUNTIME_VM_BYTECODE_H_ #include #include @@ -32,7 +32,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! * \brief The storage type for the bytecode in the VM. @@ -238,8 +238,8 @@ struct Instruction { static Instruction If(RegName cond, Index false_offset); }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_BYTECODE_H_ +#endif // TVM_RUNTIME_VM_BYTECODE_H_ diff --git a/include/tvm/runtime/relax_vm/executable.h b/include/tvm/runtime/vm/executable.h similarity index 95% rename from include/tvm/runtime/relax_vm/executable.h rename to include/tvm/runtime/vm/executable.h index 8a9fa024cab2..a84c902b6711 100644 --- a/include/tvm/runtime/relax_vm/executable.h +++ b/include/tvm/runtime/vm/executable.h @@ -18,10 +18,10 @@ */ /*! - * \file tvm/runtime/relax_vm/executable.h + * \file tvm/runtime/vm/executable.h */ -#ifndef TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_ -#define TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_ +#ifndef TVM_RUNTIME_VM_EXECUTABLE_H_ +#define TVM_RUNTIME_VM_EXECUTABLE_H_ #include #include @@ -37,11 +37,11 @@ // NOTE: this file only changes if we change relax vm format // for example if relax vm format do not change in 0.15, this should remain as 0.14 // if it changes in 0.16, we will change it to 0.16 -#define RELAX_VM_VERSION "0.14" +#define VM_VERSION "0.14" namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! * \brief Information entry in executable function table. @@ -214,11 +214,11 @@ class VMExecutable : public runtime::ModuleNode { void LoadPackedFuncNames(dmlc::Stream* strm); }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm namespace dmlc { -DMLC_DECLARE_TRAITS(has_saveload, ::tvm::runtime::relax_vm::VMFuncInfo, true); +DMLC_DECLARE_TRAITS(has_saveload, ::tvm::runtime::vm::VMFuncInfo, true); } // namespace dmlc -#endif // TVM_RUNTIME_RELAX_VM_EXECUTABLE_H_ +#endif // TVM_RUNTIME_VM_EXECUTABLE_H_ diff --git a/include/tvm/runtime/relax_vm/ndarray_cache_support.h b/include/tvm/runtime/vm/ndarray_cache_support.h similarity index 93% rename from include/tvm/runtime/relax_vm/ndarray_cache_support.h rename to include/tvm/runtime/vm/ndarray_cache_support.h index 579fbf306f68..3ab08df04389 100644 --- a/include/tvm/runtime/relax_vm/ndarray_cache_support.h +++ b/include/tvm/runtime/vm/ndarray_cache_support.h @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -#ifndef TVM_RUNTIME_RELAX_VM_NDARRAY_CACHE_SUPPORT_H_ -#define TVM_RUNTIME_RELAX_VM_NDARRAY_CACHE_SUPPORT_H_ +#ifndef TVM_RUNTIME_VM_NDARRAY_CACHE_SUPPORT_H_ +#define TVM_RUNTIME_VM_NDARRAY_CACHE_SUPPORT_H_ #include #include @@ -29,7 +29,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! * \brief Metadata for NDArray cache, which by default, is named as "ndarray-cache.json". @@ -89,8 +89,8 @@ struct NDArrayCacheMetadata { static NDArrayCacheMetadata LoadFromStr(const std::string& json_str, const std::string& path); }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_NDARRAY_CACHE_SUPPORT_H_ +#endif // TVM_RUNTIME_VM_NDARRAY_CACHE_SUPPORT_H_ diff --git a/include/tvm/runtime/relax_vm/vm.h b/include/tvm/runtime/vm/vm.h similarity index 96% rename from include/tvm/runtime/relax_vm/vm.h rename to include/tvm/runtime/vm/vm.h index 884a8d0f4375..9aa34c9b4468 100644 --- a/include/tvm/runtime/relax_vm/vm.h +++ b/include/tvm/runtime/vm/vm.h @@ -18,13 +18,13 @@ */ /*! - * \file tvm/runtime/relax_vm/vm.h + * \file tvm/runtime/vm/vm.h */ -#ifndef TVM_RUNTIME_RELAX_VM_VM_H_ -#define TVM_RUNTIME_RELAX_VM_VM_H_ +#ifndef TVM_RUNTIME_VM_VM_H_ +#define TVM_RUNTIME_VM_VM_H_ -#ifndef TVM_RELAX_VM_ENABLE_PROFILER -#define TVM_RELAX_VM_ENABLE_PROFILER 1 +#ifndef TVM_VM_ENABLE_PROFILER +#define TVM_VM_ENABLE_PROFILER 1 #endif #include @@ -45,7 +45,7 @@ using memory::MemoryManager; using memory::Storage; using memory::StorageObj; -namespace relax_vm { +namespace vm { /*! * \brief Possible instrument actions. @@ -227,8 +227,8 @@ class VirtualMachine : public runtime::ModuleNode { std::unordered_map extensions; }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_VM_H_ +#endif // TVM_RUNTIME_VM_VM_H_ diff --git a/python/tvm/contrib/hexagon/session.py b/python/tvm/contrib/hexagon/session.py index 4f017abcf6ba..b92c78309482 100644 --- a/python/tvm/contrib/hexagon/session.py +++ b/python/tvm/contrib/hexagon/session.py @@ -218,7 +218,7 @@ def get_executor_from_factory( The hexagon arch to be used """ if isinstance(module, (runtime.Executable, str)): - return self._relax_vm_executable_executor(module, hexagon_arch=hexagon_arch) + return self._vm_executable_executor(module, hexagon_arch=hexagon_arch) raise TypeError(f"Unsupported executor type: {type(module)}") @@ -244,7 +244,7 @@ def _set_device_type(self, module: Union[str, pathlib.Path]): else: self._requires_cpu_device = False - def _relax_vm_executable_executor( + def _vm_executable_executor( self, executable: Union[runtime.Executable, str], hexagon_arch: str ): """Create a local TVM module which consumes a remote vm executable. diff --git a/python/tvm/relax/__init__.py b/python/tvm/relax/__init__.py index da288942edf0..b88000119897 100644 --- a/python/tvm/relax/__init__.py +++ b/python/tvm/relax/__init__.py @@ -16,8 +16,8 @@ # under the License. # pylint: disable=invalid-name, wrong-import-position """The Relax IR namespace containing the IR, type, operator, builder, vm, etc.""" -from tvm.runtime import relax_vm as vm -from tvm.runtime.relax_vm import VirtualMachine, VMInstrumentReturnKind +from tvm.runtime import vm +from tvm.runtime.vm import VirtualMachine, VMInstrumentReturnKind from .type_converter import args_converter diff --git a/python/tvm/relax/frontend/nn/core.py b/python/tvm/relax/frontend/nn/core.py index 5b0eae4acc0e..068b2090db5b 100644 --- a/python/tvm/relax/frontend/nn/core.py +++ b/python/tvm/relax/frontend/nn/core.py @@ -45,7 +45,7 @@ from tvm.runtime import Device, NDArray from tvm.runtime import device as as_device from tvm.runtime import ndarray -from tvm.runtime.relax_vm import VirtualMachine +from tvm.runtime.vm import VirtualMachine from tvm.target import Target from .... import relax as rx diff --git a/python/tvm/relax/frontend/nn/torch.py b/python/tvm/relax/frontend/nn/torch.py index 28ccf3b8ea2f..ae98868dae09 100644 --- a/python/tvm/relax/frontend/nn/torch.py +++ b/python/tvm/relax/frontend/nn/torch.py @@ -22,7 +22,7 @@ from tvm.ir import Array from tvm.runtime import NDArray, ShapeTuple, ndarray -from tvm.runtime.relax_vm import VirtualMachine +from tvm.runtime.vm import VirtualMachine from . import core from . import spec as _spec diff --git a/python/tvm/runtime/relax_vm.py b/python/tvm/runtime/vm.py similarity index 100% rename from python/tvm/runtime/relax_vm.py rename to python/tvm/runtime/vm.py diff --git a/src/relax/backend/vm/codegen_vm.cc b/src/relax/backend/vm/codegen_vm.cc index f61579e25e96..4cf2811922c8 100644 --- a/src/relax/backend/vm/codegen_vm.cc +++ b/src/relax/backend/vm/codegen_vm.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -37,12 +37,12 @@ namespace tvm { namespace relax { -namespace relax_vm { +namespace codegen_vm { using tvm::Target; using namespace relax; using namespace tvm::runtime; -using namespace tvm::runtime::relax_vm; +using namespace tvm::runtime::vm; /*! * \brief A class to generate VM executable for Relax functions. @@ -492,6 +492,6 @@ Module VMLink(ExecBuilder builder, Target target, Optional lib, Array #include #include -#include +#include #include #include #include @@ -39,7 +39,7 @@ namespace tvm { namespace relax { -namespace relax_vm { +namespace codegen_vm { using vm::VMFuncInfo; @@ -532,6 +532,6 @@ IRModule VMTIRCodeGen(ExecBuilder exec_builder, IRModule mod) { TVM_FFI_REGISTER_GLOBAL("relax.VMTIRCodeGen").set_body_typed(VMTIRCodeGen); -} // namespace relax_vm +} // namespace codegen_vm } // namespace relax } // namespace tvm diff --git a/src/relax/backend/vm/vm_shape_lower.cc b/src/relax/backend/vm/vm_shape_lower.cc index 0b60553034fe..50e71ccc14ed 100644 --- a/src/relax/backend/vm/vm_shape_lower.cc +++ b/src/relax/backend/vm/vm_shape_lower.cc @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -176,7 +176,7 @@ class PrimExprSlotCollector : public ExprVisitor, public StructInfoVisitor { * - VisitExpr_(ShapeExprNode*): makes symbolic shape tuple. * * The checks and symbolic shape all maps to runtime builtin functions. Please checkout - * runtime/relax_vm/builtin.cc for their definitions. + * runtime/vm/builtin.cc for their definitions. * * Shape computation are lowered to host-side TIR functions that load var from slot * and store computed results into the slot. For a given slot map: {0:m, 1: n+1: 2: n} @@ -353,7 +353,7 @@ class VMShapeLowerMutator } std::pair MakeSymbolicShapeArg(const PrimExpr& expr) { - using runtime::relax_vm::MakeShapeCode; + using runtime::vm::MakeShapeCode; if (auto* int_expr = expr.as()) { return {PrimValue::Int64(static_cast(MakeShapeCode::kUseImm)), @@ -370,7 +370,7 @@ class VMShapeLowerMutator } Expr VisitExpr_(const PrimValueNode* op) final { - using runtime::relax_vm::MakeShapeCode; + using runtime::vm::MakeShapeCode; // Constant shape can be preserved. bool is_const_value = op->value->IsInstance() || op->value->IsInstance(); @@ -389,7 +389,7 @@ class VMShapeLowerMutator } Expr VisitExpr_(const ShapeExprNode* op) final { - using runtime::relax_vm::MakeShapeCode; + using runtime::vm::MakeShapeCode; // Constant shape can be preserved. bool is_const_shape = std::all_of(op->values.begin(), op->values.end(), [](const PrimExpr& e) { return e->IsInstance(); @@ -444,9 +444,9 @@ class VMShapeLowerMutator * \return The MatchShapeCode, and a relax expression specifying the * argument used by that MatchShapeCode. */ - std::pair MakeMatchArgs(const PrimExpr& expr, - bool require_value_computed) { - using runtime::relax_vm::MatchShapeCode; + std::pair MakeMatchArgs(const PrimExpr& expr, + bool require_value_computed) { + using runtime::vm::MatchShapeCode; if (auto* int_expr = expr.as()) { return {MatchShapeCode::kAssertEqualToImm, PrimValue::Int64(int_expr->value)}; @@ -496,7 +496,7 @@ class VMShapeLowerMutator bool require_value_computed) { std::vector outstanding_todos; - using runtime::relax_vm::MatchShapeCode; + using runtime::vm::MatchShapeCode; for (const MatchShapeTodoItem& item : match_todos) { bool all_nop = true; bool any_nop = false; diff --git a/src/runtime/disco/builtin.cc b/src/runtime/disco/builtin.cc index 7c769b7dd081..9cd76e673a45 100644 --- a/src/runtime/disco/builtin.cc +++ b/src/runtime/disco/builtin.cc @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include diff --git a/src/runtime/disco/loader.cc b/src/runtime/disco/loader.cc index f93170d02f07..52e7833601f3 100644 --- a/src/runtime/disco/loader.cc +++ b/src/runtime/disco/loader.cc @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include @@ -38,7 +38,7 @@ namespace tvm { namespace runtime { -using relax_vm::NDArrayCacheMetadata; +using vm::NDArrayCacheMetadata; using FileRecord = NDArrayCacheMetadata::FileRecord; using ParamRecord = NDArrayCacheMetadata::FileRecord::ParamRecord; diff --git a/src/runtime/relax_vm/attn_backend.cc b/src/runtime/vm/attn_backend.cc similarity index 97% rename from src/runtime/relax_vm/attn_backend.cc rename to src/runtime/vm/attn_backend.cc index 09f2d2c736fc..f3aaf3f68835 100644 --- a/src/runtime/relax_vm/attn_backend.cc +++ b/src/runtime/vm/attn_backend.cc @@ -17,13 +17,13 @@ * under the License. */ -/*! \file src/runtime/relax_vm/attn_backend.cc */ +/*! \file src/runtime/vm/attn_backend.cc */ #include "attn_backend.h" namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { std::unique_ptr ConvertPagedPrefillFunc(Array args, AttnKind attn_kind) { @@ -120,6 +120,6 @@ std::unique_ptr ConvertRaggedPrefillTreeMaskFunc(Arra throw; } -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/attn_backend.h b/src/runtime/vm/attn_backend.h similarity index 99% rename from src/runtime/relax_vm/attn_backend.h rename to src/runtime/vm/attn_backend.h index 2eb9cf3d6677..21d8d81a8be8 100644 --- a/src/runtime/relax_vm/attn_backend.h +++ b/src/runtime/vm/attn_backend.h @@ -18,12 +18,12 @@ */ /*! - * \file src/runtime/relax_vm/attn_backend.h + * \file src/runtime/vm/attn_backend.h * \brief The attention backend classes used by KV cache. */ -#ifndef TVM_RUNTIME_RELAX_VM_ATTN_BACKEND_H_ -#define TVM_RUNTIME_RELAX_VM_ATTN_BACKEND_H_ +#ifndef TVM_RUNTIME_VM_ATTN_BACKEND_H_ +#define TVM_RUNTIME_VM_ATTN_BACKEND_H_ #include #include @@ -39,7 +39,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! \brief The attention backend kinds. */ enum class AttnBackendKind : int { @@ -537,8 +537,8 @@ std::unique_ptr ConvertPagedPrefillTreeMaskFunc(Array< std::unique_ptr ConvertRaggedPrefillTreeMaskFunc(Array args, AttnKind attn_kind); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_ATTN_BACKEND_H_ +#endif // TVM_RUNTIME_VM_ATTN_BACKEND_H_ diff --git a/src/runtime/relax_vm/attn_utils.h b/src/runtime/vm/attn_utils.h similarity index 99% rename from src/runtime/relax_vm/attn_utils.h rename to src/runtime/vm/attn_utils.h index 547d32c1208e..dce577da0889 100644 --- a/src/runtime/relax_vm/attn_utils.h +++ b/src/runtime/vm/attn_utils.h @@ -17,12 +17,12 @@ * under the License. */ /*! - * \file src/runtime/relax_vm/attn_utils.h + * \file src/runtime/vm/attn_utils.h * \brief Data structure and utilities for KV cache. */ -#ifndef TVM_RUNTIME_RELAX_VM_ATTN_UTILS_H_ -#define TVM_RUNTIME_RELAX_VM_ATTN_UTILS_H_ +#ifndef TVM_RUNTIME_VM_ATTN_UTILS_H_ +#define TVM_RUNTIME_VM_ATTN_UTILS_H_ #include @@ -36,7 +36,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! * \brief The maximum allowed block depth (a.k.a. number of common @@ -1023,8 +1023,8 @@ class CachedPagedKVCacheAuxDataManager : public PagedKVCacheAuxDataManager { NDArray merged_compact_kv_aux_data_device_; }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_ATTN_UTILS_H_ +#endif // TVM_RUNTIME_VM_ATTN_UTILS_H_ diff --git a/src/runtime/relax_vm/builtin.cc b/src/runtime/vm/builtin.cc similarity index 99% rename from src/runtime/relax_vm/builtin.cc rename to src/runtime/vm/builtin.cc index 3d7904bd8f48..a23e196e5c15 100644 --- a/src/runtime/relax_vm/builtin.cc +++ b/src/runtime/vm/builtin.cc @@ -17,7 +17,7 @@ * under the License. */ /*! - * \file src/runtime/relax_vm/builtin.cc + * \file src/runtime/vm/builtin.cc */ #include #include @@ -29,13 +29,13 @@ #include #include #include -#include -#include -#include +#include +#include +#include namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { using tvm::runtime::NDArray; @@ -562,7 +562,7 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.ensure_zero_offset").set_body_typed([](NDArr } }); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/bytecode.cc b/src/runtime/vm/bytecode.cc similarity index 93% rename from src/runtime/relax_vm/bytecode.cc rename to src/runtime/vm/bytecode.cc index 9084207848b5..4356305521a3 100644 --- a/src/runtime/relax_vm/bytecode.cc +++ b/src/runtime/vm/bytecode.cc @@ -18,19 +18,19 @@ */ /*! - * \file src/runtime/relax_vm/bytecode.cc + * \file src/runtime/vm/bytecode.cc * \brief The bytecode for Relax virtual machine. */ #include -#include +#include #include #include namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { Instruction Instruction::Call(Index func_idx, Index num_args, Instruction::Arg* args, RegName dst) { Instruction instr; @@ -63,6 +63,6 @@ Instruction Instruction::If(RegName cond, Index false_offset) { instr.false_offset = false_offset; return instr; } -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/cuda/cuda_graph_builtin.cc b/src/runtime/vm/cuda/cuda_graph_builtin.cc similarity index 97% rename from src/runtime/relax_vm/cuda/cuda_graph_builtin.cc rename to src/runtime/vm/cuda/cuda_graph_builtin.cc index d3484cbc7b3e..fb0534eec5af 100644 --- a/src/runtime/relax_vm/cuda/cuda_graph_builtin.cc +++ b/src/runtime/vm/cuda/cuda_graph_builtin.cc @@ -18,19 +18,19 @@ */ /*! - * \file src/runtime/relax_vm/cuda_graph_builtin.cc + * \file src/runtime/vm/cuda_graph_builtin.cc * \brief The CUDA graph related builtin functions for Relax virtual machine. */ #include #include -#include +#include #include "../../../support/utils.h" #include "../../cuda/cuda_common.h" namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { namespace { @@ -213,7 +213,7 @@ class CUDAGraphExtensionNode : public VMExtensionNode { return alloc_result; } - static constexpr const char* _type_key = "relax_vm.CUDAGraphExtension"; + static constexpr const char* _type_key = "vm.CUDAGraphExtension"; private: /*! @@ -265,6 +265,6 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.cuda_graph.get_cached_alloc") *rv = extension->GetCachedAllocation(vm, alloc_func, entry_index); }); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/executable.cc b/src/runtime/vm/executable.cc similarity index 98% rename from src/runtime/relax_vm/executable.cc rename to src/runtime/vm/executable.cc index 52a0588be35c..f33ce6bc0edb 100644 --- a/src/runtime/relax_vm/executable.cc +++ b/src/runtime/vm/executable.cc @@ -18,13 +18,13 @@ */ /*! - * \file src/runtime/relax_vm/executable.cc + * \file src/runtime/vm/executable.cc */ #include #include -#include -#include +#include +#include #include #include @@ -33,7 +33,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! \brief The magic number for the serialized VM bytecode file */ constexpr uint64_t kTVMVMBytecodeMagic = 0xD225DE2F4214151D; @@ -144,7 +144,7 @@ Instruction VMExecutable::GetInstruction(Index i) const { void SaveHeader(dmlc::Stream* strm) { uint64_t header = kTVMVMBytecodeMagic; strm->Write(header); - std::string version = RELAX_VM_VERSION; + std::string version = VM_VERSION; strm->Write(version); } @@ -157,7 +157,7 @@ void LoadHeader(dmlc::Stream* strm) { // Check version. std::string version; STREAM_CHECK(strm->Read(&version), "version"); - STREAM_CHECK(version == RELAX_VM_VERSION, "version"); + STREAM_CHECK(version == VM_VERSION, "version"); } void VMExecutable::SaveToBinary(dmlc::Stream* stream) { @@ -559,6 +559,6 @@ String VMExecutable::AsPython() const { TVM_FFI_REGISTER_GLOBAL("relax.ExecutableLoadFromFile").set_body_typed(VMExecutable::LoadFromFile); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/hexagon/builtin.cc b/src/runtime/vm/hexagon/builtin.cc similarity index 95% rename from src/runtime/relax_vm/hexagon/builtin.cc rename to src/runtime/vm/hexagon/builtin.cc index 89f1708b28ed..c48445130cf0 100644 --- a/src/runtime/relax_vm/hexagon/builtin.cc +++ b/src/runtime/vm/hexagon/builtin.cc @@ -18,18 +18,18 @@ */ /*! - * \file src/runtime/relax_vm/hexagon/builtin.cc + * \file src/runtime/vm/hexagon/builtin.cc * \brief The hexagon graph related builtin functions for Relax virtual machine. */ #include #include -#include +#include #include "../../hexagon/hexagon_device_api.h" namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { TVM_FFI_REGISTER_GLOBAL("vm.builtin.hexagon.dma_copy") .set_body_typed([](ffi::AnyView vm_ptr, NDArray src_arr, NDArray dst_arr, int queue_id, @@ -66,6 +66,6 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.hexagon.dma_wait") QURT_MEM_DCACHE); } }); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/kv_state.cc b/src/runtime/vm/kv_state.cc similarity index 99% rename from src/runtime/relax_vm/kv_state.cc rename to src/runtime/vm/kv_state.cc index 12f52c0794e9..466d41e3d31e 100644 --- a/src/runtime/relax_vm/kv_state.cc +++ b/src/runtime/vm/kv_state.cc @@ -23,7 +23,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { // Register Object Type TVM_REGISTER_OBJECT_TYPE(KVStateObj); @@ -114,6 +114,6 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.rnn_state_set") }); TVM_FFI_REGISTER_GLOBAL("vm.builtin.rnn_state_debug_get").set_body_method(&RNNStateObj::DebugGet); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/kv_state.h b/src/runtime/vm/kv_state.h similarity index 98% rename from src/runtime/relax_vm/kv_state.h rename to src/runtime/vm/kv_state.h index 5800c4e2db93..46d8f4f59603 100644 --- a/src/runtime/relax_vm/kv_state.h +++ b/src/runtime/vm/kv_state.h @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -#ifndef TVM_RUNTIME_RELAX_VM_KV_STATE_H_ -#define TVM_RUNTIME_RELAX_VM_KV_STATE_H_ +#ifndef TVM_RUNTIME_VM_KV_STATE_H_ +#define TVM_RUNTIME_VM_KV_STATE_H_ #include #include #include @@ -28,7 +28,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { /*! \brief The base class of attention KV cache and rnn state. */ class KVStateObj : public Object { @@ -345,8 +345,8 @@ class RNNState : public KVState { TVM_DEFINE_MUTABLE_OBJECT_REF_METHODS(RNNState, KVState, RNNStateObj); }; -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm -#endif // TVM_RUNTIME_RELAX_VM_KV_STATE_H_ +#endif // TVM_RUNTIME_VM_KV_STATE_H_ diff --git a/src/runtime/relax_vm/lm_support.cc b/src/runtime/vm/lm_support.cc similarity index 99% rename from src/runtime/relax_vm/lm_support.cc rename to src/runtime/vm/lm_support.cc index 8abeddcf18dc..baf5bf480e37 100644 --- a/src/runtime/relax_vm/lm_support.cc +++ b/src/runtime/vm/lm_support.cc @@ -17,7 +17,7 @@ * under the License. */ /*! - * \file src/runtime/relax_vm/lm_support.cc + * \file src/runtime/vm/lm_support.cc * \brief Runtime to support language model related task * * Including inplace attention kv cache for runtime and simple sampler. @@ -42,13 +42,13 @@ #include #include #include -#include +#include #include namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { //------------------------------------------- // We keep the implementation private as @@ -621,6 +621,6 @@ void ApplySoftmaxWithTemperature(NDArray logits, double temperature) { TVM_FFI_REGISTER_GLOBAL("vm.builtin.apply_softmax_with_temperature") .set_body_typed(ApplySoftmaxWithTemperature); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/ndarray_cache_support.cc b/src/runtime/vm/ndarray_cache_support.cc similarity index 98% rename from src/runtime/relax_vm/ndarray_cache_support.cc rename to src/runtime/vm/ndarray_cache_support.cc index 7341507e9a98..17f07df70c01 100644 --- a/src/runtime/relax_vm/ndarray_cache_support.cc +++ b/src/runtime/vm/ndarray_cache_support.cc @@ -17,7 +17,7 @@ * under the License. */ /*! - * \file src/runtime/relax_vm/ndarray_cache_support.cc + * \file src/runtime/vm/ndarray_cache_support.cc * \brief Runtime to support ndarray cache file loading. * * This file provides a minimum support for ndarray cache file loading. @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include @@ -51,7 +51,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { template inline ExpectedType AsType(const picojson::value& json) { @@ -375,6 +375,6 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.param_array_from_cache_by_name_unpacked") *rv = ParamModuleNode::GetParamByName(names); }); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/paged_kv_cache.cc b/src/runtime/vm/paged_kv_cache.cc similarity index 99% rename from src/runtime/relax_vm/paged_kv_cache.cc rename to src/runtime/vm/paged_kv_cache.cc index 2f21e6978a68..5b70c0317719 100644 --- a/src/runtime/relax_vm/paged_kv_cache.cc +++ b/src/runtime/vm/paged_kv_cache.cc @@ -17,7 +17,7 @@ * under the License. */ /*! - * \file src/runtime/relax_vm/paged_kv_cache.cc + * \file src/runtime/vm/paged_kv_cache.cc * \brief Runtime paged KV cache object for language models. */ #include @@ -39,7 +39,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { //------------------------------------------- // We keep the implementation private as @@ -2276,7 +2276,7 @@ class PagedAttentionKVCacheObj : public AttentionKVCacheObj { // - Reset the dirty flag to false. dirty_aux_data_device_ = false; } -}; // namespace relax_vm +}; // namespace vm TVM_REGISTER_OBJECT_TYPE(PagedAttentionKVCacheObj); @@ -2387,6 +2387,6 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.paged_attention_kv_cache_create") *rv = AttentionKVCache(std::move(n)); }); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/rnn_state.cc b/src/runtime/vm/rnn_state.cc similarity index 99% rename from src/runtime/relax_vm/rnn_state.cc rename to src/runtime/vm/rnn_state.cc index d431fdb2ae2f..e7a655d392f8 100644 --- a/src/runtime/relax_vm/rnn_state.cc +++ b/src/runtime/vm/rnn_state.cc @@ -17,7 +17,7 @@ * under the License. */ /*! - * \file src/runtime/relax_vm/rnn_state.cc + * \file src/runtime/vm/rnn_state.cc * \brief Runtime RNN state object for space state models. */ @@ -28,7 +28,7 @@ namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { //----------------------------------------------------------------------------- // We keep the implementation private as they may subject to future changes. @@ -495,6 +495,6 @@ TVM_FFI_REGISTER_GLOBAL("vm.builtin.rnn_state_create") return RNNState(std::move(n)); }); -} // namespace relax_vm +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/src/runtime/relax_vm/vm.cc b/src/runtime/vm/vm.cc similarity index 99% rename from src/runtime/relax_vm/vm.cc rename to src/runtime/vm/vm.cc index 8d0b928f8592..55a5a87d279a 100644 --- a/src/runtime/relax_vm/vm.cc +++ b/src/runtime/vm/vm.cc @@ -18,21 +18,21 @@ */ /*! - * \file src/runtime/relax_vm/vm.cc + * \file src/runtime/vm/vm.cc */ #include #include #include #include #include -#include +#include #include #include namespace tvm { namespace runtime { -namespace relax_vm { +namespace vm { //--------------------------------------------- // VM Closure object @@ -965,7 +965,7 @@ ffi::Function VirtualMachineImpl::_LookupFunction(const String& name) { //---------------------------------------------------------------- // Profiler can be optionally disabled via a macro to reduce dep. //---------------------------------------------------------------- -#if TVM_RELAX_VM_ENABLE_PROFILER +#if TVM_VM_ENABLE_PROFILER /*! * \brief An extension of VirtualMachineImpl to support per-op profiling @@ -1081,7 +1081,7 @@ ObjectPtr VirtualMachine::CreateProfiler() { LOG(FATAL) << "Profiler support is disabled"; return nullptr; } -#endif // TVM_RELAX_VM_ENABLE_PROFILER -} // namespace relax_vm +#endif // TVM_VM_ENABLE_PROFILER +} // namespace vm } // namespace runtime } // namespace tvm diff --git a/tests/python/contrib/test_tir_triton_integration.py b/tests/python/contrib/test_tir_triton_integration.py index 69f727150544..b349d2fabce5 100644 --- a/tests/python/contrib/test_tir_triton_integration.py +++ b/tests/python/contrib/test_tir_triton_integration.py @@ -14,17 +14,18 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -import numpy as np import sys +import numpy as np +import pytest + import tvm -from tvm.script import tir as T -from tvm.script import relax as R -from tvm.script import ir as I +import tvm.testing from tvm import relax from tvm.relax.frontend import nn -import tvm.testing -import pytest +from tvm.script import ir as I +from tvm.script import relax as R +from tvm.script import tir as T try: import triton @@ -115,5 +116,5 @@ def add(x_handle: T.handle, y_handle: T.handle, output_handle: T.handle): with tvm.target.Target("cuda"): lib = tvm.compile(Module) - output_nd = tvm.runtime.relax_vm.VirtualMachine(lib, device)["main"](x_nd, y_nd) + output_nd = tvm.runtime.vm.VirtualMachine(lib, device)["main"](x_nd, y_nd) tvm.testing.assert_allclose(output_nd.numpy(), output_np, rtol=1e-5) diff --git a/tests/python/disco/test_ccl.py b/tests/python/disco/test_ccl.py index f93030f63923..649b865b6c3b 100644 --- a/tests/python/disco/test_ccl.py +++ b/tests/python/disco/test_ccl.py @@ -28,7 +28,7 @@ from tvm import get_global_func from tvm import relax as rx from tvm.runtime import disco as di -from tvm.runtime.relax_vm import VirtualMachine +from tvm.runtime.vm import VirtualMachine from tvm.script import relax as R _all_session_kinds = [di.ThreadedSession, di.ProcessSession] diff --git a/tests/python/relax/test_frontend_nn_extern_module.py b/tests/python/relax/test_frontend_nn_extern_module.py index 5aa48dd18aba..cbc2e7f42922 100644 --- a/tests/python/relax/test_frontend_nn_extern_module.py +++ b/tests/python/relax/test_frontend_nn_extern_module.py @@ -189,7 +189,7 @@ def test_sym(self, a: nn.Tensor, b: nn.Tensor): # pylint: disable=invalid-name ) _check_ir_equality(mod) mod = AttachExternModules(ext_mods)(mod) # pylint: disable=not-callable - compiled = tvm.runtime.relax_vm.VirtualMachine( + compiled = tvm.runtime.vm.VirtualMachine( tvm.compile(mod, target="llvm"), device=tvm.cpu(), ) @@ -238,7 +238,7 @@ def test_sym(self, a: nn.Tensor, b: nn.Tensor): # pylint: disable=invalid-name ) _check_ir_equality(mod) mod = AttachExternModules(ext_mods)(mod) # pylint: disable=not-callable - compiled = tvm.runtime.relax_vm.VirtualMachine( + compiled = tvm.runtime.vm.VirtualMachine( tvm.compile(mod, target="llvm"), device=tvm.cpu(), ) diff --git a/tests/python/relax/test_tir_call_source_kernel.py b/tests/python/relax/test_tir_call_source_kernel.py index 9aba489f480b..d7ca2a672b55 100644 --- a/tests/python/relax/test_tir_call_source_kernel.py +++ b/tests/python/relax/test_tir_call_source_kernel.py @@ -20,7 +20,9 @@ import tvm import tvm.testing from tvm import relax -from tvm.script import tir as T, ir as I, relax as R +from tvm.script import ir as I +from tvm.script import relax as R +from tvm.script import tir as T add_cuda_source = """ extern "C" __global__ void add_kernel(float* x, float* y, float* output, int n_elements) { @@ -96,5 +98,5 @@ def add(x_handle: T.handle, y_handle: T.handle, output_handle: T.handle): with tvm.target.Target("cuda"): lib = tvm.compile(Module) - output_nd = tvm.runtime.relax_vm.VirtualMachine(lib, device)["main"](x_nd, y_nd) + output_nd = tvm.runtime.vm.VirtualMachine(lib, device)["main"](x_nd, y_nd) tvm.testing.assert_allclose(output_nd.numpy(), output_np, rtol=1e-5) diff --git a/tests/python/relax/test_training_optimizer_numeric.py b/tests/python/relax/test_training_optimizer_numeric.py index 937582adf715..6a9c34a5fb94 100644 --- a/tests/python/relax/test_training_optimizer_numeric.py +++ b/tests/python/relax/test_training_optimizer_numeric.py @@ -18,13 +18,13 @@ from typing import Callable, List import numpy as np + import tvm import tvm.testing -from tvm import relax -from tvm import IRModule -from tvm.relax.training.optimizer import Adam, SGD, MomentumSGD +from tvm import IRModule, relax +from tvm.relax.training.optimizer import SGD, Adam, MomentumSGD +from tvm.runtime.vm import VirtualMachine from tvm.script.parser import relax as R -from tvm.runtime.relax_vm import VirtualMachine from tvm.testing import assert_allclose diff --git a/web/emcc/wasm_runtime.cc b/web/emcc/wasm_runtime.cc index 40dfb31ad19f..3c1c15a86123 100644 --- a/web/emcc/wasm_runtime.cc +++ b/web/emcc/wasm_runtime.cc @@ -60,16 +60,16 @@ #include "ffi/src/ffi/traceback.cc" #include "src/runtime/memory/memory_manager.cc" #include "src/runtime/nvtx.cc" -#include "src/runtime/relax_vm/attn_backend.cc" -#include "src/runtime/relax_vm/builtin.cc" -#include "src/runtime/relax_vm/bytecode.cc" -#include "src/runtime/relax_vm/executable.cc" -#include "src/runtime/relax_vm/kv_state.cc" -#include "src/runtime/relax_vm/lm_support.cc" -#include "src/runtime/relax_vm/ndarray_cache_support.cc" -#include "src/runtime/relax_vm/paged_kv_cache.cc" -#include "src/runtime/relax_vm/rnn_state.cc" -#include "src/runtime/relax_vm/vm.cc" +#include "src/runtime/vm/attn_backend.cc" +#include "src/runtime/vm/builtin.cc" +#include "src/runtime/vm/bytecode.cc" +#include "src/runtime/vm/executable.cc" +#include "src/runtime/vm/kv_state.cc" +#include "src/runtime/vm/lm_support.cc" +#include "src/runtime/vm/ndarray_cache_support.cc" +#include "src/runtime/vm/paged_kv_cache.cc" +#include "src/runtime/vm/rnn_state.cc" +#include "src/runtime/vm/vm.cc" // --- Implementations of backend and wasm runtime API. --- diff --git a/web/tests/node/test_relax_vm.js b/web/tests/node/test_vm.js similarity index 100% rename from web/tests/node/test_relax_vm.js rename to web/tests/node/test_vm.js