Irrespective of input same output iOS TVM model

Hi @elvin-n i have built a standalone iOS application

For iOS CPU.

  • sdk = “iphoneos”
  • target = “llvm -mtriple=arm64-apple-darwin”

For iOS Metal:

  • sdk = “iphoneos”
  • target = “metal”
  • target_host = “llvm -mtriple=arm64-apple-darwin”

And i used c++ to inference the TVM model

// load module tvm::runtime::Module mod_syslib = tvm::runtime::Module::LoadFromFile(std_resourcePath);

//load graph
std::ifstream json_in(std_jsonPath);
std::string json_data((std::istreambuf_iterator<char>(json_in)), std::istreambuf_iterator<char>());
json_in.close();

// get global function module for graph runtime
auto tvm_graph_runtime_create = tvm::runtime::Registry::Get("tvm.graph_executor.create");
tvm::runtime::Module mod = (*tvm_graph_runtime_create)(json_data, mod_syslib, device_type, device_id);
this->m_handle = new tvm::runtime::Module(mod);

//parameters needs to be TVMByteArray typr to indecate the binary data
std::ifstream params_in(std_paramPath, std::ios::binary);
std::string params_data((std::istreambuf_iterator<char>(params_in)), std::istreambuf_iterator<char>());
params_in.close();
TVMByteArray params;
params.data = params_data.c_str();
params.size = params_data.length();
mod.GetFunction("load_params")(params);

tvm::runtime::PackedFunc set_input = mod->GetFunction("set_input");
set_input("input", m_gpuInput);

tvm::runtime::PackedFunc run = mod->GetFunction("run");
run();
tvm::runtime::PackedFunc get_output = mod->GetFunction("get_output");