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 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_JIT_BASE_H_
  17. #define MINDSPORE_CCSRC_PIPELINE_JIT_BASE_H_
  18. #include <mutex>
  19. #include <memory>
  20. #include <string>
  21. #include <sstream>
  22. #include "ir/anf.h"
  23. #include "pipeline/jit/resource.h"
  24. #include "utils/ms_context.h"
  25. namespace mindspore {
  26. namespace pipeline {
  27. struct ExecutorInfo {
  28. FuncGraphPtr func_graph;
  29. ResourcePtr resource;
  30. // The num of input data.
  31. std::size_t arg_list_size;
  32. // The all args of graph,including input data and weight.
  33. VectorRef arg_list;
  34. };
  35. using ExecutorInfoPtr = std::shared_ptr<ExecutorInfo>;
  36. inline std::string GetPhasePrefix(const std::string &phase) {
  37. auto pos = phase.find('.');
  38. if (pos == std::string::npos) {
  39. MS_LOG(EXCEPTION) << "Phase has no . for prefix" << phase;
  40. }
  41. return phase.substr(0, pos);
  42. }
  43. inline std::string GetSaveGraphsPathName(const std::string &file_name) {
  44. std::ostringstream oss;
  45. auto ms_context = MsContext::GetInstance();
  46. if (ms_context == nullptr) {
  47. MS_LOG(EXCEPTION) << "ms_context is nullptr";
  48. }
  49. auto save_graphs_path = ms_context->get_param<std::string>(MS_CTX_SAVE_GRAPHS_PATH);
  50. if (save_graphs_path.empty()) {
  51. save_graphs_path = ".";
  52. }
  53. oss << save_graphs_path << "/" << file_name;
  54. return oss.str();
  55. }
  56. } // namespace pipeline
  57. } // namespace mindspore
  58. #endif // MINDSPORE_CCSRC_PIPELINE_JIT_BASE_H_