ADD file via upload

This commit is contained in:
saltyfish 2022-10-17 18:27:52 +08:00
parent c7ef57f747
commit f2cbc1a69b
1 changed files with 73 additions and 0 deletions

View File

@ -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 &param) {
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类型变量retphase存入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 &param, 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