tracel-ai / burn

Burn is a new comprehensive dynamic Deep Learning Framework built using Rust with extreme flexibility, compute efficiency and portability as its primary goals.
https://burn.dev
Apache License 2.0
7.29k stars 345 forks source link

Implement multi-dimensional repeat operation and rename existing repeat method #1715

Open antimora opened 2 weeks ago

antimora commented 2 weeks ago

Currently, Burn's repeat method only supports repeating along one dimension at a time. To enhance functionality and align with common deep learning frameworks like PyTorch, we need to implement a new repeat operation that accepts multiple dimensions simultaneously. This will provide the same behavior as PyTorch's repeat.

To avoid confusion and maintain consistency with other Burn methods, we should rename the existing repeat method to repeat_dim, similar to other *_dim methods in the library.

Implementing this multi-dimensional repeat operation is crucial for supporting the Tile ONNX operator, which is commonly used in many user-submitted models. The lack of this functionality has been reported by users, as highlighted in issue #1714.

Tasks:

  1. Implement a new repeat method that accepts multiple dimensions and repeats the tensor along those dimensions simultaneously.
  2. Rename the existing repeat method to repeat_dim for consistency with other *_dim methods.
  3. Update the documentation and examples to reflect the new repeat method and the renamed repeat_dim method.
  4. Add unit tests to verify the correctness of the multi-dimensional repeat operation.
  5. Ensure compatibility with the Tile ONNX operator and test with user-submitted models that require this functionality.

By completing these tasks, we will provide a more comprehensive and user-friendly repeat operation in Burn, enabling users to easily repeat tensors along multiple dimensions and improving compatibility with ONNX models.

antimora commented 2 weeks ago

CC: @louisfd, @nathanielsimard, @laggui

louisfd commented 2 weeks ago

It should be easy to make a default implementation that calls repeat_dim once for each dimension