You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_CustomOpTensorDict is an abstract class for some operations (mainly on TensorDict shapes).
It may not be necessary to keep it and maintaining it may be bothersome in the future.
Pros:
Most operations that we'd be doing would not change the storage anyway in most cases. For instance, a call on the view method of a regular TensorDict's values will return a view on those tensors, with no extra memory cost.
Code clarity: this is one more class that inherits from _TensorDict, and each new operation will (in the current implementation) require its own class. This is not ideal.
Cons:
In the case of LazyStackedTensorDict, we would probably like to have a view method that keeps the storage location unchanged. Not using _CustomOpTensorDict will require us to call contiguous on the stack and then call the view operation, but this will assign a new storage to the resulting tensors. The final option could be to prevent users from calling these fixed-storage operations on LazyStackedTensorDict but that could lead to some issues in the future (i.e. users asking for this feature when it has been decided to deprecate it previously).
The ProbabilisticOperator class can write to tensordict instances that are unsqueezed. This makes it easy to do in-place modifications of a tensordict without having to create multiple copies of the tensors. This feature is used to execute a policy on a single environment that has no batch size.
The text was updated successfully, but these errors were encountered:
The common practice in the pytorch ecosystem is to type-hint all functions and methods as much as can be.
This PR completes the missing hints in the code.
_CustomOpTensorDict
is an abstract class for some operations (mainly on TensorDict shapes).It may not be necessary to keep it and maintaining it may be bothersome in the future.
Pros:
view
method of a regularTensorDict
's values will return a view on those tensors, with no extra memory cost._TensorDict
, and each new operation will (in the current implementation) require its own class. This is not ideal.Cons:
LazyStackedTensorDict
, we would probably like to have aview
method that keeps the storage location unchanged. Not using_CustomOpTensorDict
will require us to callcontiguous
on the stack and then call the view operation, but this will assign a new storage to the resulting tensors. The final option could be to prevent users from calling these fixed-storage operations onLazyStackedTensorDict
but that could lead to some issues in the future (i.e. users asking for this feature when it has been decided to deprecate it previously).ProbabilisticOperator
class can write to tensordict instances that are unsqueezed. This makes it easy to do in-place modifications of a tensordict without having to create multiple copies of the tensors. This feature is used to execute a policy on a single environment that has no batch size.The text was updated successfully, but these errors were encountered: