Skip to content

Commit

Permalink
fix to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
zkh2016 committed Mar 17, 2022
1 parent 44f121c commit 448e8ce
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions python/paddle/tensor/to_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ def to_string(var, prefix='Tensor'):


def _format_dense_tensor(tensor, indent):
np_tensor = tensor.numpy()

if len(tensor.shape) == 0:
size = 0
else:
Expand All @@ -275,14 +277,10 @@ def _format_dense_tensor(tensor, indent):
if size > DEFAULT_PRINT_OPTIONS.threshold:
sumary = True

max_width, signed = _get_max_width(_to_summary(tensor))
max_width, signed = _get_max_width(_to_summary(np_tensor))

data = _format_tensor(
tensor.numpy(),
sumary,
indent=indent,
max_width=max_width,
signed=signed)
np_tensor, sumary, indent=indent, max_width=max_width, signed=signed)
return data


Expand Down

0 comments on commit 448e8ce

Please sign in to comment.