Program Listing for File execute.h

Return to documentation for file (include/execute.h)

#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_EXECUTE_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_EXECUTE_H_

#include <string>
#include <vector>
#include <map>
#include <memory>
#include "include/api/context.h"
#include "include/api/types.h"
#include "include/dataset/constants.h"
#include "include/dataset/transforms.h"

namespace mindspore {
namespace dataset {
class DeviceResource;
// class to run tensor operations in eager mode
class Execute {
 public:
  explicit Execute(std::shared_ptr<TensorOperation> op, MapTargetDevice device_type = MapTargetDevice::kCpu,
                   uint32_t device_id = 0);

  explicit Execute(std::shared_ptr<TensorTransform> op, MapTargetDevice device_type = MapTargetDevice::kCpu,
                   uint32_t device_id = 0);

  explicit Execute(std::reference_wrapper<TensorTransform> op, MapTargetDevice device_type = MapTargetDevice::kCpu,
                   uint32_t device_id = 0);

  explicit Execute(TensorTransform *op, MapTargetDevice device_type = MapTargetDevice::kCpu, uint32_t device_id = 0);

  explicit Execute(std::vector<std::shared_ptr<TensorOperation>> ops,
                   MapTargetDevice device_type = MapTargetDevice::kCpu, uint32_t device_id = 0);

  explicit Execute(std::vector<std::shared_ptr<TensorTransform>> ops,
                   MapTargetDevice device_type = MapTargetDevice::kCpu, uint32_t device_id = 0);

  explicit Execute(const std::vector<std::reference_wrapper<TensorTransform>> ops,
                   MapTargetDevice device_type = MapTargetDevice::kCpu, uint32_t device_id = 0);

  explicit Execute(const std::vector<TensorTransform *> &ops, MapTargetDevice device_type = MapTargetDevice::kCpu,
                   uint32_t device_id = 0);

  ~Execute();

  Status operator()(const mindspore::MSTensor &input, mindspore::MSTensor *output);

  Status operator()(const std::vector<mindspore::MSTensor> &input_tensor_list, std::vector<mindspore::MSTensor> *out);

  Status DeviceMemoryRelease();

  std::string AippCfgGenerator();

 private:
  Status ParseTransforms();

  Status ValidateDevice();

  Status InitResource(MapTargetDevice device_type, uint32_t device_id);

  std::vector<std::shared_ptr<TensorTransform>> transforms_;
  std::vector<std::shared_ptr<TensorOperation>> ops_;
  MapTargetDevice device_type_;
  std::shared_ptr<DeviceResource> device_resource_;
  struct ExtraInfo;
  std::shared_ptr<ExtraInfo> info_;
};

}  // namespace dataset
}  // namespace mindspore
#endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_INCLUDE_DATASET_EXECUTE_H_