MCPcopy Create free account
hub / github.com/cactus-compute/cactus / _coerce_input_array

Method _coerce_input_array

python/src/graph.py:274–289  ·  view source on GitHub ↗
(self, data, precision)

Source from the content-addressed store, hash-verified

272 return Tensor(self, int(node_id), meta["shape"], meta["precision"])
273
274 def _coerce_input_array(self, data, precision):
275 if isinstance(data, Tensor):
276 arr = data.numpy()
277 else:
278 arr = np.asarray(data)
279 if precision == self.INT8:
280 arr = np.ascontiguousarray(arr, dtype=np.int8)
281 elif precision == self.FP16:
282 arr = np.ascontiguousarray(arr, dtype=np.float16)
283 elif precision == self.FP32:
284 arr = np.ascontiguousarray(arr, dtype=np.float32)
285 elif precision == self.INT4:
286 arr = np.ascontiguousarray(arr, dtype=np.uint8)
287 else:
288 raise RuntimeError("unsupported precision")
289 return arr
290
291
292class Tensor:

Callers 1

set_inputMethod · 0.95

Calls 1

numpyMethod · 0.80

Tested by

no test coverage detected