pypto.bitwise_not

Applicable Products

  • Ascend 950PR/Ascend 950DT: Supported
  • Atlas A3 training products/Atlas A3 inference products: Supported
  • Atlas A2 training products/Atlas A2 inference products: Supported

Description

Performs a bitwise NOT operation on the input values element by element. The computation formula is as follows:

resi=∼inputires_i = \sim input_i

Prototype

bitwise_not(input: Tensor) -> Tensor

Parameters

ParameterInput/OutputDescription
inputInputSource operand.
Supported type: Tensor. The supported tensor data types vary by product model. For details, see Constraints.
Empty tensors are not supported. The shape supports only 1 to 4 dimensions. The shape size must not exceed 2147483647 (that is, INT32_MAX).

Return Value

Returns the output tensor, whose data type and shape are the same as those of input.

Constraints

  1. Tensor data type description:
    • Ascend 950PR/Ascend 950DT: DT_INT16, DT_UINT16, DT_INT8, DT_UINT8, DT_INT32, and DT_BOOL.
    • Atlas A3 training products/Atlas A3 inference products: DT_INT16, DT_UINT16, DT_INT8, DT_UINT8, and DT_BOOL.
    • Atlas A2 training products/Atlas A2 inference products: DT_INT16, DT_UINT16, DT_INT8, DT_UINT8, and DT_BOOL.
  2. Tensor inputs do not support the TileOpFormat.TILEOP_NZ format.

Examples

TileShape Setting Example

Before calling this operation API, set the TileShape through set_vec_tile_shapes.

The TileShape must have the same number of dimensions as the output.

For example, if the input shape is [m, n], the output is [m, n], and the TileShape is set to [m1, n1], then m1 and n1 are used to tile the m and n axes, respectively.

pypto.set_vec_tile_shapes(4, 16)

API Call Example

a = pypto.tensor([2], pypto.DT_INT16)
out = pypto.bitwise_not(a)

The results are as follows:

Input data a:  [2, 5]
Output data out: [-3, -6]