pytorch / pytorch/rl

[Feature Request] cloning inconsistencies

Open
#348 0 comments 0 reactions 1 assignee View on GitHub

@vmoens is already working on this.

Since Aug 7, 2022.

enhancement
Dominant language
Python
Stars
3.6k
Forks
484
Avg merge
1d 1h
Merged PRs (30d)
207

Description

Motivation

clone() should either return an object of the same type (e.g. SavedTensorDict.clone() returns a SavedTensorDict instance) or a generic type (e.g. MemmapTensor.clone() returns a torch.Tensor instance.)

Pros of same-type
  • It makes sense that cloning an object returns a copy of this object (not another type)
  • In the case of multi-task, we use the feature that a LazyStackedTensorDict contains tensordicts whose keys can be hidden. However, if cloning returns a regular TensorDict, those keys will be lost.

### Pros of generic type

  • For users that do not have a very deep understanding of the repo's primitives, it can make more sense for clone to return the generic type. Also, if cloning a stack of tensordicts returns another stack of other tensordicts, it is hard to see what the advantage and what the usage could be.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.