Hello everyone!
I have successfully built metal model for iOS and I have verified that it’s working correctly so I have focused on tuning it.
Thanks to the help of magnificent @apeskov, I was able to produce a fully tuned iOS model. As I can see from the logs, 14 hours of tuning gave a very promising results and I’m eager to see this in my iOS app.
But, when I try to deploy and run the model in my app, I get a crash on “run” function. Here’s where I store run function:
Device dev {kDLMetal, 0};
m_mod = tvm::runtime::Module::LoadFromFile([k_ModelName UTF8String]);
Module def = m_mod.GetFunction("default")(dev);
m_inputFunc = def.GetFunction("set_input");
m_runFunc = def.GetFunction("run");
m_outputFunc = def.GetFunction("get_output");
Here’s where I use it:
m_inputFunc("input", m_input);
m_runFunc(); //that's where the code crashes
m_outputFunc(1, m_output);
By the way, both input and output functions are working (or at least they don’t crash the application). Also I have experienced such an issue before by using untuned model, but it got fixed after rebuilding. I have no idea what I did wrong back then, but in that case rebuilding the model with tuned config over and over again doesn’t fix an issue
Any advise would be appreciated! Thank you!
IMPORTANT NOTE: The initial version of the config (log_file) that auto_scheduler
has created can not be used in ApplyHistoryBest
and it gives fatal error, that "input" is invalid key
. After a quick look I have found out that my config starts with this chunk of data:
{"input": ["llvm -keys=cpu -link-params=0 -mtriple=arm64-apple-darwin", "conv2d_NCHWc.x86", [["TENSOR", [1, 209, 64, 64], "float32"], ["TENSOR", [256, 209, 1, 1], "float32"], [1, 1], [0, 0, 0, 0], [1, 1], "NCHW", "NCHW", "float32"], {}], "config": {"index": 166, "code_hash": null, "entity": [["tile_ic", "sp", [-1, 19]], ["tile_oc", "sp", [-1, 32]], ["tile_ow", "sp", [-1, 4]], ["tile_oh", "ot", 1]]}, "result": [[0.00832551045], 0, 2.187854290008545, 1622414478.4734201], "version": 0.2, "tvm_version": "0.8.dev0"}
{"input": ["llvm -keys=cpu -link-params=0 -mtriple=arm64-apple-darwin", "conv2d_NCHWc.x86", [["TENSOR", [1, 64, 4, 4], "float32"], ["TENSOR", [64, 64, 3, 3], "float32"], [1, 1], [1, 1, 1, 1], [1, 1], "NCHW", "NCHW", "float32"], {}], "config": {"index": 127, "code_hash": null, "entity": [["tile_ic", "sp", [-1, 2]], ["tile_oc", "sp", [-1, 16]], ["tile_ow", "sp", [-1, 4]], ["unroll_kw", "ot", true]]}, "result": [[4.183946308163834e-05], 0, 1.418644666671753, 1622419079.2600079], "version": 0.2, "tvm_version": "0.8.dev0"}
{"input": ["llvm -keys=cpu -link-params=0 -mtriple=arm64-apple-darwin", "conv2d_NCHWc.x86", [["TENSOR", [1, 128, 4, 4], "float32"], ["TENSOR", [64, 128, 3, 3], "float32"], [1, 1], [1, 1, 1, 1], [1, 1], "NCHW", "NCHW", "float32"], {}], "config": {"index": 312, "code_hash": null, "entity": [["tile_ic", "sp", [-1, 1]], ["tile_oc", "sp", [-1, 16]], ["tile_ow", "sp", [-1, 4]], ["unroll_kw", "ot", false]]}, "result": [[7.26768600301659e-05], 0, 1.803436040878296, 1622421260.50744], "version": 0.2, "tvm_version": "0.8.dev0"}
{"input": ["llvm -keys=cpu -link-params=0 -mtriple=arm64-apple-darwin", "conv2d_NCHWc.x86", [["TENSOR", [1, 256, 4, 4], "float32"], ["TENSOR", [128, 256, 3, 3], "float32"], [1, 1], [1, 1, 1, 1], [1, 1], "NCHW", "NCHW", "float32"], {}], "config": {"index": 396, "code_hash": null, "entity": [["tile_ic", "sp", [-1, 1]], ["tile_oc", "sp", [-1, 16]], ["tile_ow", "sp", [-1, 4]], ["unroll_kw", "ot", false]]}, "result": [[0.0002428782051282051], 0, 1.4385228157043457, 1622422703.4950469], "version": 0.2, "tvm_version": "0.8.dev0"}
...........
I didn’t find any attachment to the input
key in config reading algorithms so I have deleted it. That helped me to overcome a crash from ApplyHistoryBest
and build the model. But now I’m wondering - could I erase some important info from the log_file
and because of that I have a current issue?