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.

aicpu_kernel_mod.h 2.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_MINDSPORE_CCSRC_KERNEL_AICPU_AICPU_KERNEL_MOD_H_
  17. #define MINDSPORE_MINDSPORE_CCSRC_KERNEL_AICPU_AICPU_KERNEL_MOD_H_
  18. #include <vector>
  19. #include <memory>
  20. #include <string>
  21. #include "kernel/ascend_kernel_mod.h"
  22. #include "kernel/aicpu/aicpu_util.h"
  23. namespace mindspore {
  24. namespace kernel {
  25. class AicpuOpKernelMod : public AscendKernelMod {
  26. public:
  27. AicpuOpKernelMod();
  28. ~AicpuOpKernelMod() override;
  29. bool Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
  30. const std::vector<AddressPtr> &outputs, void *stream_ptr) override;
  31. std::vector<TaskInfoPtr> GenTask(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
  32. const std::vector<AddressPtr> &outputs, uint32_t stream_id) override;
  33. void SetInputList(const std::vector<int64_t> &inputList);
  34. void SetOutputList(const std::vector<int64_t> &outputList);
  35. void SetAnfNode(const AnfNodePtr &anf_node);
  36. void SetNodeDef(const std::string &nodeDef);
  37. void SetNodeName(const std::string &node_name);
  38. /**
  39. * @brief Build AICPU Engine kernel structure, and allocate device memory for offline task generate
  40. * @return SUCCESS
  41. * @return FAIL
  42. *
  43. */
  44. void CreateCpuKernelInfo(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &outputs);
  45. void SetInputSizeList(const std::vector<size_t> &size_list);
  46. void SetOutputSizeList(const std::vector<size_t> &size_list);
  47. void SetWorkspaceSizeList(const std::vector<size_t> &size_list);
  48. const std::vector<size_t> &GetInputSizeList() const override;
  49. const std::vector<size_t> &GetOutputSizeList() const override;
  50. const std::vector<size_t> &GetWorkspaceSizeList() const override;
  51. private:
  52. std::string args_;
  53. std::string node_def_str_;
  54. std::string node_name_;
  55. std::string node_so_;
  56. std::vector<int64_t> inputList_;
  57. std::vector<int64_t> outputList_;
  58. AnfNodePtr anf_node_;
  59. std::vector<size_t> input_size_list_;
  60. std::vector<size_t> output_size_list_;
  61. std::vector<size_t> workspace_size_list_;
  62. };
  63. using AicpuOpKernelModPtr = std::shared_ptr<AicpuOpKernelMod>;
  64. using AicputOpKernelModPtrList = std::vector<AicpuOpKernelModPtr>;
  65. } // namespace kernel
  66. } // namespace mindspore
  67. #endif // MINDSPORE_MINDSPORE_CCSRC_KERNEL_AICPU_AICPU_KERNEL_MOD_H_