MCPcopy Create free account
hub / github.com/pytorch/pytorch / _sanitize_str

Function _sanitize_str

caffe2/python/net_printer.py:197–207  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

195
196
197def _sanitize_str(s):
198 if isinstance(s, str):
199 sanitized = s
200 elif isinstance(s, bytes):
201 sanitized = s.decode('ascii', errors='ignore')
202 else:
203 sanitized = str(s)
204 if len(sanitized) < 64:
205 return "'%s'" % sanitized
206 else:
207 return "'%s'" % sanitized[:64] + '...<+len=%d>' % (len(sanitized) - 64)
208
209
210def _arg_val(arg):

Callers 1

_arg_valFunction · 0.85

Calls 2

isinstanceFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…