Contains various utility functions
noop
(x
=None
, *args
, **kwargs
)
Do nothing
apply
(func
, x
, *args
, **kwargs
)
Apply func
recursively to x
, passing on args
retain_type
(new
, old
=None
, typ
=None
, copy_meta
=False
)
Cast new
to type of old
or typ
if it's a superclass
retain_meta
(x
, res
, copy_meta
=False
)
Call res.set_meta(x)
, if it exists
to_device
(b
, device
='cpu'
)
Recursively put b
on device
.
tensor
(x
, *rest
, **kwargs
)
Like torch.as_tensor
, but handle lists too, and can pass multiple vector elements directly.