!812 Feature:display model info
From: @wangwenhua1 Reviewed-by: @xchu42,@ji_chen Signed-off-by: @ji_chenpull/812/MERGE
commit
c8ceb4b8fc
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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>
|
||||
#define private public
|
||||
#define protected public
|
||||
#include "framework/common/helper/model_helper.h"
|
||||
#include "ge/model/ge_model.h"
|
||||
#undef private
|
||||
#undef protected
|
||||
|
||||
#include "proto/task.pb.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ge {
|
||||
class UtestModelHelper : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {}
|
||||
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
TEST_F(UtestModelHelper, save_size_to_modeldef_failed)
|
||||
{
|
||||
GeModelPtr ge_model = ge::MakeShared<ge::GeModel>();
|
||||
ModelHelper model_helper;
|
||||
EXPECT_EQ(ACL_ERROR_GE_MEMORY_ALLOCATION, model_helper.SaveSizeToModelDef(ge_model));
|
||||
}
|
||||
|
||||
TEST_F(UtestModelHelper, save_size_to_modeldef)
|
||||
{
|
||||
GeModelPtr ge_model = ge::MakeShared<ge::GeModel>();
|
||||
std::shared_ptr<domi::ModelTaskDef> task = ge::MakeShared<domi::ModelTaskDef>();
|
||||
ge_model->SetModelTaskDef(task);
|
||||
ModelHelper model_helper;
|
||||
EXPECT_EQ(SUCCESS, model_helper.SaveSizeToModelDef(ge_model));
|
||||
}
|
||||
} // namespace ge
|
@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright 2019-2020 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 "common/ge/ge_util.h"
|
||||
#include "proto/ge_ir.pb.h"
|
||||
#include "inc/framework/omg/omg.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace ge {
|
||||
class UtestOmg : public testing::Test {
|
||||
protected:
|
||||
void SetUp() override {}
|
||||
|
||||
void TearDown() override {}
|
||||
};
|
||||
|
||||
TEST_F(UtestOmg, display_model_info_failed) {
|
||||
ge::proto::ModelDef model_def;
|
||||
PrintModelInfo(&model_def);
|
||||
}
|
||||
|
||||
TEST_F(UtestOmg, display_model_info_success) {
|
||||
ge::proto::ModelDef model_def;
|
||||
auto attrs = model_def.mutable_attr();
|
||||
ge::proto::AttrDef *attr_def_soc = &(*attrs)["soc_version"];
|
||||
attr_def_soc->set_s("Ascend310");
|
||||
ge::proto::AttrDef *attr_def = &(*attrs)["om_info_list"];
|
||||
attr_def->mutable_list()->add_i(1);
|
||||
attr_def->mutable_list()->add_i(2);
|
||||
attr_def->mutable_list()->add_i(3);
|
||||
attr_def->mutable_list()->add_i(4);
|
||||
attr_def->mutable_list()->add_i(5);
|
||||
PrintModelInfo(&model_def);
|
||||
}
|
||||
} // namespace ge
|
Loading…
Reference in new issue