Skip to content

Commit b7f18f9

Browse files
committed
new api paddle.trunc, test=develop
1 parent feaeaa4 commit b7f18f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

python/paddle/tensor/math.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,17 @@ def trunc(input, name=None):
872872
873873
import paddle
874874
875-
input = paddle.to_tensor([[1.45, 3.54], [0.23, -4.21]], dtype='float32')
875+
input = paddle.rand([2,2],'float32')
876+
print(input)
877+
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
878+
# [[0.02331470, 0.42374918],
879+
# [0.79647720, 0.74970269]])
880+
876881
output = paddle.trunc(input)
877882
print(output)
878883
# Tensor(shape=[2, 2], dtype=float32, place=CUDAPlace(0), stop_gradient=True,
879-
# [[1., 3.],
880-
# [0., -4.]])
884+
# [[0., 0.],
885+
# [0., 0.]]))
881886
'''
882887
if in_dygraph_mode():
883888
return core.ops.trunc(input)

0 commit comments

Comments
 (0)