Browse Source

test

pull/1363/head
gengchao4@huawei.com 3 years ago
parent
commit
44611324f3
4 changed files with 34 additions and 14 deletions
  1. +3
    -3
      scripts/env/ge_env.sh
  2. +2
    -0
      tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_box.h
  3. +5
    -0
      tests/framework/ge_graph_dsl/src/op_desc/op_desc_cfg_box.cc
  4. +24
    -11
      tests/st/testcase/test_model_deploy_schedule.cc

+ 3
- 3
scripts/env/ge_env.sh View File

@@ -20,8 +20,8 @@ PROJECT_HOME=${PROJECT_HOME:-$(dirname "$0")/../../}
MOUNT_PROJECT_HOME=$(cd $PROJECT_HOME || return; pwd)

DOCKER_BUILD_ENV_NAME=${MOUNT_PROJECT_HOME#*/}
DOCKER_BUILD_ENV_NAME=${DOCKER_BUILD_ENV_NAME//\//\_}
DOCKER_IMAGE_TAG=ge_build_env.1.0.6
DOCKER_BUILD_ENV_NAME=SSH_${DOCKER_BUILD_ENV_NAME//\//\_}
DOCKER_IMAGE_TAG=ge_build_env.1.0.9
DOCKER_IAMGE_NAME=joycode2art/turing
DOCKER_FULL_IMAGE_NAME=${DOCKER_IAMGE_NAME}:${DOCKER_IMAGE_TAG}

@@ -61,7 +61,7 @@ function enter_docker_env(){
if test -z "$(docker images |grep ${DOCKER_IAMGE_NAME} | grep ${DOCKER_IMAGE_TAG})"; then
echo "please run 'ge env --pull' to download images first!"
elif test -z "$(docker ps -a |grep ${DOCKER_BUILD_ENV_NAME})"; then
$docker_cmd run -it -v ${MOUNT_PROJECT_HOME}:/code/Turing/graphEngine --workdir ${docker_work_dir} --name ${DOCKER_BUILD_ENV_NAME} ${DOCKER_FULL_IMAGE_NAME} ${docker_bash_dir}
$docker_cmd run -p 7002:22 -p 7003:7007 --privileged=true --cap-add=SYS_PTRACE -it -v ${MOUNT_PROJECT_HOME}:/code/Turing/graphEngine --workdir ${docker_work_dir} --name ${DOCKER_BUILD_ENV_NAME} ${DOCKER_FULL_IMAGE_NAME} ${docker_bash_dir}
elif test -z "$(docker ps |grep ${DOCKER_BUILD_ENV_NAME})"; then
$docker_cmd start ${DOCKER_BUILD_ENV_NAME}
$docker_cmd exec -w ${docker_work_dir} -it ${DOCKER_BUILD_ENV_NAME} ${docker_bash_dir}


+ 2
- 0
tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_box.h View File

@@ -31,8 +31,10 @@ struct OpDescCfgBox : OpBox, private OpDescCfg {
OpDescCfgBox &InCnt(int in_cnt);
OpDescCfgBox &OutCnt(int out_cnt);
OpDescCfgBox &ParentNodeIndex(int node_index);
OpDescCfgBox &TensorDescShape(std::vector<int64_t> shape);
OpDescCfgBox &TensorDesc(Format format = FORMAT_NCHW, DataType data_type = DT_FLOAT,
std::vector<int64_t> shape = {1, 1, 224, 224});

OpDescCfgBox &Weight(GeTensorPtr &);

template <typename Type>


+ 5
- 0
tests/framework/ge_graph_dsl/src/op_desc/op_desc_cfg_box.cc View File

@@ -71,6 +71,11 @@ OpDescCfgBox &OpDescCfgBox::TensorDesc(Format format, DataType data_type, std::v
return *this;
}

OpDescCfgBox &OpDescCfgBox::TensorDescShape(std::vector<int64_t> shape) {
default_tensor_.shape_ = shape;
return *this;
}

void OpDescCfgBox::UpdateAttrs(OpDescPtr &op_desc) const {
std::for_each(attrs_.begin(), attrs_.end(),
[&op_desc](const auto &attr) { op_desc->SetAttr(attr.first, attr.second); });


+ 24
- 11
tests/st/testcase/test_model_deploy_schedule.cc View File

@@ -30,24 +30,15 @@ class TestModelDeploySchedule : public testing::Test {
TEST_F(TestModelDeploySchedule, test_data_slice) {
DEF_GRAPH(g1) {
auto data = std::make_shared<OpDesc>("data1", DATA);
auto var = std::make_shared<OpDesc>("var1", VARIABLE);
auto conv = std::make_shared<OpDesc>("conv1", CONV2D);
// data output 0
auto data_output_desc = data->MutableOutputDesc(0);
std::vector<std::vector<int64_t>> cut_attr = {{0, 0, 0, 0}};
ge::AttrUtils::SetListListInt(data_output_desc, "cut_info", cut_attr);
// conv input 0
auto conv_input_desc = conv->MutableInputDesc(0);
ge::AttrUtils::SetListListInt(conv_input_desc, "cut_info", {{1,0,0,0}, {0,0,0,0}});
// conv input 1
auto input_desc = conv->MutableInputDesc(1);
ge::AttrUtils::SetListListInt(input_desc, "cut_info", {{0, 0, 0, 0}, {0, 0, 1, 0}});
CHAIN(NODE(data)->NODE(conv));
CHAIN(NODE(var)->NODE(conv));
// CHAIN(NODE("data1", DATA)->NODE("conv1", CONV2D));
// CHAIN(NODE("var1", VARIABLE)->NODE("conv1"));
CHAIN(NODE("data1", DATA)->NODE(conv));
CHAIN(NODE("var1", VARIABLE)->NODE(conv));
};
map<AscendString, AscendString> options;
@@ -58,7 +49,29 @@ TEST_F(TestModelDeploySchedule, test_data_slice) {
auto ret = session.BuildGraph(1, inputs);
EXPECT_EQ(ret, SUCCESS);
DEF_GRAPH(g1_1) {
auto conv = std::make_shared<OpDesc>("conv1", CONV2D);
// conv input 0
auto conv_input_desc = conv->MutableInputDesc(0);
ge::AttrUtils::SetListListInt(conv_input_desc, "cut_info", {{1, 0, 0, 0}, {0, 0, 0, 0}});
auto dims = conv_input_desc->GetShape().GetDims();
dims[0] /= 2;
conv_input_desc->SetShape(GeShape(dims));
// conv input 1
auto input_desc = conv->MutableInputDesc(1);
ge::AttrUtils::SetListListInt(input_desc, "cut_info", {{0, 0, 0, 0}, {0, 0, 1, 0}});
auto cov2 = OP_CFG(CONV2D).input(0, TensorDesc().attr("cut_info", {{1, 0, 0, 0}, {0, 0, 0, 0}});
auto slice =OP_CFG(SLICE).Attr("ddd ", 1).TensorDescShape(dims);
CHAIN(NODE("data1", DATA)->EDGE(0, 0)->NODE("any_slice", slice)->EDGE(0, 0)->NODE(conv));
CHAIN(NODE("any_var", VARIABLE)->EDGE(0, 0)->NODE("any_slice"));
CHAIN(NODE("var1", VARIABLE)->EDGE(0, 1)->NODE(conv));
};
CHECK_GRAPH(PreRunAfterBuild) {
ASSERT_GRAPH_CMP(graph, g1_1);
ASSERT_EQ(graph->GetName(), "g1_1");
ASSERT_EQ(graph->GetAllNodesSize(), 4);
};


Loading…
Cancel
Save