Browse Source

GE supports aicore DEPEND_SHAPE_RANGE op update outputs shape

pull/2008/head
zhujingjing 3 years ago
parent
commit
456f4c7d9f
1 changed files with 91 additions and 0 deletions
  1. +91
    -0
      tests/ut/ge/hybrid/node_executor/aicore/aicore_op_task_unittest.cc

+ 91
- 0
tests/ut/ge/hybrid/node_executor/aicore/aicore_op_task_unittest.cc View File

@@ -0,0 +1,91 @@
/**
* 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 <gmock/gmock.h>
#include <gtest/gtest.h>

#include <vector>

#define private public
#define protected public
#include "framework/common/taskdown_common.h"
#include "hybrid/node_executor/aicore/aicore_op_task.h"
#include "init/gelib.h"
#undef private
#undef protected

using namespace std;
using namespace testing;

namespace ge {
using namespace hybrid;

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

static ge::OpDescPtr CreateOpDesc(string name = "", string type = "",
int in_num = 0, int out_num = 0) {
auto op_desc = std::make_shared<ge::OpDesc>(name, type);
op_desc->SetStreamId(0);
static int32_t index = 0;
op_desc->SetId(index++);

GeTensorDesc tensor(GeShape(), FORMAT_ND, DT_INT64);
TensorUtils::SetSize(tensor, 64);
vector<int64_t> input_offset;
for (int i = 0; i < in_num; ++i) {
op_desc->AddInputDesc(tensor);
input_offset.emplace_back(index * 64 + i * 64);
}
op_desc->SetInputOffset(input_offset);

vector<int64_t> output_offset;
for (int i = 0; i < out_num; ++i) {
op_desc->AddOutputDesc(tensor);
output_offset.emplace_back(index * 64 + in_num * 64 + i * 64);
}
op_desc->SetOutputOffset(output_offset);

op_desc->SetWorkspace({});
op_desc->SetWorkspaceBytes({});

ge::AttrUtils::SetStr(op_desc, ge::TVM_ATTR_NAME_MAGIC,
"RT_DEV_BINARY_MAGIC_ELF_AIVEC");
bool support_dynamic = true;
ge::AttrUtils::GetBool(op_desc, "support_dynamicshape", support_dynamic);
return op_desc;
}

TEST_F(UtestAiCoreOpTask, Init_failed) {
dlog_setlevel(0, 0, 0);
std::unique_ptr<AiCoreOpTask> task1(new AiCoreOpTask());
OpDescPtr op_desc = CreateOpDesc("Add", "Add");
ge::AttrUtils::SetInt(*op_desc, ge::ATTR_NAME_UNKNOWN_SHAPE_TYPE,
DEPEND_SHAPE_RANGE);
domi::TaskDef task_def;
task_def.set_type(RT_MODEL_TASK_KERNEL);
std::vector<uint8_t> args(10, 0);
task_def.mutable_kernel()->set_args(args.data(), args.size());
task_def.mutable_kernel()->set_args_size(10);
task_def.mutable_kernel()->mutable_context()->set_kernel_type(
ccKernelType::TE);
EXPECT_EQ(task1->Init(*op_desc, task_def), ge::PARAM_INVALID);
dlog_setlevel(0, 3, 0);
}
} // namespace ge

Loading…
Cancel
Save