-
Notifications
You must be signed in to change notification settings - Fork 2
TransposeLayer #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TransposeLayer #193
Conversation
src/layers/TransposeLayer.cpp
Outdated
| } | ||
| Shape new_shape(new_dims); | ||
|
|
||
| std::vector<float> output_data(input_data->size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, check for other data types
src/layers/TransposeLayer.cpp
Outdated
| } | ||
|
|
||
| if (perm_.empty()) { | ||
| perm_.resize(shape.dims()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we enumerate shapes starting from the end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the default to be reverse permutation, but it's probably unnecessary.
|
Currently, if the layer is constructed with empty perm_, run() fills perm_ once using the first input’s rank. That means calling the same instance later with a different-rank tensor will throw on validate_perm. Prefer computing a local permutation per call when perm_ is empty, e.g.: This keeps the layer usable across inputs of different ranks without surprising statefulness. |
|
Current mapping recomputes old_indices by repeated %// per element. That’s fine for clarity and likely OK at your tensor sizes, but if you profile a hot path, consider: |
|
run assumes float (input.as(), std::vector). If the framework expects multi-dtype tensors, you’ll want either a templated kernel or a small type-dispatch in run. Tests currently cover only float. Not necessarily required for this PR, but worth tracking. |
|
Reserve capacity for new_dims (new_dims.reserve(shape.dims())). |
|
Tests to add (nice-to-have) |
No description provided.