Class Execute

Class Documentation

class Execute

Public Functions

explicit Execute(const std::shared_ptr<TensorOperation> &op, MapTargetDevice device_type = MapTargetDevice::kCpu, uint32_t device_id = 0)

Constructor.

Parameters
  • op[in] TensorOperation to be applied in Eager mode, it accepts operation in type of shared pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • op[in] TensorTransform to be applied in Eager mode, it accepts operation in type of shared pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • op[in] TensorTransform to be applied in Eager mode, it accepts operation in type of reference.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • op[in] TensorTransform to be applied in Eager mode, it accepts operation in type of raw pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • ops[in] A vector of TensorOperations to be applied in Eager mode, it accepts operation in type of shared pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • ops[in] A vector of TensorTransforms to be applied in Eager mode, it accepts operation in type of shared pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • ops[in] A vector of TensorTransforms to be applied in Eager mode, it accepts operation in type of raw pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

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

Constructor.

Parameters
  • ops[in] A vector of TensorTransforms to be applied in Eager mode, it accepts operation in type of raw pointer.

  • device_type[in] Target device environment to perform operation, can be kCPU/kGPU/kAscend310 (default=kCPU).

  • device_id[in] Target device ID to perform operation, only valid when device_type=kAscend310 (default=0).

~Execute()

Destructor.

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

Callable function to execute the TensorTransform in eager mode.

Parameters
  • input[in] Tensor to be transformed.

  • output[out] Transformed tensor.

Returns

Status error code, returns OK if no error encountered.

样例
/* Usage of Execute */
std::shared_ptr<TensorTransform> decode = std::make_shared<vision::Decode>();
std::shared_ptr<TensorTransform> center_crop(new vision::CenterCrop({30}));
std::shared_ptr<TensorTransform> rescale = std::make_shared<vision::Rescale>(1. / 3, 0.5);
mindspore::dataset::Execute transform = Execute({decode, center_crop, rescale});

/* Apply transforms */
mindspore::MSTensor image = ReadFileToTensor("apple.jpg");
Status rc = transform(image, &image);
Status operator()(const std::vector<mindspore::MSTensor> &input_tensor_list, std::vector<mindspore::MSTensor> *out)

Callable function to execute the TensorTransform in eager mode.

Parameters
  • input_tensor_list[in] List of Tensor to be transformed.

  • out[out] Result tensor after transform.

Returns

Status error code, returns OK if no error encountered.

样例
/* Usage of Execute */
auto tokenizer = text::BasicTokenizer();
mindspore::dataset::Execute transform = Execute({tokenizer});

/* Apply transforms */
std::vector<mindspore::MSTensor> txt = ReadTextToTensor("demo.txt");
std::vector<mindspore::MSTensor> txt_result;
Status rc = transform1({txt}, &txt_result);
Status DeviceMemoryRelease()

The function to release device memory on Ascend310.

std::string AippCfgGenerator()

The function to generate AIPP configuration.

Public Static Functions

static Status Run(const std::vector<std::shared_ptr<dataset::Execute>> &data_graph, const std::vector<mindspore::MSTensor> &inputs, std::vector<mindspore::MSTensor> *outputs)

Given a set of Executes, run them.