From 49c0e45278054fd776cd3c7c0c3d88a6e6d34d06 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dmitry=20Mozolev/AI=20Tools=20Lab=20/SRR/Engineer/=EC=82=BC?= =?utf8?q?=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 7 Aug 2018 10:34:25 +0300 Subject: [PATCH] [nnc] Remove unnecessary heap allocs in interpreter test (#916) Changed unnecessary heap allocation for Interpreter and ShapeInference objects to stack allocations. Signed-off-by: Dmitry Mozolev --- .../nnc/libs/backend/interpreter/test/src/graph_creator.cpp | 5 ++--- contrib/nnc/libs/backend/interpreter/test/src/op_test.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/contrib/nnc/libs/backend/interpreter/test/src/graph_creator.cpp b/contrib/nnc/libs/backend/interpreter/test/src/graph_creator.cpp index 746b3f5..9d81ca3 100644 --- a/contrib/nnc/libs/backend/interpreter/test/src/graph_creator.cpp +++ b/contrib/nnc/libs/backend/interpreter/test/src/graph_creator.cpp @@ -135,9 +135,8 @@ std::unique_ptr make_graph(const opinfo::OperatorInfo* opInfo) g->markOutput(opNode); // Run shape inference - auto shapeInferencer = new ShapeInference(); - g->accept(shapeInferencer); - delete shapeInferencer; + ShapeInference shapeInferencer; + g->accept(&shapeInferencer); return g; } diff --git a/contrib/nnc/libs/backend/interpreter/test/src/op_test.cpp b/contrib/nnc/libs/backend/interpreter/test/src/op_test.cpp index 6ffe62a..dd69e68 100644 --- a/contrib/nnc/libs/backend/interpreter/test/src/op_test.cpp +++ b/contrib/nnc/libs/backend/interpreter/test/src/op_test.cpp @@ -24,21 +24,19 @@ TEST_P(InterpTestFixture, InterpTest) const OperatorInfo* opInfo = GetParam(); std::unique_ptr g = make_graph(opInfo); - auto interpreter = new core::NNInterpreter(); + core::NNInterpreter interpreter; for (unsigned int i = 0; i < opInfo->inputs()->size(); ++i) { - interpreter->setInput("x" + std::to_string(i), *getTensor(opInfo->inputs()->Get(i))); + interpreter.setInput("x" + std::to_string(i), *getTensor(opInfo->inputs()->Get(i))); } - g->accept(interpreter); + g->accept(&interpreter); // TODO: Get and check equality for multiple outputs and results. - auto res = interpreter->getResult(g->getOutput("y"))[0]; + auto res = interpreter.getResult(g->getOutput("y"))[0]; assertTensorEq(res, *getTensor(opInfo->results()->Get(0))); - - delete interpreter; } INSTANTIATE_TEST_CASE_P(InterpTestSuite, InterpTestFixture, -- 2.7.4