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_select_cpu.h 2.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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_DEVICE_CPU_KERNEL_SELECT_CPU_H_
  17. #define MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_SELECT_CPU_H_
  18. #include <utility>
  19. #include <string>
  20. #include <vector>
  21. #include "ir/anf.h"
  22. #include "ir/dtype/type.h"
  23. #include "utils/utils.h"
  24. namespace mindspore {
  25. namespace device {
  26. namespace cpu {
  27. void SetKernelInfo(const CNodePtr &apply_kernel_ptr);
  28. class KernelAttr {
  29. public:
  30. using DataType = std::pair<TypeId, std::string>;
  31. KernelAttr() = default;
  32. ~KernelAttr() = default;
  33. KernelAttr &AddInputAttr(const TypeId &ms_type, const std::string &format = kOpFormat_DEFAULT) {
  34. input_type_.emplace_back(ms_type, format);
  35. return *this;
  36. }
  37. KernelAttr &AddOutputAttr(const TypeId &ms_type, const std::string &format = kOpFormat_DEFAULT) {
  38. output_type_.emplace_back(ms_type, format);
  39. return *this;
  40. }
  41. const DataType &GetInputAttr(const size_t index) const { return input_type_[index]; }
  42. const DataType &GetOutputAttr(const size_t index) const { return output_type_[index]; }
  43. size_t GetInputSize() const { return input_type_.size(); }
  44. size_t GetOutputSize() const { return output_type_.size(); }
  45. private:
  46. std::vector<DataType> input_type_;
  47. std::vector<DataType> output_type_;
  48. };
  49. } // namespace cpu
  50. } // namespace device
  51. } // namespace mindspore
  52. #endif // MINDSPORE_CCSRC_DEVICE_CPU_KERNEL_SELECT_CPU_H_