Skip to content

Commit

Permalink
ensure ndarray is writeable when -> tensor (#137)
Browse files Browse the repository at this point in the history
Signed-off-by: nstarman <[email protected]>
  • Loading branch information
nstarman authored Sep 7, 2023
1 parent 360593e commit d49368e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/stream_ml/pytorch/_connect/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def _from_ndarraytype_to_tensor(
data: Data[np.ndarray[Any, Any]], /, **kwargs: Any
) -> Data[xp.Tensor]:
"""Convert from numpy.ndarray to torch.Tensor."""
return replace(data, array=xp.asarray(np.asarray(data.array), **kwargs))
array = np.array(data.array, copy=True, subok=False)
array.flags.writeable = True
return replace(data, array=xp.asarray(array, **kwargs))

ASTYPE_REGISTRY[
(asdf.tags.core.ndarray.NDArrayType, xp.Tensor)
Expand Down

0 comments on commit d49368e

Please sign in to comment.