Skip to content

Commit

Permalink
fix _format_item
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqiu committed Oct 12, 2020
1 parent c25f045 commit d0dfb51
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions python/paddle/tensor/to_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,6 @@ def set_printoptions(precision=None,
core.set_printoptions(**kwargs)


def _to_sumary(var):
edgeitems = DEFAULT_PRINT_OPTIONS.edgeitems

if len(var.shape) == 0:
return var
elif len(var.shape) == 1:
if var.shape[0] > 2 * edgeitems:
return paddle.concat([var[:edgeitems], var[-edgeitems:]])
else:
return var
else:
# recursively handle all dimensions
if var.shape[0] > 2 * edgeitems:
begin = [x for x in var[:edgeitems]]
end = [x for x in var[-edgeitems:]]
return paddle.stack([_to_sumary(x) for x in (begin + end)])
else:
return paddle.stack([_to_sumary(x) for x in var])


def _format_item(np_var):
if np_var.dtype == np.float32 or np_var.dtype == np.float64 or np_var.dtype == np.float16:
if DEFAULT_PRINT_OPTIONS.sci_mode:
Expand All @@ -123,7 +103,7 @@ def _format_item(np_var):
return '{{:.{}f}}'.format(DEFAULT_PRINT_OPTIONS.precision).format(
np_var)
else:
return '{}'.format(var)
return '{}'.format(np_var)


def _format_tensor(var, sumary, indent=0):
Expand Down

0 comments on commit d0dfb51

Please sign in to comment.