MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / _tensor_str_with_formatter

Function _tensor_str_with_formatter

python/oneflow/framework/tensor_str.py:239–267  ·  view source on GitHub ↗
(self, indent, summarize, formatter1)

Source from the content-addressed store, hash-verified

237
238
239def _tensor_str_with_formatter(self, indent, summarize, formatter1):
240 dim = self.dim()
241
242 if dim == 0:
243 return _scalar_str(self, formatter1)
244
245 if dim == 1:
246 return _vector_str(self, indent, summarize, formatter1)
247
248 if summarize and self.size(0) > 2 * PRINT_OPTS.edgeitems:
249 slices = (
250 [
251 _tensor_str_with_formatter(self[i], indent + 1, summarize, formatter1,)
252 for i in range(0, PRINT_OPTS.edgeitems)
253 ]
254 + ["..."]
255 + [
256 _tensor_str_with_formatter(self[i], indent + 1, summarize, formatter1,)
257 for i in range(self.shape[0] - PRINT_OPTS.edgeitems, self.shape[0])
258 ]
259 )
260 else:
261 slices = [
262 _tensor_str_with_formatter(self[i], indent + 1, summarize, formatter1)
263 for i in range(0, self.size(0))
264 ]
265
266 tensor_str = ("," + "\n" * (dim - 1) + " " * (indent + 1)).join(slices)
267 return "[" + tensor_str + "]"
268
269
270def _tensor_str(self, indent):

Callers 1

_tensor_strFunction · 0.85

Calls 5

_scalar_strFunction · 0.85
_vector_strFunction · 0.85
dimMethod · 0.80
joinMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected