The operator casts the elements of a given input tensor to a data type specified by the 'to' argument and returns an output tensor of the same size in the converted type. Args: x (Tensor): input tensor. to (int): data type, float32 = 0; int = 2. Returns:
(x, to)
| 4711 | |
| 4712 | |
| 4713 | def cast(x, to): |
| 4714 | """ |
| 4715 | The operator casts the elements of a given input tensor to a data type |
| 4716 | specified by the 'to' argument and returns an output tensor of the same |
| 4717 | size in the converted type. |
| 4718 | Args: |
| 4719 | x (Tensor): input tensor. |
| 4720 | to (int): data type, float32 = 0; int = 2. |
| 4721 | Returns: |
| 4722 | the output Tensor. |
| 4723 | """ |
| 4724 | return Cast(to)(x)[0] |
| 4725 | |
| 4726 | |
| 4727 | class OneHot(Operator): |