You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

graph_builder.cc 1.8 kB

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