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

Method set_input

python/src/graph.py:47–61  ·  view source on GitHub ↗
(self, tensor, data, dtype=None)

Source from the content-addressed store, hash-verified

45 return self._tensor_from_node(out.value)
46
47 def set_input(self, tensor, data, dtype=None):
48 if not isinstance(tensor, Tensor):
49 raise TypeError("tensor must be a Tensor")
50 if tensor.g is not self:
51 raise ValueError("tensor belongs to a different graph")
52 target_dtype = int(tensor.dtype if dtype is None else dtype)
53 arr = self._coerce_input_array(data, target_dtype)
54 rc = _lib.cactus_graph_set_input(
55 self.h,
56 cactus_node_t(tensor.id),
57 arr.ctypes.data_as(ctypes.c_void_p),
58 target_dtype,
59 )
60 if rc != 0:
61 raise RuntimeError("graph_set_input failed")
62
63 def hard_reset(self):
64 rc = _lib.cactus_graph_hard_reset(self.h)

Callers 15

test_pow_absMethod · 0.95
test_subtractMethod · 0.95
test_addMethod · 0.95
test_multiplyMethod · 0.95
test_divideMethod · 0.95
test_viewMethod · 0.95
test_flattenMethod · 0.95
test_concatMethod · 0.95
test_cat_1dMethod · 0.95
test_cat_2d_axis1Method · 0.95
test_reluMethod · 0.95

Calls 2

_coerce_input_arrayMethod · 0.95
data_asMethod · 0.80

Tested by 15

test_pow_absMethod · 0.76
test_subtractMethod · 0.76
test_addMethod · 0.76
test_multiplyMethod · 0.76
test_divideMethod · 0.76
test_viewMethod · 0.76
test_flattenMethod · 0.76
test_concatMethod · 0.76
test_cat_1dMethod · 0.76
test_cat_2d_axis1Method · 0.76
test_reluMethod · 0.76