SetTensorValue

Function Usage

Sets the value of a tensor. The value can be of the int32_t, uint8_t, float16, or float32 type.

The tensor object must be on the device side, and the data type must match the called SetTensorValue method.

The device where the tensor is located must be the same as that where the stream is located.

Prototype

1
APP_ERROR Tensor::SetTensorValue(uint8_t value, AscendStream& stream = AscendStream::DefaultStream());
1
APP_ERROR Tensor::SetTensorValue(float value, bool IsFloat16 = false, AscendStream& stream = AscendStream::DefaultStream());
1
APP_ERROR Tensor::SetTensorValue(int32_t value, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

value

Input

int32_t, uint8_t, or float type. It specifies the value to be set for a tensor.

isFloat16

Input

The value is of the Bool type. The default value is false.

  • true indicates that the tensor element is of the float16 type.
  • false indicates that the tensor element is of the float32 type.

stream

Input

AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.