MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / _get_max_width

Function _get_max_width

python/paddle/tensor/to_string.py:168–178  ·  view source on GitHub ↗
(var)

Source from the content-addressed store, hash-verified

166
167
168def _get_max_width(var):
169 # return max_width for a scalar
170 max_width = 0
171 signed = False
172 for item in list(var.flatten()):
173 if (not signed) and (item < 0):
174 signed = True
175 item_str = _format_item(item)
176 max_width = max(max_width, len(item_str))
177
178 return max_width, signed
179
180
181def _format_tensor(var, summary, indent=0, max_width=0, signed=False):

Callers 5

test_positive_onlyMethod · 0.90
test_with_negativeMethod · 0.90
test_single_valueMethod · 0.90
to_stringFunction · 0.85
_format_dense_tensorFunction · 0.85

Calls 4

listFunction · 0.85
_format_itemFunction · 0.85
maxFunction · 0.70
flattenMethod · 0.45

Tested by 3

test_positive_onlyMethod · 0.72
test_with_negativeMethod · 0.72
test_single_valueMethod · 0.72