You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by mallappa s via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/08/16 06:12:47 UTC
[Apache TVM Discuss] [Application] 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");
---
[Visit Topic](https://discuss.tvm.apache.org/t/irrespective-of-input-same-output-ios-tvm-model/10765/3) to respond.
You are receiving this because you enabled mailing list mode.
To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/8159a5666f6746363d7df571b242d93033ce1c185c147e6cde950272d030d7a7).