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
Implement a more flexible unsqueeze() function that matches the behavior of PyTorch's unsqueeze(). The new function should allow inserting a singleton dimension anywhere in the tensor, as opposed to only prepending.
Feature motivation
The current implementation of unsqueeze() only prepends singleton dimensions. This limitation imposes constraints when manipulating tensor shapes. Having a more flexible unsqueeze operation will increase the usability and compatibility of the library.
(Optional) Suggest a Solution
Modify the unsqueeze() function to take an additional argument, dim, which indicates the position where the singleton dimension should be inserted. Something like this:
// Before `dim`
dims[0..dim].copy_from_slice(&shape.dims[0..dim]);// Insert singleton dimension at `dim`
dims[dim] = 1;// After `dim`
dims[(dim+1)..].copy_from_slice(&shape.dims[dim..]);
The text was updated successfully, but these errors were encountered:
Feature description
Implement a more flexible unsqueeze() function that matches the behavior of PyTorch's unsqueeze(). The new function should allow inserting a singleton dimension anywhere in the tensor, as opposed to only prepending.
Feature motivation
The current implementation of unsqueeze() only prepends singleton dimensions. This limitation imposes constraints when manipulating tensor shapes. Having a more flexible unsqueeze operation will increase the usability and compatibility of the library.
(Optional) Suggest a Solution
The text was updated successfully, but these errors were encountered: