Clipping API of the tensor class. It is used to limit elements in a tensor between the specified minimum value and maximum value (elements smaller than the minimum value will be replaced with the minimum value, and elements greater than the maximum value will be replaced with the maximum value). Asynchronous calling is supported. The inplace operation is not supported.
It is supported by the Atlas inference product and
For the
The following conditions must be met:
1 | APP_ERROR Clip(const Tensor &src, Tensor &dst, float minVal, float maxVal, AscendStream &stream = AscendStream::DefaultStream()); |
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Tensor class, supporting float16, float32, and uint8 data types. |
dst |
Output |
Tensor class, supporting float16, float32, and uint8 data types. An empty tensor can be passed. If dst is not an empty tensor, call Tensor.Malloc() to allocate memory in advance. |
minVal |
Input |
Float type, minimum value after clipping in a tensor. Elements smaller than the minimum value will be replaced with the minimum value. The value of minVal must be less than or equal to that of maxVal. |
maxVal |
Input |
Float type, maximum value after clipping in a tensor. Elements greater than the maximum value will be replaced with the maximum value. The value of maxVal must be greater than or equal to that of minVal. |
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. |
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |