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.

kernel_info.h 3.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef MINDSPORE_DEVICE_KERNEL_INFO_H_
  17. #define MINDSPORE_DEVICE_KERNEL_INFO_H_
  18. #include <vector>
  19. #include <memory>
  20. #include "kernel/kernel_build_info.h"
  21. #include "device/ascend/ascend_device_address.h"
  22. #include "kernel/kernel.h"
  23. namespace mindspore {
  24. const uint32_t kInvalidGraphId = UINT32_MAX;
  25. const uint32_t kInvalidDistincLabel = UINT32_MAX;
  26. namespace device {
  27. class KernelInfo {
  28. public:
  29. KernelInfo() {
  30. kernel_mod_ = nullptr;
  31. is_feature_map_ = false;
  32. select_kernel_build_info_ = nullptr;
  33. output_address_list_ = {};
  34. workspace_address_list_ = {};
  35. stream_id_ = 0;
  36. stream_distinction_label_ = kInvalidDistincLabel;
  37. graph_id_ = kInvalidGraphId;
  38. }
  39. virtual ~KernelInfo() = default;
  40. const kernel::KernelBuildInfo *select_kernel_build_info() const;
  41. kernel::KernelBuildInfoPtr GetMutableSelectKernelBuildInfo() const;
  42. void set_select_kernel_build_info(const kernel::KernelBuildInfoPtr &select_kernel_build_info) {
  43. select_kernel_build_info_ = select_kernel_build_info;
  44. }
  45. void SetFeatureMapFlag(bool flag) { is_feature_map_ = flag; }
  46. const DeviceAddress *GetOutputAddr(size_t index) const;
  47. DeviceAddressPtr GetMutableOutputAddr(size_t index) const;
  48. bool OutputAddrExist(size_t index) const;
  49. bool SetOutputAddr(const DeviceAddressPtr &output_address, size_t index);
  50. DeviceAddress *GetWorkspaceAddr(size_t index) const;
  51. bool SetWorkspaceAddr(const DeviceAddressPtr &output_address, size_t index);
  52. void set_kernel_mod(const kernel::KernelModPtr &kernel_mod);
  53. kernel::KernelMod *MutableKernelMod() const;
  54. const kernel::KernelMod *kernel_mod() const;
  55. uint32_t stream_id() const { return stream_id_; }
  56. void set_stream_id(uint32_t stream_id) { stream_id_ = stream_id; }
  57. uint32_t stream_distinction_label() const { return stream_distinction_label_; }
  58. void set_stream_distinction_label(uint32_t stream_distinction_label) {
  59. stream_distinction_label_ = stream_distinction_label;
  60. }
  61. void set_graph_id(uint32_t graph_id) { graph_id_ = graph_id; }
  62. uint32_t graph_id() const { return graph_id_; }
  63. bool operator==(const KernelInfo &other) const;
  64. bool is_feature_map() const { return is_feature_map_; }
  65. private:
  66. bool is_feature_map_;
  67. kernel::KernelBuildInfoPtr select_kernel_build_info_;
  68. std::vector<std::shared_ptr<DeviceAddress>> output_address_list_;
  69. std::vector<std::shared_ptr<DeviceAddress>> workspace_address_list_;
  70. kernel::KernelModPtr kernel_mod_;
  71. // stream_id_ is the index of stream object vector
  72. uint32_t stream_id_;
  73. // stream_distinction_label_ is used mark different op in different stream
  74. uint32_t stream_distinction_label_;
  75. // record which graph the node belong to
  76. uint32_t graph_id_;
  77. };
  78. } // namespace device
  79. } // namespace mindspore
  80. #endif // MINDSPORE_DEVICE_KERNEL_INFO_H_