• 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 #include <vector>
19 #include <sstream>
20 #include "op_proto/inc/math_ops.h"
21 
22 namespace mindspore {
23 namespace transform {
BuildMDDatasetGraph(const DatasetGraphParam & param)24 DfGraphPtr BuildMDDatasetGraph(const DatasetGraphParam &param) {
25   MS_LOG(INFO) << "BuildMDDatasetGraph.";
26 
27   // InitData
28   auto d = ::ge::op::InitData("init_data_tmp").set_attr_channel_name(param.queue_name());
29 
30   // set graph inputs & outputs
31   std::vector<::ge::Operator> inputs{d};
32   std::vector<::ge::Operator> outputs{d};
33   DfGraphPtr dataset_graph = std::make_shared<DfGraph>("dataset");
34   (void)dataset_graph->SetInputs(inputs);
35   (void)dataset_graph->SetOutputs(outputs);
36 
37   return dataset_graph;
38 }
39 
BuildDatasetGraph(const DatasetGraphParam & param,const std::string & phase)40 Status BuildDatasetGraph(const DatasetGraphParam &param, const std::string &phase) {
41   Status ret;
42   std::string graph_name = phase;
43 
44   MS_LOG(INFO) << "BuildDatasetGraph begin. phase is " << phase;
45   MS_LOG(INFO) << "param is " << param.ToString() << ".";
46 
47   DfGraphPtr dataset_graph = BuildMDDatasetGraph(param);
48   ret = DfGraphManager::GetInstance().AddGraph(graph_name, dataset_graph);
49   if (ret != Status::SUCCESS) {
50     MS_LOG(ERROR) << "BuildDatasetGraph failed.";
51   } else {
52     MS_LOG(INFO) << "BuildDatasetGraph end.";
53   }
54   return ret;
55 }
56 }  // namespace transform
57 }  // namespace mindspore
58