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

Method _binary

python/src/graph.py:240–247  ·  view source on GitHub ↗
(self, fn_name, a, b)

Source from the content-addressed store, hash-verified

238 return self._get_output_info(x.id)
239
240 def _binary(self, fn_name, a, b):
241 a = self._ensure_tensor(a)
242 b = self._ensure_tensor(b)
243 out = cactus_node_t()
244 rc = getattr(_lib, fn_name)(self.h, cactus_node_t(a.id), cactus_node_t(b.id), ctypes.byref(out))
245 if rc != 0:
246 raise RuntimeError(f"{fn_name} failed")
247 return self._tensor_from_node(out.value)
248
249 def _ensure_tensor(self, x):
250 if not isinstance(x, Tensor):

Callers 4

addMethod · 0.95
subtractMethod · 0.95
multiplyMethod · 0.95
divideMethod · 0.95

Calls 2

_ensure_tensorMethod · 0.95
_tensor_from_nodeMethod · 0.95

Tested by

no test coverage detected