Skip to content

Commit

Permalink
[RLlib] Fix torch None conversion in `torch_utils.py::convert_to_torc…
Browse files Browse the repository at this point in the history
…h_tensor`. (ray-project#26863)

Signed-off-by: Stefan van der Kleij <s.vanderkleij@viroteq.com>
  • Loading branch information
Rohan138 authored and Stefan van der Kleij committed Aug 18, 2022
1 parent 88c9e65 commit 5143772
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rllib/utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def convert_to_torch_tensor(x: TensorStructType, device: Optional[str] = None):
"""

def mapping(item):
if item is None:
# returns None with dtype=np.obj
return np.asarray(item)
# Already torch tensor -> make sure it's on right device.
if torch.is_tensor(item):
return item if device is None else item.to(device)
Expand Down

0 comments on commit 5143772

Please sign in to comment.