• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "transform/graph_ir/graph_builder.h"
18 
19 #include <sstream>
20 
21 #include "ops/math_ops.h"
22 
23 namespace mindspore {
24 namespace transform {
BuildMDDatasetGraph(const DatasetGraphParam & param)25 DfGraphPtr BuildMDDatasetGraph(const DatasetGraphParam &param) {
26   MS_LOG(INFO) << "BuildMDDatasetGraph.";
27 
28   // InitData
29   auto d = ge::op::InitData("init_data_tmp").set_attr_channel_name(param.queue_name());
30 
31   // set graph inputs & outputs
32   std::vector<ge::Operator> inputs{d};
33   std::vector<ge::Operator> outputs{d};
34   DfGraphPtr dataset_graph = std::make_shared<DfGraph>("dataset");
35   (void)dataset_graph->SetInputs(inputs);
36   (void)dataset_graph->SetOutputs(outputs);
37 
38   return dataset_graph;
39 }
40 
BuildDatasetGraph(const DatasetGraphParam & param,const std::string & phase)41 Status BuildDatasetGraph(const DatasetGraphParam &param, const std::string &phase) {
42   Status ret;
43   std::string graph_name = phase;
44 
45   MS_LOG(INFO) << "BuildDatasetGraph begin. phase is " << phase;
46   MS_LOG(INFO) << "param is " << param.ToString() << ".";
47 
48   DfGraphPtr dataset_graph = BuildMDDatasetGraph(param);
49   ret = DfGraphManager::GetInstance().AddGraph(graph_name, dataset_graph);
50   if (ret != Status::SUCCESS) {
51     MS_LOG(ERROR) << "BuildDatasetGraph failed.";
52   } else {
53     MS_LOG(INFO) << "BuildDatasetGraph end.";
54   }
55   return ret;
56 }
57 }  // namespace transform
58 }  // namespace mindspore
59