mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[RLlib] Fix torch None conversion in torch_utils.py::convert_to_torch_tensor
. (#26863)
This commit is contained in:
parent
69f6b843da
commit
97bcf38ec0
1 changed files with 3 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue