cast¶
- paddle.fluid.layers.tensor. cast ( x, dtype ) [source]
- 
         This OP takes in the Tensor xwithx.dtypeand casts it to the output withdtype. It’s meaningless if the output dtype equals the input dtype, but it’s fine if you do so.- Parameters
- 
           - x (Tensor) – An input N-D Tensor with data type bool, float16, float32, float64, int32, int64, uint8. 
- dtype (np.dtype|str) – Data type of the output: bool, float16, float32, float64, int8, int32, int64, uint8. 
 
- Returns
- 
           A Tensor with the same shape as input’s. 
- Return type
- 
           Tensor 
 Examples import paddle x = paddle.to_tensor([2, 3, 4], 'float64') y = paddle.cast(x, 'uint8') 
