Skip to content

Commit fd87c0e

Browse files
author
Yibing Liu
committed
Fix cast layer's doc
1 parent fbddb8e commit fd87c0e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

python/paddle/fluid/layers/tensor.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,21 @@ def create_global_var(shape,
111111

112112
def cast(x, dtype):
113113
"""
114-
This function takes in the input with input_dtype
115-
and casts it to the output_dtype as the output.
114+
This layer takes in the Variable :attr:`x` with :attr:`x.dtype` and casts
115+
it to the output with :attr:`dtype`.
116+
117+
Args:
118+
x (Variable): The input Variable for casting.
119+
dtype(np.dtype|core.VarDesc.VarType|str): Data type of the output Variable.
120+
121+
Returns:
122+
Variable: The output Variable after casting.
123+
124+
Examples:
125+
.. code-block:: python
126+
127+
data = fluid.layers.data(name='x', shape=[13], dtype='float32')
128+
result = fluid.layers.cast(x=data, dtype='float64')
116129
"""
117130
helper = LayerHelper('cast', **locals())
118131
out = helper.create_tmp_variable(dtype=dtype)

0 commit comments

Comments
 (0)