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.

profiling_kernel_mod.cc 2.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "kernel/rts/profiling_kernel_mod.h"
  17. #include <vector>
  18. #include <string>
  19. #include <memory>
  20. #include "framework/ge_runtime/task_info.h"
  21. #include "device/ascend/profiling/profiling_utils.h"
  22. #include "session/anf_runtime_algorithm.h"
  23. using ProfilerTraceTaskInfo = ge::model_runner::ProfilerTraceTaskInfo;
  24. using mindspore::device::ascend::ProfilingUtils;
  25. namespace mindspore {
  26. namespace kernel {
  27. bool ProfilingKernelMod::Init(const AnfNodePtr &anf_node) {
  28. MS_LOG(INFO) << "[profiling] init profiling kernel mod";
  29. auto primitive = AnfAlgo::GetCNodePrimitive(anf_node);
  30. ValuePtr notify_ptr = primitive->GetAttr(ProfilingUtils::kNotify);
  31. MS_EXCEPTION_IF_NULL(notify_ptr);
  32. ValuePtr log_id_ptr = primitive->GetAttr(ProfilingUtils::kProfilerTraceId);
  33. MS_EXCEPTION_IF_NULL(log_id_ptr);
  34. ValuePtr flags_ptr = primitive->GetAttr(ProfilingUtils::kFlags);
  35. MS_EXCEPTION_IF_NULL(flags_ptr);
  36. notify_ = GetValue<bool>(notify_ptr);
  37. log_id_ = GetValue<uint64_t>(log_id_ptr);
  38. flags_ = GetValue<uint32_t>(flags_ptr);
  39. MS_LOG(INFO) << "[profiling] profiling kernel notify_:" << notify_ << ", log_id_:" << log_id_
  40. << ", flags_:" << flags_;
  41. return true;
  42. }
  43. bool ProfilingKernelMod::Launch(const std::vector<AddressPtr> & /*inputs*/,
  44. const std::vector<AddressPtr> & /*workspace*/,
  45. const std::vector<AddressPtr> & /*outputs*/, void * /*stream_ptr*/) {
  46. return true;
  47. }
  48. std::vector<TaskInfoPtr> ProfilingKernelMod::GenTask(const std::vector<AddressPtr> &inputs,
  49. const std::vector<AddressPtr> &workspace,
  50. const std::vector<AddressPtr> &outputs, uint32_t stream_id) {
  51. MS_LOG(INFO) << "gen task inputs size:" << inputs.size() << ", workspace size:" << workspace.size()
  52. << ", outputs size:" << outputs.size();
  53. stream_id_ = stream_id;
  54. std::shared_ptr<ProfilerTraceTaskInfo> task_info_ptr =
  55. std::make_shared<ProfilerTraceTaskInfo>(stream_id, log_id_, notify_, flags_);
  56. return {task_info_ptr};
  57. }
  58. } // namespace kernel
  59. } // namespace mindspore