ADD file via upload
This commit is contained in:
parent
c7ef57f747
commit
f2cbc1a69b
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
* Copyright 2019 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 "include/transform/graph_ir/graph_builder.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "ops/math_ops.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace transform {
|
||||
//定义名为BuildMDDatasetGraph的函数,返回值为自定义类型DfGraphPtr
|
||||
//此函数为建立MD数据设置表格,返回为用指针引出的一系列数据
|
||||
/*
|
||||
首先输出消息日志 "BuildMDDatasetGraph.",其次初始化数据并获取变量param的name属性
|
||||
再其次借助SetInputs函数和SetOutputs函数分别设置图表的输入和输出
|
||||
最后返回dataset_graph
|
||||
*/
|
||||
DfGraphPtr BuildMDDatasetGraph(const DatasetGraphParam ¶m) {
|
||||
MS_LOG(INFO) << "BuildMDDatasetGraph.";
|
||||
|
||||
// InitData
|
||||
auto d = ge::op::InitData("init_data_tmp").set_attr_channel_name(param.queue_name());
|
||||
|
||||
// set graph inputs & outputs
|
||||
std::vector<ge::Operator> inputs{d};
|
||||
std::vector<ge::Operator> outputs{d};
|
||||
DfGraphPtr dataset_graph = std::make_shared<DfGraph>("dataset");
|
||||
(void)dataset_graph->SetInputs(inputs);
|
||||
(void)dataset_graph->SetOutputs(outputs);
|
||||
|
||||
return dataset_graph;
|
||||
}
|
||||
//定义名为BuildDatasetGraph的函数,返回值为自定义类型Status
|
||||
/*
|
||||
首先定义Status类型变量ret,并将phase存入graph_name
|
||||
其次输出消息日志"BuildDatasetGraph begin. phase is [*此处为phase]"
|
||||
"param is[*此处打印param]."
|
||||
再其次,先建立MD数据设置表格,再在此基础上执行对graph_name和dataset_graph的进一步操作并存入ret
|
||||
判断上述操作是否成功,若不成功则输出错误日志"BuildDatasetGraph failed.",若成功则输出消息日志"BuildDatasetGraph end."
|
||||
最后返回ret
|
||||
*/
|
||||
Status BuildDatasetGraph(const DatasetGraphParam ¶m, const std::string &phase) {
|
||||
Status ret;
|
||||
std::string graph_name = phase;
|
||||
|
||||
MS_LOG(INFO) << "BuildDatasetGraph begin. phase is " << phase;
|
||||
MS_LOG(INFO) << "param is " << param.ToString() << ".";
|
||||
|
||||
DfGraphPtr dataset_graph = BuildMDDatasetGraph(param);
|
||||
ret = DfGraphManager::GetInstance().AddGraph(graph_name, dataset_graph);
|
||||
if (ret != Status::SUCCESS) {
|
||||
MS_LOG(ERROR) << "BuildDatasetGraph failed.";
|
||||
} else {
|
||||
MS_LOG(INFO) << "BuildDatasetGraph end.";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace transform
|
||||
} // namespace mindspore
|
||||
Loading…
Reference in New Issue