Commit ce346218 authored by liucong's avatar liucong
Browse files

修改input/output代码

parent fb1c8860
...@@ -23,10 +23,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm ...@@ -23,10 +23,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm
net = migraphx::parse_onnx(modelPath); net = migraphx::parse_onnx(modelPath);
LOG_INFO(logFile,"succeed to load model: %s\n",GetFileName(modelPath).c_str()); LOG_INFO(logFile,"succeed to load model: %s\n",GetFileName(modelPath).c_str());
// 获取模型输入属性 // 获取模型输入/输出节点信息
std::pair<std::string, migraphx::shape> inputAttribute=net.get_parameter_shapes(); std::cout<<"inputs:"<<std::endl;
inputName=inputAttribute.first; std::unordered_map<std::string, migraphx::shape> inputs=net.get_inputs();
inputShape=inputAttribute.second; for(auto i:inputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
std::cout<<"outputs:"<<std::endl;
std::unordered_map<std::string, migraphx::shape> outputs=net.get_outputs();
for(auto i:outputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
inputName=inputs.first;
inputShape=inputs.second;
int N=inputShape.lens()[0]; int N=inputShape.lens()[0];
int C=inputShape.lens()[1]; int C=inputShape.lens()[1];
int H=inputShape.lens()[2]; int H=inputShape.lens()[2];
......
...@@ -26,8 +26,20 @@ if __name__ == '__main__': ...@@ -26,8 +26,20 @@ if __name__ == '__main__':
# 加载模型 # 加载模型
model = migraphx.parse_onnx("../Resource/Models/unet_13_256.onnx") model = migraphx.parse_onnx("../Resource/Models/unet_13_256.onnx")
# 获取模型输入/输出节点信息
print("inputs:")
inputs = model.get_inputs()
for key,value in inputs.items():
print("{}:{}".format(key,value))
print("outputs:")
outputs = model.get_outputs()
for key,value in outputs.items():
print("{}:{}".format(key,value))
inputName = model.get_parameter_names() inputName = model.get_parameter_names()
inputShape = model.get_parameter_shapes() inputShape = inputs[inputName].lens()
print("inputName:{0} \ninputShape:{1}".format(inputName, inputShape)) print("inputName:{0} \ninputShape:{1}".format(inputName, inputShape))
# 编译模型 # 编译模型
......
...@@ -53,10 +53,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm ...@@ -53,10 +53,21 @@ ErrorCode Unet::Initialize(InitializationParameterOfSegmentation initParamOfSegm
net = migraphx::parse_onnx(modelPath); net = migraphx::parse_onnx(modelPath);
LOG_INFO(stdout,"succeed to load model: %s\n",GetFileName(modelPath).c_str()); LOG_INFO(stdout,"succeed to load model: %s\n",GetFileName(modelPath).c_str());
// 获取模型输入属性 // 获取模型输入/输出节点信息
std::unordered_map<std::string, migraphx::shape> inputMap=net.get_parameter_shapes(); std::cout<<"inputs:"<<std::endl;
inputName=inputMap.begin()->first; std::unordered_map<std::string, migraphx::shape> inputs=net.get_inputs();
inputShape=inputMap.begin()->second; for(auto i:inputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
std::cout<<"outputs:"<<std::endl;
std::unordered_map<std::string, migraphx::shape> outputs=net.get_outputs();
for(auto i:outputs)
{
std::cout<<i.first<<":"<<i.second<<std::endl;
}
inputName=inputs.begin()->first;
inputShape=inputs.begin()->second;
int N=inputShape.lens()[0]; int N=inputShape.lens()[0];
int C=inputShape.lens()[1]; int C=inputShape.lens()[1];
int H=inputShape.lens()[2]; int H=inputShape.lens()[2];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment