TransposeLayer#193
Conversation
| } | ||
| Shape new_shape(new_dims); | ||
|
|
||
| std::vector<float> output_data(input_data->size()); |
There was a problem hiding this comment.
Please, check for other data types
| } | ||
|
|
||
| if (perm_.empty()) { | ||
| perm_.resize(shape.dims()); |
There was a problem hiding this comment.
Why do we enumerate shapes starting from the end?
There was a problem hiding this comment.
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.