Browse Source

support fwk offline inference when ge_lib is not initialized

pull/1636/head
lichun 4 years ago
parent
commit
ac62f5d2ce
2 changed files with 56 additions and 0 deletions
  1. +1
    -0
      tests/ut/ge/CMakeLists.txt
  2. +55
    -0
      tests/ut/ge/hybrid/node_executor/aicore/aicore_task_compiler_unittest.cc

+ 1
- 0
tests/ut/ge/CMakeLists.txt View File

@@ -828,6 +828,7 @@ set(HYBRID_TEST_FILES
"hybrid/executor/worker/execution_engine_unittest.cc"
"hybrid/model/hybrid_model_builder_unittest.cc"
"hybrid/node_executor/rts/rts_node_task_unittest.cc"
"hybrid/node_executor/aicore/aicore_task_compiler_unittest.cc"
)

set(OTHERS_TEST_FILES


+ 55
- 0
tests/ut/ge/hybrid/node_executor/aicore/aicore_task_compiler_unittest.cc View File

@@ -0,0 +1,55 @@
/**
* Copyright 2021-2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <vector>

#define private public
#define protected public
#include "init/gelib.h"
#include "hybrid/node_executor/aicore/aicore_task_compiler.h"

using namespace std;
using namespace testing;

namespace ge {
using namespace hybrid;

class UtestAiCoreTaskCompiler : public testing::Test {
protected:
void SetUp() {}
void TearDown() { }
};

TEST_F(UtestAiCoreTaskCompiler, test_aicore_task_compiler_init) {
AicoreTaskCompiler aicore_task_compiler;
NodePtr node = nullptr;
std::vector<domi::TaskDef> tasks{};
ASSERT_EQ(aicore_task_compiler.Initialize(), FAILED); // cause: ge lib is nullptr
ASSERT_EQ(aicore_task_compiler.CompileOp(node, tasks), FAILED); // cause: aicore task compiler init failed.

std::shared_ptr<GELib> ge_lib_ptr = MakeShared<GELib>();
ge_lib_ptr->init_flag_ = true;
OpsKernelManager OpsKernelManagerObj;
OpsKernelInfoStorePtr ops_kernel_info_store = MakeShared<OpsKernelInfoStore>(new OpsKernelInfoStore());
OpsKernelManagerObj.ops_kernel_store_.insert("AIcoreEngine", ops_kernel_info_store);
ASSERT_EQ(aicore_task_compiler.CompileOp(node, tasks), FAILED); // cause: node is nullptr
ASSERT_EQ(aicore_task_compiler.is_initialized_, true); // though CompileOp failed since node is nullptr,
// but aicore_task_compiler init success.
}
} // namespace ge


Loading…
Cancel
Save