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.

execute.h 2.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * Copyright 2020-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_CCSRC_MINDDATA_DATASET_INCLUDE_EXECUTE_H_
  17. #define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_EXECUTE_H_
  18. #include <string>
  19. #include <vector>
  20. #include <memory>
  21. #include "include/api/context.h"
  22. #include "include/api/types.h"
  23. #include "minddata/dataset/include/constants.h"
  24. #include "minddata/dataset/include/transforms.h"
  25. namespace mindspore {
  26. namespace dataset {
  27. class AscendResource; // Class to manage the resource of Ascend310
  28. // class to run tensor operations in eager mode
  29. class Execute {
  30. public:
  31. /// \brief Constructor
  32. explicit Execute(std::shared_ptr<TensorOperation> op, std::string deviceType = "CPU");
  33. explicit Execute(std::vector<std::shared_ptr<TensorOperation>> ops, std::string deviceType = "CPU");
  34. /// \brief Destructor
  35. ~Execute();
  36. /// \brief callable function to execute the TensorOperation in eager mode
  37. /// \param[in] input Tensor to be transformed
  38. /// \param[out] output Transformed tensor
  39. /// \return Status code
  40. Status operator()(const mindspore::MSTensor &input, mindspore::MSTensor *output);
  41. /// \brief callable function to execute the TensorOperation in eager mode
  42. /// \param[in] input_tensor_list List of Tensor to be transformed
  43. /// \param[out] out Result tensor after transform
  44. /// \return - Status
  45. Status operator()(const std::vector<mindspore::MSTensor> &input_tensor_list, std::vector<mindspore::MSTensor> *out);
  46. #ifdef ENABLE_ACL
  47. Status DeviceMemoryRelease();
  48. #endif
  49. private:
  50. Status validate_device_();
  51. std::vector<std::shared_ptr<TensorOperation>> ops_;
  52. std::string device_type_;
  53. #ifdef ENABLE_ACL
  54. std::shared_ptr<AscendResource> D_resource_;
  55. #endif
  56. };
  57. } // namespace dataset
  58. } // namespace mindspore
  59. #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_EXECUTE_H_