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.

base.h 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright 2020 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. #ifndef MINDSPORE_CCSRC_PIPELINE_BASE_H_
  17. #define MINDSPORE_CCSRC_PIPELINE_BASE_H_
  18. #include <mutex>
  19. #include <memory>
  20. #include <string>
  21. #include <sstream>
  22. #include "ir/anf.h"
  23. #include "pipeline/resource.h"
  24. #include "utils/context/ms_context.h"
  25. namespace mindspore {
  26. namespace pipeline {
  27. struct ExecutorInfo {
  28. FuncGraphPtr func_graph;
  29. ResourcePtr resource;
  30. std::size_t arg_list_size;
  31. };
  32. using ExecutorInfoPtr = std::shared_ptr<ExecutorInfo>;
  33. inline std::string GetPhasePrefix(const std::string &phase) {
  34. auto pos = phase.find('.');
  35. if (pos == std::string::npos) {
  36. MS_LOG(EXCEPTION) << "Phase has no . for prefix" << phase;
  37. }
  38. return phase.substr(0, pos);
  39. }
  40. inline std::string GetFilePathName(const std::string &file_name) {
  41. std::ostringstream oss;
  42. auto ms_context = MsContext::GetInstance();
  43. if (ms_context == nullptr) {
  44. MS_LOG(EXCEPTION) << "ms_context is nullptr";
  45. }
  46. auto save_graphs_path = ms_context->save_graphs_path();
  47. if (save_graphs_path.empty()) {
  48. save_graphs_path = ".";
  49. }
  50. oss << save_graphs_path << "/" << file_name;
  51. return oss.str();
  52. }
  53. } // namespace pipeline
  54. } // namespace mindspore
  55. #endif // MINDSPORE_CCSRC_PIPELINE_BASE_H_