From e2b20c20a132f6e402fd310bf1d31b433c8c4746 Mon Sep 17 00:00:00 2001 From: liuqi Date: Sun, 7 Jan 2018 11:57:00 +0800 Subject: [PATCH] Move create tensor to mace engine init. --- mace/core/mace.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mace/core/mace.cc b/mace/core/mace.cc index 2361a435..770a8067 100644 --- a/mace/core/mace.cc +++ b/mace/core/mace.cc @@ -534,7 +534,9 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type) : ws_->CreateTensor("mace_input_node:0", GetDeviceAllocator(device_type_), 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)); } } @@ -551,9 +553,7 @@ bool MaceEngine::Run(const float *input, float *output) { MACE_CHECK(output != nullptr, "output ptr cannot be NULL"); Tensor *input_tensor = ws_->GetTensor("mace_input_node:0"); - Tensor *output_tensor = ws_->CreateTensor("mace_output_node:0", - GetDeviceAllocator(device_type_), - DT_FLOAT); + Tensor *output_tensor = ws_->GetTensor("mace_output_node:0"); input_tensor->Resize(input_shape); { Tensor::MappingGuard input_guard(input_tensor); -- GitLab