mindspore.Tensor.bitwise_xor
- mindspore.Tensor.bitwise_xor(other)
逐元素执行两个Tensor的异或运算。
说明
参数 self 和 other 遵循隐式类型转换规则,使数据类型保持一致。
- 参数:
other (Tensor, Number.number) - 输入Tensor或常量,shape与 self 相同,或能与 self 的shape广播。
- 返回:
Tensor,与广播后的输入shape相同,和 self 数据类型相同。
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor >>> input = Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mindspore.int16) >>> other = Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mindspore.int16) >>> output = input.bitwise_xor(other) >>> print(output) [ 0 1 0 0 -2 3 2]