MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / decode

Function decode

tools/Polygraphy/polygraphy/json/serde.py:215–232  ·  view source on GitHub ↗
(dct)

Source from the content-addressed store, hash-verified

213
214 @Decoder.register(np.ndarray)
215 def decode(dct):
216 def load(mode="base64"):
217 if mode == "base64":
218 data = base64.b64decode(dct["array"].encode(), validate=True)
219 elif mode == "latin-1":
220 data = dct["array"].encode(mode)
221 else:
222 assert False, f"Unsupported mode: {mode}"
223 infile = io.BytesIO(data)
224 return np.load(infile, allow_pickle=False)
225
226 try:
227 arr = load()
228 except:
229 arr = load("latin-1") # For backwards compatibility
230 if isinstance(arr, np.ndarray):
231 return arr
232 return list(arr.values())[0] # For backwards compatibility
233
234 NUMPY_REGISTRATION_SUCCESS = True
235

Callers

nothing calls this directly

Calls 2

loadFunction · 0.85
valuesMethod · 0.45

Tested by

no test coverage detected