| 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) |