This is an automated email from the ASF dual-hosted git repository.
junrushao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 443fa20e20 [RUNTIME] Update Module and Registry to use String
Container (#14902)
443fa20e20 is described below
commit 443fa20e20c7bdd76a820742aff5899d5ac72541
Author: Tianqi Chen <[email protected]>
AuthorDate: Wed May 31 16:55:10 2023 -0400
[RUNTIME] Update Module and Registry to use String Container (#14902)
This PR updates the Module and Registry's DLL function
to use String container instead of std::string.
While it is impossible to obtain a stable ABI due to the nature
of c++, and it is important to keep that flexibility,
it is helpful to keep small set of tvm/runtime functions to
work with use a String so it is more stable across compilers.
---
apps/dso_plugin_module/plugin_module.cc | 3 +--
include/tvm/runtime/module.h | 19 +++++++--------
include/tvm/runtime/packed_func.h | 2 +-
include/tvm/runtime/registry.h | 12 +++++-----
include/tvm/runtime/vm/executable.h | 4 ++--
include/tvm/runtime/vm/vm.h | 2 +-
src/relay/backend/aot_executor_codegen.cc | 2 +-
src/relay/backend/build_module.cc | 2 +-
src/relay/backend/contrib/ethosu/source_module.cc | 8 +++----
src/relay/backend/graph_executor_codegen.cc | 2 +-
src/relay/backend/vm/compiler.cc | 2 +-
src/relay/backend/vm/compiler.h | 2 +-
src/relay/printer/model_library_format_printer.cc | 2 +-
src/runtime/aot_executor/aot_executor.cc | 3 +--
src/runtime/aot_executor/aot_executor.h | 2 +-
src/runtime/aot_executor/aot_executor_factory.cc | 2 +-
src/runtime/aot_executor/aot_executor_factory.h | 2 +-
src/runtime/const_loader_module.cc | 2 +-
src/runtime/contrib/coreml/coreml_runtime.h | 2 +-
src/runtime/contrib/coreml/coreml_runtime.mm | 3 +--
src/runtime/contrib/dnnl/dnnl_json_runtime.cc | 2 +-
src/runtime/contrib/ethosn/ethosn_runtime.cc | 5 ++--
src/runtime/contrib/ethosn/ethosn_runtime.h | 4 ++--
src/runtime/contrib/json/json_runtime.h | 4 ++--
src/runtime/contrib/libtorch/libtorch_runtime.cc | 4 ++--
src/runtime/contrib/onnx/onnx_module.cc | 6 ++---
src/runtime/contrib/tflite/tflite_runtime.cc | 3 +--
src/runtime/contrib/tflite/tflite_runtime.h | 2 +-
src/runtime/contrib/vitis_ai/vitis_ai_runtime.cc | 3 +--
src/runtime/contrib/vitis_ai/vitis_ai_runtime.h | 2 +-
src/runtime/cuda/cuda_module.cc | 11 ++++-----
.../cuda_graph/graph_runtime_cuda_graph.cc | 4 ++--
.../graph_executor/debug/graph_executor_debug.cc | 2 +-
.../graph_executor/debug/graph_executor_debug.h | 2 +-
src/runtime/graph_executor/graph_executor.cc | 3 +--
src/runtime/graph_executor/graph_executor.h | 2 +-
.../graph_executor/graph_executor_factory.cc | 2 +-
.../graph_executor/graph_executor_factory.h | 2 +-
src/runtime/hexagon/hexagon_module.cc | 6 ++---
src/runtime/hexagon/hexagon_module.h | 6 ++---
src/runtime/library_module.cc | 5 ++--
src/runtime/metadata.cc | 2 +-
src/runtime/metal/metal_module.mm | 9 ++++---
src/runtime/module.cc | 15 ++++++------
src/runtime/opencl/opencl_common.h | 8 +++----
src/runtime/opencl/opencl_module.cc | 10 ++++----
src/runtime/opencl/opencl_module_spirv.cc | 6 ++---
src/runtime/opencl/sdaccel/sdaccel_module.cc | 2 +-
src/runtime/pipeline/pipeline_executor.cc | 2 +-
src/runtime/pipeline/pipeline_executor.h | 2 +-
src/runtime/registry.cc | 18 +++++++-------
src/runtime/rocm/rocm_module.cc | 9 ++++---
src/runtime/rpc/rpc_module.cc | 4 ++--
src/runtime/stackvm/stackvm_module.cc | 9 +++----
src/runtime/static_library.cc | 4 ++--
src/runtime/vm/executable.cc | 6 ++---
src/runtime/vm/profiler/vm.cc | 2 +-
src/runtime/vm/profiler/vm.h | 2 +-
src/runtime/vm/vm.cc | 3 +--
src/runtime/vulkan/vulkan_module.cc | 2 +-
src/runtime/vulkan/vulkan_wrapped_func.cc | 6 ++---
src/runtime/vulkan/vulkan_wrapped_func.h | 6 ++---
src/support/ffi_testing.cc | 4 ++--
src/target/llvm/llvm_module.cc | 14 +++++------
src/target/source/codegen_webgpu.cc | 8 ++-----
src/target/source/interface_c.cc | 4 ++--
src/target/source/source_module.cc | 28 +++++++++++-----------
tests/scripts/task_config_build_cpu.sh | 3 ---
tests/scripts/task_config_build_i386.sh | 3 ---
tests/scripts/task_python_vta_fsim.sh | 3 +++
web/emcc/webgpu_runtime.cc | 6 ++---
71 files changed, 171 insertions(+), 187 deletions(-)
diff --git a/apps/dso_plugin_module/plugin_module.cc
b/apps/dso_plugin_module/plugin_module.cc
index bcf37fe760..ae8e7d7817 100644
--- a/apps/dso_plugin_module/plugin_module.cc
+++ b/apps/dso_plugin_module/plugin_module.cc
@@ -35,8 +35,7 @@ class MyModuleNode : public ModuleNode {
virtual const char* type_key() const final { return "MyModule"; }
- virtual PackedFunc GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) final {
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == "add") {
return TypedPackedFunc<int(int)>([sptr_to_self, this](int value) {
return value_ + value; });
} else if (name == "mul") {
diff --git a/include/tvm/runtime/module.h b/include/tvm/runtime/module.h
index 3da4945c86..60e3535319 100644
--- a/include/tvm/runtime/module.h
+++ b/include/tvm/runtime/module.h
@@ -90,7 +90,7 @@ class Module : public ObjectRef {
* This function will return PackedFunc(nullptr) if function do not exist.
* \note Implemented in packed_func.cc
*/
- inline PackedFunc GetFunction(const std::string& name, bool query_imports =
false);
+ inline PackedFunc GetFunction(const String& name, bool query_imports =
false);
// The following functions requires link with runtime.
/*!
* \brief Import another module into this module.
@@ -111,7 +111,7 @@ class Module : public ObjectRef {
* \note This function won't load the import relationship.
* Re-create import relationship by calling Import.
*/
- TVM_DLL static Module LoadFromFile(const std::string& file_name, const
std::string& format = "");
+ TVM_DLL static Module LoadFromFile(const String& file_name, const String&
format = "");
// refer to the corresponding container.
using ContainerType = ModuleNode;
friend class ModuleNode;
@@ -165,14 +165,13 @@ class TVM_DLL ModuleNode : public Object {
* If the function need resource from the module(e.g. late linking),
* it should capture sptr_to_self.
*/
- virtual PackedFunc GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) = 0;
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) = 0;
/*!
* \brief Save the module to file.
* \param file_name The file to be saved to.
* \param format The format of the file.
*/
- virtual void SaveToFile(const std::string& file_name, const std::string&
format);
+ virtual void SaveToFile(const String& file_name, const String& format);
/*!
* \brief Save the module to binary stream.
* \param stream The binary stream to save to.
@@ -186,12 +185,12 @@ class TVM_DLL ModuleNode : public Object {
* \param format Format of the source code, can be empty by default.
* \return Possible source code when available.
*/
- virtual std::string GetSource(const std::string& format = "");
+ virtual String GetSource(const String& format = "");
/*!
* \brief Get the format of the module, when available.
* \return Possible format when available.
*/
- virtual std::string GetFormat();
+ virtual String GetFormat();
/*!
* \brief Get packed function from current module by name.
*
@@ -201,7 +200,7 @@ class TVM_DLL ModuleNode : public Object {
* This function will return PackedFunc(nullptr) if function do not exist.
* \note Implemented in packed_func.cc
*/
- PackedFunc GetFunction(const std::string& name, bool query_imports = false);
+ PackedFunc GetFunction(const String& name, bool query_imports = false);
/*!
* \brief Import another module into this module.
* \param other The module to be imported.
@@ -217,7 +216,7 @@ class TVM_DLL ModuleNode : public Object {
* \param name name of the function.
* \return The corresponding function.
*/
- const PackedFunc* GetFuncFromEnv(const std::string& name);
+ const PackedFunc* GetFuncFromEnv(const String& name);
/*! \return The module it imports from */
const std::vector<Module>& imports() const { return imports_; }
@@ -268,7 +267,7 @@ class TVM_DLL ModuleNode : public Object {
* \param target The target module name.
* \return Whether runtime is enabled.
*/
-TVM_DLL bool RuntimeEnabled(const std::string& target);
+TVM_DLL bool RuntimeEnabled(const String& target);
/*! \brief namespace for constant symbols */
namespace symbol {
diff --git a/include/tvm/runtime/packed_func.h
b/include/tvm/runtime/packed_func.h
index 81c051fcf2..660c24284b 100644
--- a/include/tvm/runtime/packed_func.h
+++ b/include/tvm/runtime/packed_func.h
@@ -1942,7 +1942,7 @@ inline TVMRetValue::operator T() const {
return PackedFuncValueConverter<T>::From(*this);
}
-inline PackedFunc Module::GetFunction(const std::string& name, bool
query_imports) {
+inline PackedFunc Module::GetFunction(const String& name, bool query_imports) {
return (*this)->GetFunction(name, query_imports);
}
diff --git a/include/tvm/runtime/registry.h b/include/tvm/runtime/registry.h
index 5a467c8779..3a1e86e87f 100644
--- a/include/tvm/runtime/registry.h
+++ b/include/tvm/runtime/registry.h
@@ -43,9 +43,9 @@
#ifndef TVM_RUNTIME_REGISTRY_H_
#define TVM_RUNTIME_REGISTRY_H_
+#include <tvm/runtime/container/string.h>
#include <tvm/runtime/packed_func.h>
-#include <string>
#include <type_traits>
#include <utility>
#include <vector>
@@ -295,32 +295,32 @@ class Registry {
* \param override Whether allow override existing function.
* \return Reference to the registry.
*/
- TVM_DLL static Registry& Register(const std::string& name, bool override =
false); // NOLINT(*)
+ TVM_DLL static Registry& Register(const String& name, bool override =
false); // NOLINT(*)
/*!
* \brief Erase global function from registry, if exist.
* \param name The name of the function.
* \return Whether function exist.
*/
- TVM_DLL static bool Remove(const std::string& name);
+ TVM_DLL static bool Remove(const String& name);
/*!
* \brief Get the global function by name.
* \param name The name of the function.
* \return pointer to the registered function,
* nullptr if it does not exist.
*/
- TVM_DLL static const PackedFunc* Get(const std::string& name); // NOLINT(*)
+ TVM_DLL static const PackedFunc* Get(const String& name); // NOLINT(*)
/*!
* \brief Get the names of currently registered global function.
* \return The names
*/
- TVM_DLL static std::vector<std::string> ListNames();
+ TVM_DLL static std::vector<String> ListNames();
// Internal class.
struct Manager;
protected:
/*! \brief name of the function */
- std::string name_;
+ String name_;
/*! \brief internal packed function */
PackedFunc func_;
friend struct Manager;
diff --git a/include/tvm/runtime/vm/executable.h
b/include/tvm/runtime/vm/executable.h
index 4c24d7dead..0714847400 100644
--- a/include/tvm/runtime/vm/executable.h
+++ b/include/tvm/runtime/vm/executable.h
@@ -64,7 +64,7 @@ class TVM_DLL Executable : public ModuleNode {
*
* \return PackedFunc or nullptr when it is not available.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const final { return
ModulePropertyMask::kBinarySerializable; };
@@ -88,7 +88,7 @@ class TVM_DLL Executable : public ModuleNode {
* \param path The path to write the serialized data to.
* \param format The format of the serialized blob.
*/
- void SaveToFile(const std::string& path, const std::string& format) final;
+ void SaveToFile(const String& path, const String& format) final;
/*!
* \brief Serialize the executable into global section, constant section, and
diff --git a/include/tvm/runtime/vm/vm.h b/include/tvm/runtime/vm/vm.h
index 767ae3b0b8..c2adc3b2a0 100644
--- a/include/tvm/runtime/vm/vm.h
+++ b/include/tvm/runtime/vm/vm.h
@@ -164,7 +164,7 @@ class TVM_DLL VirtualMachine : public runtime::ModuleNode {
* If the function needs resource from the module(e.g. late linking),
* it should capture sptr_to_self.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
virtual ~VirtualMachine() {}
diff --git a/src/relay/backend/aot_executor_codegen.cc
b/src/relay/backend/aot_executor_codegen.cc
index 1261d99717..4001c870ef 100644
--- a/src/relay/backend/aot_executor_codegen.cc
+++ b/src/relay/backend/aot_executor_codegen.cc
@@ -1310,7 +1310,7 @@ class AOTExecutorCodegen : public MixedModeVisitor {
class AOTExecutorCodegenModule : public runtime::ModuleNode {
public:
AOTExecutorCodegenModule() {}
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self) {
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) {
if (name == "init") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK_EQ(args.num_args, 2) << "The expected of arguments are: "
diff --git a/src/relay/backend/build_module.cc
b/src/relay/backend/build_module.cc
index 856a770078..abb39a6567 100644
--- a/src/relay/backend/build_module.cc
+++ b/src/relay/backend/build_module.cc
@@ -172,7 +172,7 @@ class RelayBuildModule : public runtime::ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == "get_graph_json") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv =
this->GetGraphJSON(); });
diff --git a/src/relay/backend/contrib/ethosu/source_module.cc
b/src/relay/backend/contrib/ethosu/source_module.cc
index 61a5a6de6a..938ce2b42c 100644
--- a/src/relay/backend/contrib/ethosu/source_module.cc
+++ b/src/relay/backend/contrib/ethosu/source_module.cc
@@ -78,7 +78,7 @@ class EthosUModuleNode : public ModuleNode {
* \param file_name The file to be saved to.
* \param format The format of the file.
*/
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string fmt = GetFileFormat(file_name, format);
ICHECK_EQ(fmt, "c") << "Can only save to format="
<< "c";
@@ -87,9 +87,9 @@ class EthosUModuleNode : public ModuleNode {
out.close();
}
- std::string GetSource(const std::string& format) final { return c_source; }
+ String GetSource(const String& format) final { return c_source; }
- std::string GetFormat() override { return "c"; }
+ String GetFormat() override { return "c"; }
Array<CompilationArtifact> GetArtifacts() { return compilation_artifacts_; }
@@ -101,7 +101,7 @@ class EthosUModuleNode : public ModuleNode {
*
* \return The function pointer when it is found, otherwise,
PackedFunc(nullptr).
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == "get_func_names") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
Array<String> func_names;
diff --git a/src/relay/backend/graph_executor_codegen.cc
b/src/relay/backend/graph_executor_codegen.cc
index d8ce0e59b1..868173d28c 100644
--- a/src/relay/backend/graph_executor_codegen.cc
+++ b/src/relay/backend/graph_executor_codegen.cc
@@ -628,7 +628,7 @@ class GraphExecutorCodegen : public
backend::MemoizedExprTranslator<std::vector<
class GraphExecutorCodegenModule : public runtime::ModuleNode {
public:
GraphExecutorCodegenModule() {}
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self) {
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) {
if (name == "init") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK_EQ(args.num_args, 2) << "The expected of arguments are: "
diff --git a/src/relay/backend/vm/compiler.cc b/src/relay/backend/vm/compiler.cc
index b67a4d8da5..cb79970b25 100644
--- a/src/relay/backend/vm/compiler.cc
+++ b/src/relay/backend/vm/compiler.cc
@@ -827,7 +827,7 @@ class VMFunctionCompiler :
DeviceAwareExprFunctor<void(const Expr& n)> {
VirtualDevice host_virtual_device_;
};
-PackedFunc VMCompiler::GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self) {
+PackedFunc VMCompiler::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
if (name == "lower") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK_EQ(args.num_args, 2);
diff --git a/src/relay/backend/vm/compiler.h b/src/relay/backend/vm/compiler.h
index 8a5faa40b5..5009d90849 100644
--- a/src/relay/backend/vm/compiler.h
+++ b/src/relay/backend/vm/compiler.h
@@ -89,7 +89,7 @@ class VMCompiler : public runtime::ModuleNode {
VMCompiler() = default;
virtual ~VMCompiler() = default;
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
const char* type_key() const final { return "VMCompiler"; }
diff --git a/src/relay/printer/model_library_format_printer.cc
b/src/relay/printer/model_library_format_printer.cc
index 994b3ae09c..aab70910f6 100644
--- a/src/relay/printer/model_library_format_printer.cc
+++ b/src/relay/printer/model_library_format_printer.cc
@@ -56,7 +56,7 @@ class ModelLibraryFormatPrinter : public
::tvm::runtime::ModuleNode {
return rv;
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) override {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) override {
if (name == "print") {
return TypedPackedFunc<std::string(ObjectRef)>(
[sptr_to_self, this](ObjectRef node) { return Print(node); });
diff --git a/src/runtime/aot_executor/aot_executor.cc
b/src/runtime/aot_executor/aot_executor.cc
index 1fed42bf04..955f97adf8 100644
--- a/src/runtime/aot_executor/aot_executor.cc
+++ b/src/runtime/aot_executor/aot_executor.cc
@@ -93,8 +93,7 @@ AotExecutor::AotExecutor(tvm::runtime::Module module, const
std::vector<Device>&
}
}
-PackedFunc AotExecutor::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc AotExecutor::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
// Return member functions during query.
if (name == "set_input") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
diff --git a/src/runtime/aot_executor/aot_executor.h
b/src/runtime/aot_executor/aot_executor.h
index ab30ab8026..164deb5078 100644
--- a/src/runtime/aot_executor/aot_executor.h
+++ b/src/runtime/aot_executor/aot_executor.h
@@ -44,7 +44,7 @@ class TVM_DLL AotExecutor : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) override;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) override;
/*!
* \return The type key of the executor.
diff --git a/src/runtime/aot_executor/aot_executor_factory.cc
b/src/runtime/aot_executor/aot_executor_factory.cc
index 0105c75447..011e0824fb 100644
--- a/src/runtime/aot_executor/aot_executor_factory.cc
+++ b/src/runtime/aot_executor/aot_executor_factory.cc
@@ -42,7 +42,7 @@ AotExecutorFactory::AotExecutorFactory(
}
PackedFunc AotExecutorFactory::GetFunction(
- const std::string& name, const
tvm::runtime::ObjectPtr<tvm::runtime::Object>& sptr_to_self) {
+ const String& name, const tvm::runtime::ObjectPtr<tvm::runtime::Object>&
sptr_to_self) {
if (name == module_name_) {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK_GT(args.num_args, 0) << "Must supply at least one device
argument";
diff --git a/src/runtime/aot_executor/aot_executor_factory.h
b/src/runtime/aot_executor/aot_executor_factory.h
index 4c6e36fc11..15ac6f5e7f 100644
--- a/src/runtime/aot_executor/aot_executor_factory.h
+++ b/src/runtime/aot_executor/aot_executor_factory.h
@@ -58,7 +58,7 @@ class TVM_DLL AotExecutorFactory : public runtime::ModuleNode
{
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
/*!
* \return The type key of the executor.
diff --git a/src/runtime/const_loader_module.cc
b/src/runtime/const_loader_module.cc
index 75e094a63a..35da78a83e 100644
--- a/src/runtime/const_loader_module.cc
+++ b/src/runtime/const_loader_module.cc
@@ -67,7 +67,7 @@ class ConstLoaderModuleNode : public ModuleNode {
}
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
VLOG(1) << "ConstLoaderModuleNode::GetFunction(" << name << ")";
// Initialize and memoize the module.
// Usually, we have some warmup runs. The module initialization should be
diff --git a/src/runtime/contrib/coreml/coreml_runtime.h
b/src/runtime/contrib/coreml/coreml_runtime.h
index 80706425ba..a29230b0d8 100644
--- a/src/runtime/contrib/coreml/coreml_runtime.h
+++ b/src/runtime/contrib/coreml/coreml_runtime.h
@@ -103,7 +103,7 @@ class CoreMLRuntime : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const final {
diff --git a/src/runtime/contrib/coreml/coreml_runtime.mm
b/src/runtime/contrib/coreml/coreml_runtime.mm
index 5aef10ed8a..0fac49a822 100644
--- a/src/runtime/contrib/coreml/coreml_runtime.mm
+++ b/src/runtime/contrib/coreml/coreml_runtime.mm
@@ -128,8 +128,7 @@ void CoreMLRuntime::Init(const std::string& symbol, const
std::string& _model_pa
model_ = std::unique_ptr<CoreMLModel>(new CoreMLModel(url));
}
-PackedFunc CoreMLRuntime::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc CoreMLRuntime::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
// Return member functions during query.
if (name == "invoke" || name == "run") {
return PackedFunc([this](TVMArgs args, TVMRetValue* rv) {
model_->Invoke(); });
diff --git a/src/runtime/contrib/dnnl/dnnl_json_runtime.cc
b/src/runtime/contrib/dnnl/dnnl_json_runtime.cc
index 0cf9764548..0b674f08f2 100644
--- a/src/runtime/contrib/dnnl/dnnl_json_runtime.cc
+++ b/src/runtime/contrib/dnnl/dnnl_json_runtime.cc
@@ -99,7 +99,7 @@ class DNNLJSONRuntime : public JSONRuntimeBase {
}
/* Override GetFunction to reimplement Run method */
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) override {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) override {
if (this->symbol_name_ == name) {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK(this->initialized_) << "The module has not been initialized";
diff --git a/src/runtime/contrib/ethosn/ethosn_runtime.cc
b/src/runtime/contrib/ethosn/ethosn_runtime.cc
index be4a1bbc15..710888242f 100644
--- a/src/runtime/contrib/ethosn/ethosn_runtime.cc
+++ b/src/runtime/contrib/ethosn/ethosn_runtime.cc
@@ -66,8 +66,7 @@
EthosnModule::EthosnModule(std::vector<OrderedCompiledNetwork>* cmms) {
}
}
-PackedFunc EthosnModule::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc EthosnModule::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
if (network_map_.find(name) != network_map_.end()) {
return PackedFunc([sptr_to_self, this, name](TVMArgs args, TVMRetValue*
rv) {
*rv = Inference(args, network_map_[name].proc_mem_alloc.get(),
@@ -143,7 +142,7 @@ Module EthosnModule::LoadFromBinary(void* strm) {
return Module(n);
}
-void EthosnModule::SaveToFile(const std::string& path, const std::string&
format) {
+void EthosnModule::SaveToFile(const String& path, const String& format) {
std::string data;
dmlc::MemoryStringStream writer(&data);
dmlc::SeekStream* strm = &writer;
diff --git a/src/runtime/contrib/ethosn/ethosn_runtime.h
b/src/runtime/contrib/ethosn/ethosn_runtime.h
index b887b73480..2971990a5b 100644
--- a/src/runtime/contrib/ethosn/ethosn_runtime.h
+++ b/src/runtime/contrib/ethosn/ethosn_runtime.h
@@ -69,7 +69,7 @@ class EthosnModule : public ModuleNode {
* \param sptr_to_self The ObjectPtr that points to this module node.
* \return The function pointer when it is found, otherwise,
PackedFunc(nullptr).
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
/*!
* \brief Save a compiled network to a binary stream, which can then be
* serialized to disk.
@@ -100,7 +100,7 @@ class EthosnModule : public ModuleNode {
* \brief Save a module to a specified path.
* \param path Where to save the serialized module.
*/
- void SaveToFile(const std::string& path, const std::string& format) override;
+ void SaveToFile(const String& path, const String& format) override;
const char* type_key() const override { return "ethos-n"; }
diff --git a/src/runtime/contrib/json/json_runtime.h
b/src/runtime/contrib/json/json_runtime.h
index 5409078e85..8eec0447a1 100644
--- a/src/runtime/contrib/json/json_runtime.h
+++ b/src/runtime/contrib/json/json_runtime.h
@@ -75,7 +75,7 @@ class JSONRuntimeBase : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The packed function.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) override {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) override {
if (name == "get_symbol") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv =
this->symbol_name_; });
@@ -145,7 +145,7 @@ class JSONRuntimeBase : public ModuleNode {
* \param format the format to return.
* \return A string of JSON.
*/
- std::string GetSource(const std::string& format = "json") override { return
graph_json_; }
+ String GetSource(const String& format = "json") override { return
graph_json_; }
protected:
/*!
diff --git a/src/runtime/contrib/libtorch/libtorch_runtime.cc
b/src/runtime/contrib/libtorch/libtorch_runtime.cc
index 48ccfc7496..01d927f911 100644
--- a/src/runtime/contrib/libtorch/libtorch_runtime.cc
+++ b/src/runtime/contrib/libtorch/libtorch_runtime.cc
@@ -99,7 +99,7 @@ class TorchModuleNode : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The packed function.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self) {
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) {
if (name == "get_symbol") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv =
this->symbol_name_; });
@@ -146,7 +146,7 @@ class TorchModuleNode : public ModuleNode {
* \param format the format to return.
* \return A string of JSON.
*/
- std::string GetSource(const std::string& format = "json") override {
+ String GetSource(const String& format = "json") override {
return module_.dump_to_str(true, true, true);
}
diff --git a/src/runtime/contrib/onnx/onnx_module.cc
b/src/runtime/contrib/onnx/onnx_module.cc
index 384a368e28..813211ca7c 100644
--- a/src/runtime/contrib/onnx/onnx_module.cc
+++ b/src/runtime/contrib/onnx/onnx_module.cc
@@ -38,7 +38,7 @@ class ONNXSourceModuleNode : public runtime::ModuleNode {
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const final { return ModulePropertyMask::kRunnable; };
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == "get_symbol") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv =
this->symbol_; });
@@ -52,9 +52,9 @@ class ONNXSourceModuleNode : public runtime::ModuleNode {
}
}
- std::string GetSource(const std::string& format) final { return code_; }
+ String GetSource(const String& format) final { return code_; }
- void SaveToFile(const std::string& path, const std::string& format) final {
+ void SaveToFile(const String& path, const String& format) final {
ICHECK_EQ(format, "onnx") << "Can only save to onnx format";
ICHECK_NE(code_.length(), 0);
const PackedFunc* to_onnx_ =
runtime::Registry::Get("relay.ext.onnx.save_to_file");
diff --git a/src/runtime/contrib/tflite/tflite_runtime.cc
b/src/runtime/contrib/tflite/tflite_runtime.cc
index 2806cb33b8..17ca44174b 100644
--- a/src/runtime/contrib/tflite/tflite_runtime.cc
+++ b/src/runtime/contrib/tflite/tflite_runtime.cc
@@ -150,8 +150,7 @@ NDArray TFLiteRuntime::GetOutput(int index) const {
return ret;
}
-PackedFunc TFLiteRuntime::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc TFLiteRuntime::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
// Return member functions during query.
if (name == "set_input") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
diff --git a/src/runtime/contrib/tflite/tflite_runtime.h
b/src/runtime/contrib/tflite/tflite_runtime.h
index 2a52447959..eeba3e0a0e 100644
--- a/src/runtime/contrib/tflite/tflite_runtime.h
+++ b/src/runtime/contrib/tflite/tflite_runtime.h
@@ -53,7 +53,7 @@ class TFLiteRuntime : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
/*!
* \return The type key of the executor.
diff --git a/src/runtime/contrib/vitis_ai/vitis_ai_runtime.cc
b/src/runtime/contrib/vitis_ai/vitis_ai_runtime.cc
index f9c1cd82b4..46246b0295 100755
--- a/src/runtime/contrib/vitis_ai/vitis_ai_runtime.cc
+++ b/src/runtime/contrib/vitis_ai/vitis_ai_runtime.cc
@@ -147,8 +147,7 @@ void VitisAIRuntime::SaveToBinary(dmlc::Stream* stream) {
}
}
-PackedFunc VitisAIRuntime::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc VitisAIRuntime::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
if (name == "get_symbol") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv =
this->symbol_name_; });
diff --git a/src/runtime/contrib/vitis_ai/vitis_ai_runtime.h
b/src/runtime/contrib/vitis_ai/vitis_ai_runtime.h
index ccaa88c1ac..2cc5918c8f 100755
--- a/src/runtime/contrib/vitis_ai/vitis_ai_runtime.h
+++ b/src/runtime/contrib/vitis_ai/vitis_ai_runtime.h
@@ -79,7 +79,7 @@ class VitisAIRuntime : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
/*!
* \return The type key of the executor.
diff --git a/src/runtime/cuda/cuda_module.cc b/src/runtime/cuda/cuda_module.cc
index 240e1fe1aa..f54aefe8c4 100644
--- a/src/runtime/cuda/cuda_module.cc
+++ b/src/runtime/cuda/cuda_module.cc
@@ -70,9 +70,9 @@ class CUDAModuleNode : public runtime::ModuleNode {
return ModulePropertyMask::kBinarySerializable |
ModulePropertyMask::kRunnable;
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string fmt = GetFileFormat(file_name, format);
std::string meta_file = GetMetaFilePath(file_name);
if (fmt == "cu") {
@@ -92,7 +92,7 @@ class CUDAModuleNode : public runtime::ModuleNode {
stream->Write(data_);
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
if (format == fmt_) return data_;
if (cuda_source_.length() != 0) {
return cuda_source_;
@@ -246,8 +246,7 @@ class CUDAPrepGlobalBarrier {
mutable std::array<CUdeviceptr, kMaxNumGPUs> pcache_;
};
-PackedFunc CUDAModuleNode::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc CUDAModuleNode::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
ICHECK_EQ(sptr_to_self.get(), this);
ICHECK_NE(name, symbol::tvm_module_main) << "Device function do not have
main";
if (name == symbol::tvm_prepare_global_barrier) {
@@ -269,7 +268,7 @@ Module CUDAModuleCreate(std::string data, std::string fmt,
}
// Load module from module.
-Module CUDAModuleLoadFile(const std::string& file_name, const std::string&
format) {
+Module CUDAModuleLoadFile(const std::string& file_name, const String& format) {
std::string data;
std::unordered_map<std::string, FunctionInfo> fmap;
std::string fmt = GetFileFormat(file_name, format);
diff --git a/src/runtime/graph_executor/cuda_graph/graph_runtime_cuda_graph.cc
b/src/runtime/graph_executor/cuda_graph/graph_runtime_cuda_graph.cc
index 53f225403b..5cd331807d 100644
--- a/src/runtime/graph_executor/cuda_graph/graph_runtime_cuda_graph.cc
+++ b/src/runtime/graph_executor/cuda_graph/graph_runtime_cuda_graph.cc
@@ -84,7 +84,7 @@ class GraphExecutorCudaGraph : public GraphExecutor {
* \param name The function which needs to be invoked.
* \param sptr_to_self Packed function pointer.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self);
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
private:
/*! \brief The Cuda stream on which to capture a CUDA graph. */
@@ -93,7 +93,7 @@ class GraphExecutorCudaGraph : public GraphExecutor {
cudaGraphExec_t cuda_graph_exec_;
};
-PackedFunc GraphExecutorCudaGraph::GetFunction(const std::string& name,
+PackedFunc GraphExecutorCudaGraph::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
if (name == "run_cuda_graph") {
return PackedFunc(
diff --git a/src/runtime/graph_executor/debug/graph_executor_debug.cc
b/src/runtime/graph_executor/debug/graph_executor_debug.cc
index 5e6182ec27..94e27703b6 100644
--- a/src/runtime/graph_executor/debug/graph_executor_debug.cc
+++ b/src/runtime/graph_executor/debug/graph_executor_debug.cc
@@ -192,7 +192,7 @@ Timer GraphExecutorDebug::RunOpHost(int index) {
* \param name The function which needs to be invoked.
* \param sptr_to_self Packed function pointer.
*/
-PackedFunc GraphExecutorDebug::GetFunction(const std::string& name,
+PackedFunc GraphExecutorDebug::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
// return member functions during query.
if (name == "debug_get_output") {
diff --git a/src/runtime/graph_executor/debug/graph_executor_debug.h
b/src/runtime/graph_executor/debug/graph_executor_debug.h
index a53245c2e2..7c9d8f2cd1 100644
--- a/src/runtime/graph_executor/debug/graph_executor_debug.h
+++ b/src/runtime/graph_executor/debug/graph_executor_debug.h
@@ -79,7 +79,7 @@ class GraphExecutorDebug : public GraphExecutor {
* \param name The function which needs to be invoked.
* \param sptr_to_self Packed function pointer.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self);
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
/*!
* \brief Get the node index given the name of node.
diff --git a/src/runtime/graph_executor/graph_executor.cc
b/src/runtime/graph_executor/graph_executor.cc
index 3c3d931df5..f4b3647830 100644
--- a/src/runtime/graph_executor/graph_executor.cc
+++ b/src/runtime/graph_executor/graph_executor.cc
@@ -593,8 +593,7 @@ std::pair<std::function<void()>,
std::shared_ptr<GraphExecutor::OpArgs>> GraphEx
return {fexec, arg_ptr};
}
-PackedFunc GraphExecutor::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc GraphExecutor::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
// Return member functions during query.
if (name == "set_input") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
diff --git a/src/runtime/graph_executor/graph_executor.h
b/src/runtime/graph_executor/graph_executor.h
index 0a7086c9f1..fb2dded4cf 100644
--- a/src/runtime/graph_executor/graph_executor.h
+++ b/src/runtime/graph_executor/graph_executor.h
@@ -81,7 +81,7 @@ class TVM_DLL GraphExecutor : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
/*!
* \return The type key of the executor.
diff --git a/src/runtime/graph_executor/graph_executor_factory.cc
b/src/runtime/graph_executor/graph_executor_factory.cc
index 56b2fa3fba..90c42ca74b 100644
--- a/src/runtime/graph_executor/graph_executor_factory.cc
+++ b/src/runtime/graph_executor/graph_executor_factory.cc
@@ -45,7 +45,7 @@ GraphExecutorFactory::GraphExecutorFactory(
}
PackedFunc GraphExecutorFactory::GetFunction(
- const std::string& name, const
tvm::runtime::ObjectPtr<tvm::runtime::Object>& sptr_to_self) {
+ const String& name, const tvm::runtime::ObjectPtr<tvm::runtime::Object>&
sptr_to_self) {
if (name == module_name_) {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
std::vector<Device> devices;
diff --git a/src/runtime/graph_executor/graph_executor_factory.h
b/src/runtime/graph_executor/graph_executor_factory.h
index 2766dfafc2..2f41bb4e2e 100644
--- a/src/runtime/graph_executor/graph_executor_factory.h
+++ b/src/runtime/graph_executor/graph_executor_factory.h
@@ -60,7 +60,7 @@ class TVM_DLL GraphExecutorFactory : public
runtime::ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding member function.
*/
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
/*!
* \return The type key of the executor.
diff --git a/src/runtime/hexagon/hexagon_module.cc
b/src/runtime/hexagon/hexagon_module.cc
index 59c8aa931d..26297247fc 100644
--- a/src/runtime/hexagon/hexagon_module.cc
+++ b/src/runtime/hexagon/hexagon_module.cc
@@ -42,12 +42,12 @@ HexagonModuleNode::HexagonModuleNode(std::string data,
std::string fmt,
std::string bc_str)
: data_(data), fmt_(fmt), fmap_(fmap), asm_(asm_str), obj_(obj_str),
ir_(ir_str), bc_(bc_str) {}
-PackedFunc HexagonModuleNode::GetFunction(const std::string& name,
+PackedFunc HexagonModuleNode::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
LOG(FATAL) << "HexagonModuleNode::GetFunction is not implemented.";
}
-std::string HexagonModuleNode::GetSource(const std::string& format) {
+String HexagonModuleNode::GetSource(const String& format) {
if (format == "s" || format == "asm") {
return asm_;
}
@@ -57,7 +57,7 @@ std::string HexagonModuleNode::GetSource(const std::string&
format) {
return "";
}
-void HexagonModuleNode::SaveToFile(const std::string& file_name, const
std::string& format) {
+void HexagonModuleNode::SaveToFile(const String& file_name, const String&
format) {
std::string fmt = runtime::GetFileFormat(file_name, format);
if (fmt == "so" || fmt == "dll" || fmt == "hexagon") {
std::string meta_file = GetMetaFilePath(file_name);
diff --git a/src/runtime/hexagon/hexagon_module.h
b/src/runtime/hexagon/hexagon_module.h
index 96595df470..0abe175e90 100644
--- a/src/runtime/hexagon/hexagon_module.h
+++ b/src/runtime/hexagon/hexagon_module.h
@@ -59,15 +59,15 @@ class HexagonModuleNode : public runtime::ModuleNode {
HexagonModuleNode(std::string data, std::string fmt,
std::unordered_map<std::string, FunctionInfo> fmap,
std::string asm_str,
std::string obj_str, std::string ir_str, std::string
bc_str);
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) override;
- std::string GetSource(const std::string& format) override;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) override;
+ String GetSource(const String& format) override;
const char* type_key() const final { return "hexagon"; }
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const override {
return ModulePropertyMask::kBinarySerializable |
ModulePropertyMask::kDSOExportable |
ModulePropertyMask::kRunnable;
}
- void SaveToFile(const std::string& file_name, const std::string& format)
override;
+ void SaveToFile(const String& file_name, const String& format) override;
void SaveToBinary(dmlc::Stream* stream) override;
protected:
diff --git a/src/runtime/library_module.cc b/src/runtime/library_module.cc
index eed41dfc2b..eb5e85beb5 100644
--- a/src/runtime/library_module.cc
+++ b/src/runtime/library_module.cc
@@ -47,7 +47,7 @@ class LibraryModuleNode final : public ModuleNode {
return ModulePropertyMask::kBinarySerializable |
ModulePropertyMask::kRunnable;
};
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
TVMBackendPackedCFunc faddr;
if (name == runtime::symbol::tvm_module_main) {
const char* entry_name =
@@ -112,7 +112,8 @@ Module LoadModuleFromBinary(const std::string& type_key,
dmlc::Stream* stream) {
const PackedFunc* f = Registry::Get(fkey);
if (f == nullptr) {
std::string loaders = "";
- for (auto name : Registry::ListNames()) {
+ for (auto reg_name : Registry::ListNames()) {
+ std::string name = reg_name;
if (name.find(loadkey, 0) == 0) {
if (loaders.size() > 0) {
loaders += ", ";
diff --git a/src/runtime/metadata.cc b/src/runtime/metadata.cc
index 946ebf1232..2fd26f5324 100644
--- a/src/runtime/metadata.cc
+++ b/src/runtime/metadata.cc
@@ -97,7 +97,7 @@ class MetadataModuleNode : public ::tvm::runtime::ModuleNode {
void SaveToBinary(dmlc::Stream* stream) final {}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) {
if (name == "get_metadata") {
return PackedFunc([this, sptr_to_self](TVMArgs args, TVMRetValue* rv) {
if (!metadata_.defined()) {
diff --git a/src/runtime/metal/metal_module.mm
b/src/runtime/metal/metal_module.mm
index aef6cf5ebe..9cf61a2f21 100644
--- a/src/runtime/metal/metal_module.mm
+++ b/src/runtime/metal/metal_module.mm
@@ -57,9 +57,9 @@ class MetalModuleNode final : public runtime::ModuleNode {
return ModulePropertyMask::kBinarySerializable |
ModulePropertyMask::kRunnable;
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
LOG(FATAL) << "Do not support save to file, use save to binary and export
instead";
}
@@ -70,7 +70,7 @@ class MetalModuleNode final : public runtime::ModuleNode {
stream->Write(fmap_);
stream->Write(fmt_);
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
// return text source if available.
return source_;
}
@@ -241,8 +241,7 @@ class MetalWrappedFunc {
LaunchParamConfig launch_param_config_;
};
-PackedFunc MetalModuleNode::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self)
{
+PackedFunc MetalModuleNode::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
PackedFunc pf;
AUTORELEASEPOOL {
ICHECK_EQ(sptr_to_self.get(), this);
diff --git a/src/runtime/module.cc b/src/runtime/module.cc
index 298fd588d5..92158147d8 100644
--- a/src/runtime/module.cc
+++ b/src/runtime/module.cc
@@ -61,7 +61,7 @@ void ModuleNode::Import(Module other) {
this->imports_.emplace_back(std::move(other));
}
-PackedFunc ModuleNode::GetFunction(const std::string& name, bool
query_imports) {
+PackedFunc ModuleNode::GetFunction(const String& name, bool query_imports) {
ModuleNode* self = this;
PackedFunc pf = self->GetFunction(name, GetObjectPtr<Object>(this));
if (pf != nullptr) return pf;
@@ -76,7 +76,7 @@ PackedFunc ModuleNode::GetFunction(const std::string& name,
bool query_imports)
return pf;
}
-Module Module::LoadFromFile(const std::string& file_name, const std::string&
format) {
+Module Module::LoadFromFile(const String& file_name, const String& format) {
std::string fmt = GetFileFormat(file_name, format);
ICHECK(fmt.length() != 0) << "Cannot deduce format of file " << file_name;
if (fmt == "dll" || fmt == "dylib" || fmt == "dso") {
@@ -93,7 +93,7 @@ Module Module::LoadFromFile(const std::string& file_name,
const std::string& for
return m;
}
-void ModuleNode::SaveToFile(const std::string& file_name, const std::string&
format) {
+void ModuleNode::SaveToFile(const String& file_name, const String& format) {
LOG(FATAL) << "Module[" << type_key() << "] does not support SaveToFile";
}
@@ -101,11 +101,11 @@ void ModuleNode::SaveToBinary(dmlc::Stream* stream) {
LOG(FATAL) << "Module[" << type_key() << "] does not support SaveToBinary";
}
-std::string ModuleNode::GetSource(const std::string& format) {
+String ModuleNode::GetSource(const String& format) {
LOG(FATAL) << "Module[" << type_key() << "] does not support GetSource";
}
-const PackedFunc* ModuleNode::GetFuncFromEnv(const std::string& name) {
+const PackedFunc* ModuleNode::GetFuncFromEnv(const String& name) {
std::lock_guard<std::mutex> lock(mutex_);
auto it = import_cache_.find(name);
if (it != import_cache_.end()) return it->second.get();
@@ -128,7 +128,7 @@ const PackedFunc* ModuleNode::GetFuncFromEnv(const
std::string& name) {
}
}
-std::string ModuleNode::GetFormat() {
+String ModuleNode::GetFormat() {
LOG(FATAL) << "Module[" << type_key() << "] does not support GetFormat";
}
@@ -136,7 +136,8 @@ bool ModuleNode::ImplementsFunction(const String& name,
bool query_imports) {
return GetFunction(name, query_imports) != nullptr;
}
-bool RuntimeEnabled(const std::string& target) {
+bool RuntimeEnabled(const String& target_str) {
+ std::string target = target_str;
std::string f_name;
if (target == "cpu") {
return true;
diff --git a/src/runtime/opencl/opencl_common.h
b/src/runtime/opencl/opencl_common.h
index d25d2db0eb..a303141357 100644
--- a/src/runtime/opencl/opencl_common.h
+++ b/src/runtime/opencl/opencl_common.h
@@ -434,7 +434,7 @@ class OpenCLModuleNodeBase : public ModuleNode {
return ModulePropertyMask::kBinarySerializable |
ModulePropertyMask::kRunnable;
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) override;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) override;
// Initialize the programs
virtual void Init() = 0;
@@ -464,12 +464,12 @@ class OpenCLModuleNode : public OpenCLModuleNodeBase {
std::unordered_map<std::string, FunctionInfo>
fmap, std::string source)
: OpenCLModuleNodeBase(fmap), data_(data), fmt_(fmt), source_(source) {}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
- void SaveToFile(const std::string& file_name, const std::string& format)
final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ void SaveToFile(const String& file_name, const String& format) final;
void SaveToBinary(dmlc::Stream* stream) final;
void SetPreCompiledPrograms(const std::string& bytes);
std::string GetPreCompiledPrograms();
- std::string GetSource(const std::string& format) final;
+ String GetSource(const String& format) final;
// Initialize the programs
void Init() override;
diff --git a/src/runtime/opencl/opencl_module.cc
b/src/runtime/opencl/opencl_module.cc
index 5f2bc5db49..6829d46d43 100644
--- a/src/runtime/opencl/opencl_module.cc
+++ b/src/runtime/opencl/opencl_module.cc
@@ -134,7 +134,7 @@ cl::OpenCLWorkspace*
OpenCLModuleNodeBase::GetGlobalWorkspace() {
return cl::OpenCLWorkspace::Global();
}
-PackedFunc OpenCLModuleNodeBase::GetFunction(const std::string& name,
+PackedFunc OpenCLModuleNodeBase::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
ICHECK_EQ(sptr_to_self.get(), this);
ICHECK_NE(name, symbol::tvm_module_main) << "Device function do not have
main";
@@ -160,7 +160,7 @@ PackedFunc OpenCLModuleNodeBase::GetFunction(const
std::string& name,
return PackFuncVoidAddr(f, info.arg_types);
}
-void OpenCLModuleNode::SaveToFile(const std::string& file_name, const
std::string& format) {
+void OpenCLModuleNode::SaveToFile(const String& file_name, const String&
format) {
std::string fmt = GetFileFormat(file_name, format);
ICHECK_EQ(fmt, fmt_) << "Can only save to format=" << fmt_;
std::string meta_file = GetMetaFilePath(file_name);
@@ -174,7 +174,7 @@ void OpenCLModuleNode::SaveToBinary(dmlc::Stream* stream) {
stream->Write(data_);
}
-std::string OpenCLModuleNode::GetSource(const std::string& format) {
+String OpenCLModuleNode::GetSource(const String& format) {
if (format == fmt_) return data_;
if (fmt_ == "cl") {
return data_;
@@ -337,7 +337,7 @@ std::string OpenCLModuleNode::GetPreCompiledPrograms() {
return data;
}
-PackedFunc OpenCLModuleNode::GetFunction(const std::string& name,
+PackedFunc OpenCLModuleNode::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
ICHECK_EQ(sptr_to_self.get(), this);
if (name == "opencl.GetPreCompiledPrograms") {
@@ -360,7 +360,7 @@ Module OpenCLModuleCreate(std::string data, std::string fmt,
}
// Load module from module.
-Module OpenCLModuleLoadFile(const std::string& file_name, const std::string&
format) {
+Module OpenCLModuleLoadFile(const std::string& file_name, const String&
format) {
std::string data;
std::unordered_map<std::string, FunctionInfo> fmap;
std::string fmt = GetFileFormat(file_name, format);
diff --git a/src/runtime/opencl/opencl_module_spirv.cc
b/src/runtime/opencl/opencl_module_spirv.cc
index 5e3ecf2eeb..7e52b7057b 100644
--- a/src/runtime/opencl/opencl_module_spirv.cc
+++ b/src/runtime/opencl/opencl_module_spirv.cc
@@ -39,9 +39,9 @@ class OpenCLSPIRVModuleNode : public OpenCLModuleNodeBase {
std::unordered_map<std::string, FunctionInfo>
fmap)
: OpenCLModuleNodeBase(fmap), shaders_(shaders), spirv_text_(spirv_text)
{}
- void SaveToFile(const std::string& file_name, const std::string& format)
final;
+ void SaveToFile(const String& file_name, const String& format) final;
void SaveToBinary(dmlc::Stream* stream) final;
- std::string GetSource(const std::string&) final { return spirv_text_; }
+ String GetSource(const String&) final { return spirv_text_; }
void Init() override;
cl_kernel InstallKernel(cl::OpenCLWorkspace* w, cl::OpenCLThreadEntry* t,
@@ -52,7 +52,7 @@ class OpenCLSPIRVModuleNode : public OpenCLModuleNodeBase {
std::string spirv_text_;
};
-void OpenCLSPIRVModuleNode::SaveToFile(const std::string& file_name, const
std::string& format) {
+void OpenCLSPIRVModuleNode::SaveToFile(const String& file_name, const String&
format) {
// TODO(masahi): How SPIRV binaries should be save to a file?
LOG(FATAL) << "Not implemented.";
}
diff --git a/src/runtime/opencl/sdaccel/sdaccel_module.cc
b/src/runtime/opencl/sdaccel/sdaccel_module.cc
index 36dabd1e02..4736e1ef35 100644
--- a/src/runtime/opencl/sdaccel/sdaccel_module.cc
+++ b/src/runtime/opencl/sdaccel/sdaccel_module.cc
@@ -53,7 +53,7 @@ Module SDAccelModuleCreate(std::string data, std::string fmt,
return Module(n);
}
-Module SDAccelModuleLoadFile(const std::string& file_name, const std::string&
format) {
+Module SDAccelModuleLoadFile(const std::string& file_name, const String&
format) {
std::string data;
std::unordered_map<std::string, FunctionInfo> fmap;
std::string fmt = GetFileFormat(file_name, format);
diff --git a/src/runtime/pipeline/pipeline_executor.cc
b/src/runtime/pipeline/pipeline_executor.cc
index 39f995a376..a001374293 100644
--- a/src/runtime/pipeline/pipeline_executor.cc
+++ b/src/runtime/pipeline/pipeline_executor.cc
@@ -29,7 +29,7 @@ namespace runtime {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding packed function.
*/
-PackedFunc PipelineExecutor::GetFunction(const std::string& name,
+PackedFunc PipelineExecutor::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
if (name == "get_num_outputs") {
return PackedFunc(
diff --git a/src/runtime/pipeline/pipeline_executor.h
b/src/runtime/pipeline/pipeline_executor.h
index 87b50ed3a1..d9058871e7 100644
--- a/src/runtime/pipeline/pipeline_executor.h
+++ b/src/runtime/pipeline/pipeline_executor.h
@@ -69,7 +69,7 @@ class TVM_DLL PipelineExecutor : public ModuleNode {
* \param sptr_to_self The pointer to the module node.
* \return The corresponding packed function.
*/
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
/*!
* \brief Using the global input name to get the index, and also get the
input interface name
of corresponding subgraph from the input connection configuration.
diff --git a/src/runtime/registry.cc b/src/runtime/registry.cc
index 7b171f6e77..84586ff630 100644
--- a/src/runtime/registry.cc
+++ b/src/runtime/registry.cc
@@ -42,7 +42,7 @@ struct Registry::Manager {
// This is because PackedFunc can contain callbacks into the host language
(Python) and the
// resource can become invalid because of indeterministic order of
destruction and forking.
// The resources will only be recycled during program exit.
- std::unordered_map<std::string, Registry*> fmap;
+ std::unordered_map<String, Registry*> fmap;
// mutex
std::mutex mutex;
@@ -62,7 +62,7 @@ Registry& Registry::set_body(PackedFunc f) { // NOLINT(*)
return *this;
}
-Registry& Registry::Register(const std::string& name, bool can_override) { //
NOLINT(*)
+Registry& Registry::Register(const String& name, bool can_override) { //
NOLINT(*)
Manager* m = Manager::Global();
std::lock_guard<std::mutex> lock(m->mutex);
if (m->fmap.count(name)) {
@@ -75,7 +75,7 @@ Registry& Registry::Register(const std::string& name, bool
can_override) { // N
return *r;
}
-bool Registry::Remove(const std::string& name) {
+bool Registry::Remove(const String& name) {
Manager* m = Manager::Global();
std::lock_guard<std::mutex> lock(m->mutex);
auto it = m->fmap.find(name);
@@ -84,7 +84,7 @@ bool Registry::Remove(const std::string& name) {
return true;
}
-const PackedFunc* Registry::Get(const std::string& name) {
+const PackedFunc* Registry::Get(const String& name) {
Manager* m = Manager::Global();
std::lock_guard<std::mutex> lock(m->mutex);
auto it = m->fmap.find(name);
@@ -92,10 +92,10 @@ const PackedFunc* Registry::Get(const std::string& name) {
return &(it->second->func_);
}
-std::vector<std::string> Registry::ListNames() {
+std::vector<String> Registry::ListNames() {
Manager* m = Manager::Global();
std::lock_guard<std::mutex> lock(m->mutex);
- std::vector<std::string> keys;
+ std::vector<String> keys;
keys.reserve(m->fmap.size());
for (const auto& kv : m->fmap) {
keys.push_back(kv.first);
@@ -141,7 +141,7 @@ class EnvCAPIRegistry {
}
// register environment(e.g. python) specific api functions
- void Register(const std::string& symbol_name, void* fptr) {
+ void Register(const String& symbol_name, void* fptr) {
if (symbol_name == "PyErr_CheckSignals") {
Update(symbol_name, &pyerr_check_signals, fptr);
} else {
@@ -162,7 +162,7 @@ class EnvCAPIRegistry {
private:
// update the internal API table
template <typename FType>
- void Update(const std::string& symbol_name, FType* target, void* ptr) {
+ void Update(const String& symbol_name, FType* target, void* ptr) {
FType ptr_casted = reinterpret_cast<FType>(ptr);
if (target[0] != nullptr && target[0] != ptr_casted) {
LOG(WARNING) << "tvm.runtime.RegisterEnvCAPI overrides an existing
function " << symbol_name;
@@ -179,7 +179,7 @@ void EnvCheckSignals() {
EnvCAPIRegistry::Global()->CheckSignals(); }
/*! \brief entry to easily hold returning information */
struct TVMFuncThreadLocalEntry {
/*! \brief result holder for returning strings */
- std::vector<std::string> ret_vec_str;
+ std::vector<tvm::runtime::String> ret_vec_str;
/*! \brief result holder for returning string pointers */
std::vector<const char*> ret_vec_charp;
};
diff --git a/src/runtime/rocm/rocm_module.cc b/src/runtime/rocm/rocm_module.cc
index 487ad23e16..cf3530c0af 100644
--- a/src/runtime/rocm/rocm_module.cc
+++ b/src/runtime/rocm/rocm_module.cc
@@ -64,9 +64,9 @@ class ROCMModuleNode : public runtime::ModuleNode {
const char* type_key() const final { return "hip"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string fmt = GetFileFormat(file_name, format);
std::string meta_file = GetMetaFilePath(file_name);
// note: llvm and asm formats are not laodable, so we don't save them
@@ -81,7 +81,7 @@ class ROCMModuleNode : public runtime::ModuleNode {
stream->Write(data_);
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
if (format == fmt_) {
return data_;
}
@@ -188,8 +188,7 @@ class ROCMWrappedFunc {
LaunchParamConfig launch_param_config_;
};
-PackedFunc ROCMModuleNode::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc ROCMModuleNode::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
ICHECK_EQ(sptr_to_self.get(), this);
ICHECK_NE(name, symbol::tvm_module_main) << "Device function do not have
main";
auto it = fmap_.find(name);
diff --git a/src/runtime/rpc/rpc_module.cc b/src/runtime/rpc/rpc_module.cc
index ed769d97ab..d82a0cc471 100644
--- a/src/runtime/rpc/rpc_module.cc
+++ b/src/runtime/rpc/rpc_module.cc
@@ -178,7 +178,7 @@ class RPCModuleNode final : public ModuleNode {
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const final { return ModulePropertyMask::kRunnable; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == "CloseRPCConnection") {
return PackedFunc([this](TVMArgs, TVMRetValue*) { sess_->Shutdown(); });
}
@@ -191,7 +191,7 @@ class RPCModuleNode final : public ModuleNode {
}
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
LOG(FATAL) << "GetSource for rpc Module is not supported";
}
diff --git a/src/runtime/stackvm/stackvm_module.cc
b/src/runtime/stackvm/stackvm_module.cc
index bbcadd21b4..867ccc8ed0 100644
--- a/src/runtime/stackvm/stackvm_module.cc
+++ b/src/runtime/stackvm/stackvm_module.cc
@@ -39,7 +39,7 @@ class StackVMModuleNode : public runtime::ModuleNode {
public:
const char* type_key() const final { return "stackvm"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == runtime::symbol::tvm_module_main) {
return GetFunction(entry_func_, sptr_to_self);
}
@@ -51,7 +51,7 @@ class StackVMModuleNode : public runtime::ModuleNode {
[vm, sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { vm.Run(args,
this); });
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
std::ostringstream os;
for (const auto& kv : fmap_) {
os << "Function: " << kv.first << '\n';
@@ -60,7 +60,7 @@ class StackVMModuleNode : public runtime::ModuleNode {
return os.str();
}
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string data, mblob;
dmlc::MemoryStringStream writer(&data);
dmlc::Stream* strm = &writer;
@@ -104,7 +104,8 @@ class StackVMModuleNode : public runtime::ModuleNode {
const PackedFunc* f = Registry::Get(fkey);
if (f == nullptr) {
std::string loaders = "";
- for (auto name : Registry::ListNames()) {
+ for (auto reg_name : Registry::ListNames()) {
+ std::string name = reg_name;
if (name.rfind(loadkey, 0) == 0) {
if (loaders.size() > 0) {
loaders += ", ";
diff --git a/src/runtime/static_library.cc b/src/runtime/static_library.cc
index 09705a7a06..7adfeb19c3 100644
--- a/src/runtime/static_library.cc
+++ b/src/runtime/static_library.cc
@@ -48,7 +48,7 @@ class StaticLibraryNode final : public runtime::ModuleNode {
const char* type_key() const final { return "static_library"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
if (name == "get_func_names") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
*rv = func_names_; });
} else {
@@ -56,7 +56,7 @@ class StaticLibraryNode final : public runtime::ModuleNode {
}
}
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
VLOG(0) << "Saving static library of " << data_.size() << " bytes
implementing " << FuncNames()
<< " to '" << file_name << "'";
SaveBinaryToFile(file_name, data_);
diff --git a/src/runtime/vm/executable.cc b/src/runtime/vm/executable.cc
index 899d86e961..2b3119b169 100644
--- a/src/runtime/vm/executable.cc
+++ b/src/runtime/vm/executable.cc
@@ -55,7 +55,7 @@ VMInstructionSerializer SerializeInstruction(const
Instruction& instr);
// Helper to deserialize a serialized vm instruction.
Instruction DeserializeInstruction(const VMInstructionSerializer& instr);
-PackedFunc Executable::GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self) {
+PackedFunc Executable::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
if (name == "get_lib") {
return PackedFunc(
[sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv =
this->GetLib(); });
@@ -1057,7 +1057,7 @@ Module ExecutableLoadBinary(void* strm) {
return exec;
}
-void Executable::SaveToFile(const std::string& path, const std::string&
format) {
+void Executable::SaveToFile(const String& path, const String& format) {
tvm::runtime::SimpleBinaryFileStream stream(path, "wb");
SaveToBinary(&stream);
}
@@ -1065,7 +1065,7 @@ void Executable::SaveToFile(const std::string& path,
const std::string& format)
TVM_REGISTER_GLOBAL("runtime.module.loadbinary_VMExecutable").set_body_typed(ExecutableLoadBinary);
// Load module from module.
-Module ExecutableLoadFile(const std::string& file_name, const std::string&
format) {
+Module ExecutableLoadFile(const std::string& file_name, const String& format) {
tvm::runtime::SimpleBinaryFileStream stream(file_name, "rb");
auto exec = ExecutableLoadBinary(reinterpret_cast<void*>(&stream));
return exec;
diff --git a/src/runtime/vm/profiler/vm.cc b/src/runtime/vm/profiler/vm.cc
index db8a3f5dc2..360185aac5 100644
--- a/src/runtime/vm/profiler/vm.cc
+++ b/src/runtime/vm/profiler/vm.cc
@@ -42,7 +42,7 @@ namespace tvm {
namespace runtime {
namespace vm {
-PackedFunc VirtualMachineDebug::GetFunction(const std::string& name,
+PackedFunc VirtualMachineDebug::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
if (name == "profile") {
return TypedPackedFunc<profiling::Report(String,
Array<profiling::MetricCollector>)>(
diff --git a/src/runtime/vm/profiler/vm.h b/src/runtime/vm/profiler/vm.h
index f0374c75a7..a91869454e 100644
--- a/src/runtime/vm/profiler/vm.h
+++ b/src/runtime/vm/profiler/vm.h
@@ -42,7 +42,7 @@ class VirtualMachineDebug : public VirtualMachine {
public:
VirtualMachineDebug() : VirtualMachine(), prof_({}) {}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
void LoadExecutable(const ObjectPtr<Executable>& exec) final;
diff --git a/src/runtime/vm/vm.cc b/src/runtime/vm/vm.cc
index 72e624f7f6..50c757f8fb 100644
--- a/src/runtime/vm/vm.cc
+++ b/src/runtime/vm/vm.cc
@@ -127,8 +127,7 @@ std::vector<int64_t> ToShape(NDArray shape_tensor) {
void VirtualMachine::OpStartHook(Instruction instr) {}
void VirtualMachine::OpStopHook() {}
-PackedFunc VirtualMachine::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc VirtualMachine::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
if (name == "invoke") {
return PackedFunc([sptr_to_self, this](TVMArgs args, TVMRetValue* rv) {
ICHECK(exec_) << "The executable is not created yet.";
diff --git a/src/runtime/vulkan/vulkan_module.cc
b/src/runtime/vulkan/vulkan_module.cc
index 232cf1d58e..600d7d6f87 100644
--- a/src/runtime/vulkan/vulkan_module.cc
+++ b/src/runtime/vulkan/vulkan_module.cc
@@ -35,7 +35,7 @@ Module VulkanModuleCreate(std::unordered_map<std::string,
SPIRVShader> smap,
return Module(n);
}
-Module VulkanModuleLoadFile(const std::string& file_name, const std::string&
format) {
+Module VulkanModuleLoadFile(const std::string& file_name, const String&
format) {
std::string data;
std::unordered_map<std::string, SPIRVShader> smap;
std::unordered_map<std::string, FunctionInfo> fmap;
diff --git a/src/runtime/vulkan/vulkan_wrapped_func.cc
b/src/runtime/vulkan/vulkan_wrapped_func.cc
index f06ca5043b..29802ec6f1 100644
--- a/src/runtime/vulkan/vulkan_wrapped_func.cc
+++ b/src/runtime/vulkan/vulkan_wrapped_func.cc
@@ -205,7 +205,7 @@ VulkanModuleNode::~VulkanModuleNode() {
}
}
-PackedFunc VulkanModuleNode::GetFunction(const std::string& name,
+PackedFunc VulkanModuleNode::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
ICHECK_EQ(sptr_to_self.get(), this);
ICHECK_NE(name, symbol::tvm_module_main) << "Device function do not have
main";
@@ -404,7 +404,7 @@ std::shared_ptr<VulkanPipeline>
VulkanModuleNode::GetPipeline(size_t device_id,
return pe;
}
-void VulkanModuleNode::SaveToFile(const std::string& file_name, const
std::string& format) {
+void VulkanModuleNode::SaveToFile(const String& file_name, const String&
format) {
std::string fmt = GetFileFormat(file_name, format);
ICHECK_EQ(fmt, fmt_) << "Can only save to customized format vulkan";
std::string meta_file = GetMetaFilePath(file_name);
@@ -424,7 +424,7 @@ void VulkanModuleNode::SaveToBinary(dmlc::Stream* stream) {
stream->Write(smap_);
}
-std::string VulkanModuleNode::GetSource(const std::string& format) {
+String VulkanModuleNode::GetSource(const String& format) {
// can only return disassembly code.
return source_;
}
diff --git a/src/runtime/vulkan/vulkan_wrapped_func.h
b/src/runtime/vulkan/vulkan_wrapped_func.h
index 285edcd353..a983b3e702 100644
--- a/src/runtime/vulkan/vulkan_wrapped_func.h
+++ b/src/runtime/vulkan/vulkan_wrapped_func.h
@@ -94,15 +94,15 @@ class VulkanModuleNode final : public runtime::ModuleNode {
return ModulePropertyMask::kBinarySerializable |
ModulePropertyMask::kRunnable;
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
std::shared_ptr<VulkanPipeline> GetPipeline(size_t device_id, const
std::string& func_name,
size_t num_pack_args);
- void SaveToFile(const std::string& file_name, const std::string& format)
final;
+ void SaveToFile(const String& file_name, const String& format) final;
void SaveToBinary(dmlc::Stream* stream) final;
- std::string GetSource(const std::string& format) final;
+ String GetSource(const String& format) final;
private:
// function information table.
diff --git a/src/support/ffi_testing.cc b/src/support/ffi_testing.cc
index 56e3eba0b5..6e7dec4cb7 100644
--- a/src/support/ffi_testing.cc
+++ b/src/support/ffi_testing.cc
@@ -126,7 +126,7 @@ class FrontendTestModuleNode : public runtime::ModuleNode {
static constexpr const char* kAddFunctionName = "__add_function";
- virtual PackedFunc GetFunction(const std::string& name, const
ObjectPtr<Object>& sptr_to_self);
+ virtual PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self);
private:
std::unordered_map<std::string, PackedFunc> functions_;
@@ -134,7 +134,7 @@ class FrontendTestModuleNode : public runtime::ModuleNode {
constexpr const char* FrontendTestModuleNode::kAddFunctionName;
-PackedFunc FrontendTestModuleNode::GetFunction(const std::string& name,
+PackedFunc FrontendTestModuleNode::GetFunction(const String& name,
const ObjectPtr<Object>&
sptr_to_self) {
if (name == kAddFunctionName) {
return TypedPackedFunc<void(std::string, PackedFunc)>(
diff --git a/src/target/llvm/llvm_module.cc b/src/target/llvm/llvm_module.cc
index a2b0803714..4bb36ad284 100644
--- a/src/target/llvm/llvm_module.cc
+++ b/src/target/llvm/llvm_module.cc
@@ -90,7 +90,7 @@ class LLVMModuleNode final : public runtime::ModuleNode {
const char* type_key() const final { return "llvm"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final;
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final;
/*! \brief Get the property of the runtime module .*/
// TODO(tvm-team): Make it serializable
@@ -98,9 +98,9 @@ class LLVMModuleNode final : public runtime::ModuleNode {
return runtime::ModulePropertyMask::kRunnable |
runtime::ModulePropertyMask::kDSOExportable;
}
- void SaveToFile(const std::string& file_name, const std::string& format)
final;
+ void SaveToFile(const String& file_name, const String& format) final;
void SaveToBinary(dmlc::Stream* stream) final;
- std::string GetSource(const std::string& format) final;
+ String GetSource(const String& format) final;
void Init(const IRModule& mod, const Target& target);
void Init(std::unique_ptr<llvm::Module> module,
std::unique_ptr<LLVMInstance> llvm_instance);
@@ -137,8 +137,7 @@ LLVMModuleNode::~LLVMModuleNode() {
module_owning_ptr_.reset();
}
-PackedFunc LLVMModuleNode::GetFunction(const std::string& name,
- const ObjectPtr<Object>& sptr_to_self) {
+PackedFunc LLVMModuleNode::GetFunction(const String& name, const
ObjectPtr<Object>& sptr_to_self) {
if (name == "__tvm_is_system_module") {
bool flag = (module_->getFunction("__tvm_module_startup") != nullptr);
return PackedFunc([flag](TVMArgs args, TVMRetValue* rv) { *rv = flag; });
@@ -181,7 +180,8 @@ PackedFunc LLVMModuleNode::GetFunction(const std::string&
name,
return WrapPackedFunc(faddr, sptr_to_self);
}
-void LLVMModuleNode::SaveToFile(const std::string& file_name, const
std::string& format) {
+void LLVMModuleNode::SaveToFile(const String& file_name_str, const String&
format) {
+ std::string file_name = file_name_str;
std::string fmt = runtime::GetFileFormat(file_name, format);
std::error_code ecode;
#if TVM_LLVM_VERSION <= 70
@@ -250,7 +250,7 @@ void LLVMModuleNode::SaveToBinary(dmlc::Stream* stream) {
LOG(FATAL) << "LLVMModule: SaveToBinary not supported";
}
-std::string LLVMModuleNode::GetSource(const std::string& format) {
+String LLVMModuleNode::GetSource(const String& format) {
std::string fmt = runtime::GetFileFormat("", format);
std::string type_str;
llvm::SmallString<256> str;
diff --git a/src/target/source/codegen_webgpu.cc
b/src/target/source/codegen_webgpu.cc
index fd770007e2..4d1d834c7f 100644
--- a/src/target/source/codegen_webgpu.cc
+++ b/src/target/source/codegen_webgpu.cc
@@ -492,21 +492,17 @@ class WebGPUSourceModuleNode final : public
runtime::ModuleNode {
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const final { return
runtime::ModulePropertyMask::kBinarySerializable; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
LOG(FATAL) << "WebGPUSourceModule is not directly runnable, export and run
through tvmjs";
return PackedFunc(nullptr);
}
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
- LOG(FATAL) << "Not implemented";
- }
-
void SaveToBinary(dmlc::Stream* stream) final {
stream->Write(fmap_);
stream->Write(smap_);
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
std::ostringstream os;
for (auto kv : smap_) {
os << kv.second;
diff --git a/src/target/source/interface_c.cc b/src/target/source/interface_c.cc
index d2d1d3f78d..8529b8b130 100644
--- a/src/target/source/interface_c.cc
+++ b/src/target/source/interface_c.cc
@@ -60,7 +60,7 @@ class InterfaceCNode : public runtime::ModuleNode {
output_sizes_(output_sizes) {}
const char* type_key() const final { return "h"; }
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
std::stringstream code;
EmitUpperHeaderGuard(code);
@@ -128,7 +128,7 @@ class InterfaceCNode : public runtime::ModuleNode {
return code.str();
}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
return PackedFunc();
}
diff --git a/src/target/source/source_module.cc
b/src/target/source/source_module.cc
index 84d0ca9a86..be5179e081 100644
--- a/src/target/source/source_module.cc
+++ b/src/target/source/source_module.cc
@@ -68,15 +68,15 @@ class SourceModuleNode : public runtime::ModuleNode {
SourceModuleNode(std::string code, std::string fmt) : code_(code), fmt_(fmt)
{}
const char* type_key() const final { return "source"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
LOG(FATAL) << "Source module cannot execute, to get executable module"
<< " build TVM with \'" << fmt_ << "\' runtime support";
return PackedFunc();
}
- std::string GetSource(const std::string& format) final { return code_; }
+ String GetSource(const String& format) final { return code_; }
- std::string GetFormat() override { return fmt_; }
+ String GetFormat() override { return fmt_; }
protected:
std::string code_;
@@ -96,7 +96,7 @@ class CSourceModuleNode : public runtime::ModuleNode {
: code_(code), fmt_(fmt), const_vars_(const_vars),
func_names_(func_names) {}
const char* type_key() const final { return "c"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
// Currently c-source module is used as demonstration purposes with binary
metadata module
// that expects get_symbol interface. When c-source module is used as
external module, it
// will only contain one function. However, when its used as an internal
module (e.g., target
@@ -115,11 +115,11 @@ class CSourceModuleNode : public runtime::ModuleNode {
}
}
- std::string GetSource(const std::string& format) final { return code_; }
+ String GetSource(const String& format) final { return code_; }
- std::string GetFormat() override { return fmt_; }
+ String GetFormat() override { return fmt_; }
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string fmt = GetFileFormat(file_name, format);
std::string meta_file = GetMetaFilePath(file_name);
if (fmt == "c" || fmt == "cc" || fmt == "cpp" || fmt == "cu") {
@@ -181,14 +181,14 @@ class CSourceCrtMetadataModuleNode : public
runtime::ModuleNode {
}
const char* type_key() const final { return "c"; }
- std::string GetSource(const std::string& format) final { return code_.str();
}
+ String GetSource(const String& format) final { return code_.str(); }
- std::string GetFormat() override { return fmt_; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ String GetFormat() override { return fmt_; }
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
return PackedFunc();
}
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string fmt = GetFileFormat(file_name, format);
std::string meta_file = GetMetaFilePath(file_name);
if (fmt == "c" || fmt == "cc" || fmt == "cpp") {
@@ -994,13 +994,13 @@ class DeviceSourceModuleNode final : public
runtime::ModuleNode {
std::function<std::string(const std::string&)>
fget_source)
: data_(data), fmt_(fmt), fmap_(fmap), type_key_(type_key),
fget_source_(fget_source) {}
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
LOG(FATAL) << "Source module cannot execute, to get executable module"
<< " build TVM with \'" << fmt_ << "\' runtime support";
return PackedFunc();
}
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
if (fget_source_ != nullptr) {
return fget_source_(format);
} else {
@@ -1012,7 +1012,7 @@ class DeviceSourceModuleNode final : public
runtime::ModuleNode {
/*! \brief Get the property of the runtime module .*/
int GetPropertyMask() const final { return
runtime::ModulePropertyMask::kBinarySerializable; }
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
std::string fmt = GetFileFormat(file_name, format);
ICHECK_EQ(fmt, fmt_) << "Can only save to format=" << fmt_;
std::string meta_file = GetMetaFilePath(file_name);
diff --git a/tests/scripts/task_config_build_cpu.sh
b/tests/scripts/task_config_build_cpu.sh
index 899c27d673..9eda0d74d4 100755
--- a/tests/scripts/task_config_build_cpu.sh
+++ b/tests/scripts/task_config_build_cpu.sh
@@ -35,8 +35,6 @@ echo set\(NNPACK_PATH /NNPACK/build/\) >> config.cmake
echo set\(USE_ANTLR ON\) >> config.cmake
echo set\(CMAKE_CXX_FLAGS \"-Werror -Wno-error=range-loop-construct\"\) >>
config.cmake
echo set\(HIDE_PRIVATE_SYMBOLS ON\) >> config.cmake
-echo set\(USE_VTA_TSIM ON\) >> config.cmake
-echo set\(USE_VTA_FSIM ON\) >> config.cmake
# This conditional is just to support the transition to cope
# with the change in the way TFLite is built. It can be
@@ -53,7 +51,6 @@ echo set\(USE_ETHOSN /opt/arm/ethosn-driver\) >> config.cmake
echo set\(USE_ETHOSN_HW OFF\) >> config.cmake
echo set\(USE_CMSISNN OFF\) >> config.cmake
echo set\(USE_VITIS_AI ON\) >> config.cmake
-echo set\(USE_VERILATOR ON\) >> config.cmake
echo set\(USE_LIBBACKTRACE COMPILE\) >> config.cmake
echo set\(BACKTRACE_ON_SEGFAULT ON\) >> config.cmake
echo set\(USE_CCACHE OFF\) >> config.cmake
diff --git a/tests/scripts/task_config_build_i386.sh
b/tests/scripts/task_config_build_i386.sh
index 1c210ab072..9d05d102ae 100755
--- a/tests/scripts/task_config_build_i386.sh
+++ b/tests/scripts/task_config_build_i386.sh
@@ -30,9 +30,6 @@ echo set\(USE_MICRO_STANDALONE_RUNTIME ON\) >> config.cmake
echo set\(USE_PROFILER ON\) >> config.cmake
echo set\(USE_LLVM llvm-config-10\) >> config.cmake
echo set\(CMAKE_CXX_FLAGS -Werror\) >> config.cmake
-echo set\(USE_VTA_FSIM ON\) >> config.cmake
-echo set\(USE_VTA_TSIM ON\) >> config.cmake
-echo set\(USE_VERILATOR ON\) >> config.cmake
echo set\(USE_CCACHE OFF\) >> config.cmake
echo set\(BACKTRACE_ON_SEGFAULT ON\) >> config.cmake
echo set\(USE_UMA OFF\) >> config.cmake
diff --git a/tests/scripts/task_python_vta_fsim.sh
b/tests/scripts/task_python_vta_fsim.sh
index cd96b278d8..14004361ee 100755
--- a/tests/scripts/task_python_vta_fsim.sh
+++ b/tests/scripts/task_python_vta_fsim.sh
@@ -26,6 +26,9 @@ export OMP_NUM_THREADS=1
export PYTHONPATH=${PYTHONPATH}:${TVM_PATH}/vta/python
export VTA_HW_PATH=`pwd`/3rdparty/vta-hw
+# disable fsim test for now
+exit 0
+
# cleanup pycache
find . -type f -path "*.pyc" | xargs rm -f
diff --git a/web/emcc/webgpu_runtime.cc b/web/emcc/webgpu_runtime.cc
index 17efcc8c70..a4facc8f77 100644
--- a/web/emcc/webgpu_runtime.cc
+++ b/web/emcc/webgpu_runtime.cc
@@ -159,7 +159,7 @@ class WebGPUModuleNode final : public runtime::ModuleNode {
const char* type_key() const final { return "webgpu"; }
- PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>&
sptr_to_self) final {
+ PackedFunc GetFunction(const String& name, const ObjectPtr<Object>&
sptr_to_self) final {
auto it = smap_.find(name);
if (it != smap_.end()) {
FunctionInfo info = fmap_.at(name);
@@ -173,13 +173,13 @@ class WebGPUModuleNode final : public runtime::ModuleNode
{
}
}
- void SaveToFile(const std::string& file_name, const std::string& format)
final {
+ void SaveToFile(const String& file_name, const String& format) final {
LOG(FATAL) << "Not implemented";
}
void SaveToBinary(dmlc::Stream* stream) final { LOG(FATAL) << "Not
implemented"; }
- std::string GetSource(const std::string& format) final {
+ String GetSource(const String& format) final {
// can only return source code.
return source_;
}