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.

launch_mul.h 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Copyright 2021 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_RUNTIME_DEVICE_LAUNCH_MUL_H_
  17. #define MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_LAUNCH_MUL_H_
  18. #include <vector>
  19. #include <memory>
  20. #include "backend/session/kernel_graph.h"
  21. namespace mindspore::device {
  22. class LaunchMul {
  23. public:
  24. LaunchMul(TypeId dtype, size_t total_size)
  25. : dtype_(dtype),
  26. total_size_(total_size),
  27. input1_addr_(nullptr),
  28. input2_addr_(nullptr),
  29. input2_value_(0),
  30. mul_graph_(nullptr) {}
  31. virtual ~LaunchMul() = default;
  32. virtual void FreeDeviceMem(void *addr) = 0;
  33. virtual size_t AlignSizeForLaunchKernel(size_t size) = 0;
  34. virtual uint8_t *AllocDeviceMem(size_t size) = 0;
  35. virtual void KernelSelect(std::shared_ptr<session::KernelGraph> kernel_graph) = 0;
  36. virtual void KernelBuild(std::shared_ptr<session::KernelGraph> kernel_graph) = 0;
  37. virtual void CopyHostMemToDevice(size_t origin_size, size_t dst_size) = 0;
  38. std::shared_ptr<session::KernelGraph> ObtainMulKernelGraph();
  39. kernel::KernelMod *ObtainLaunchMulKernelMod();
  40. void ObtainMulInputsAddr();
  41. void FreeInputDeviceMemory();
  42. protected:
  43. TypeId dtype_;
  44. size_t total_size_;
  45. uint8_t *input1_addr_;
  46. uint8_t *input2_addr_;
  47. float input2_value_;
  48. std::shared_ptr<session::KernelGraph> mul_graph_;
  49. std::vector<uint8_t *> inputs_addr_;
  50. };
  51. } // namespace mindspore::device
  52. #endif // MINDSPORE_MINDSPORE_CCSRC_RUNTIME_DEVICE_LAUNCH_MUL_H_