未验证 提交 d49bd42c 编写于 作者: Z zhupengyang 提交者: GitHub

[NPU] refine subgraph name (#3624)

上级 337c2061
......@@ -25,6 +25,7 @@ DEFINE_string(optimized_model_dir, "", "path of optimized naive buffer model");
DEFINE_string(input_tensor_shape, "1,3,224,224", "shape of input tensors");
DEFINE_string(input_tensor_type, "float32", "data type of input tensors");
DEFINE_string(output_tensor_type, "float32", "data type of output tensors");
DEFINE_string(subgraph_model_cache_dir, "", "dir of subgraph model cache");
namespace paddle {
namespace lite {
......@@ -132,7 +133,7 @@ std::shared_ptr<lite_api::PaddlePredictor> TestModel(
mobile_config.set_model_from_file(optimized_model_dir + ".nb");
mobile_config.set_power_mode(lite_api::PowerMode::LITE_POWER_HIGH);
mobile_config.set_threads(1);
// mobile_config.set_subgraph_model_cache_dir("/data/local/tmp");
mobile_config.set_subgraph_model_cache_dir(FLAGS_subgraph_model_cache_dir);
predictor = lite_api::CreatePaddlePredictor(mobile_config);
FillInputTensors(predictor, input_tensor_shape, input_tensor_type, 1);
// Run optimized model
......
......@@ -34,24 +34,16 @@ std::string SubgraphEngine::GenerateModelCacheName() const {
auto inames = device_inames_;
auto onames = device_onames_;
std::sort(inames.begin(), inames.end());
std::sort(onames.begin(), onames.end());
std::string model_cache_name = "";
std::string model_cache_name = "subgraph_" + std::to_string(block_idx_);
for (auto iname : inames) {
model_cache_name += "_";
auto itensor = scope_->FindTensor(iname);
std::replace(iname.begin(), iname.end(), '/', '_');
model_cache_name += "_" + iname;
int tmp = 0;
for (auto i : itensor->dims().Vectorize()) {
model_cache_name += "_" + std::to_string(i);
}
}
for (auto oname : onames) {
auto otensor = scope_->FindTensor(oname);
std::replace(oname.begin(), oname.end(), '/', '_');
model_cache_name += "_" + oname;
for (auto i : otensor->dims().Vectorize()) {
model_cache_name += "_" + std::to_string(i);
tmp += i * i;
}
model_cache_name += std::to_string(tmp % 1999);
}
model_cache_name += "_.om";
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册