mindspore.Tensor.type_as
- Tensor.type_as(other)[source]
Change the dtype of the Tensor to the dtype of other.
- Parameters
other (Tensor) – The return tensor has the same dtype as other.
- Returns
Tensor, has the same dtype as other.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> from mindspore import Tensor >>> x = Tensor([[1, 2], [3, 4]], dtype=mindspore.float32) >>> y = Tensor([[1, 2], [3, 4]], dtype=mindspore.int32) >>> x = x.type_as(y) >>> print(x.dtype) Int32