提交 e2b20c20 编写于 作者: L liuqi

Move create tensor to mace engine init.

上级 e387e093
...@@ -534,7 +534,9 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type) : ...@@ -534,7 +534,9 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type) :
ws_->CreateTensor("mace_input_node:0", ws_->CreateTensor("mace_input_node:0",
GetDeviceAllocator(device_type_), GetDeviceAllocator(device_type_),
DT_FLOAT); DT_FLOAT);
ws_->CreateTensor("mace_output_node:0",
GetDeviceAllocator(device_type_),
DT_FLOAT);
net_ = std::move(CreateNet(op_registry_, *net_def, ws_.get(), device_type)); net_ = std::move(CreateNet(op_registry_, *net_def, ws_.get(), device_type));
} }
} }
...@@ -551,9 +553,7 @@ bool MaceEngine::Run(const float *input, ...@@ -551,9 +553,7 @@ bool MaceEngine::Run(const float *input,
float *output) { float *output) {
MACE_CHECK(output != nullptr, "output ptr cannot be NULL"); MACE_CHECK(output != nullptr, "output ptr cannot be NULL");
Tensor *input_tensor = ws_->GetTensor("mace_input_node:0"); Tensor *input_tensor = ws_->GetTensor("mace_input_node:0");
Tensor *output_tensor = ws_->CreateTensor("mace_output_node:0", Tensor *output_tensor = ws_->GetTensor("mace_output_node:0");
GetDeviceAllocator(device_type_),
DT_FLOAT);
input_tensor->Resize(input_shape); input_tensor->Resize(input_shape);
{ {
Tensor::MappingGuard input_guard(input_tensor); Tensor::MappingGuard input_guard(input_tensor);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册