-
Notifications
You must be signed in to change notification settings - Fork 5
[Feature]: Improve TensorLayout descriptor and add string-based TensorShape querying #112
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
base: develop
Are you sure you want to change the base?
[Feature]: Improve TensorLayout descriptor and add string-based TensorShape querying #112
Conversation
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.
Pull request overview
This pull request refactors the TensorLayout system to use string-based representations internally and adds new capabilities for querying tensor shape dimensions by dimension name and permuting tensor shapes between different layouts.
Changes:
- Replaced the
TensorLayoutDescstruct-based system with a string-based representation usinglayoutStringTable - Added
operator[]overload to query tensor shape dimensions by name (e.g.,shape["N"]) - Added
TensorShape::permute()method to convert tensor shapes between different layouts
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
include/core/tensor_layout.hpp |
Removed TensorLayoutDesc struct and replaced descriptor-based methods with string-based implementation; added indexOf(), dimAt(), and string() methods |
src/core/tensor_layout.cpp |
Implemented new TensorLayout constructor and string-based dimension lookup methods |
include/core/tensor_shape.hpp |
Added operator[](std::string_view) and permute() method declarations |
src/core/tensor_shape.cpp |
Implemented string-based dimension indexing and shape permutation logic; improved error messages for index operator |
include/core/tensor.hpp |
Added shape(std::string_view) method declaration |
src/core/tensor.cpp |
Implemented shape(std::string_view) method forwarding to TensorShape |
tests/roccv/cpp/src/tests/core/tensor/test_tensor_shape.cpp |
Added tests for string-based dimension querying and shape permutation |
Comments suppressed due to low confidence (1)
include/core/tensor_layout.hpp:27
- Missing
#include <string>and#include <string_view>headers. The header file usesstd::stringinlayoutStringTable(line 53),m_layoutString(line 139), and the return type ofstring()method (line 88), as well asstd::string_viewin method signaturesindexOf()(line 73) anddimAt()(line 81). These headers must be included to ensure the code compiles independently.
#include <unordered_map>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #112 +/- ##
===========================================
+ Coverage 73.76% 73.78% +0.02%
===========================================
Files 72 74 +2
Lines 2828 2864 +36
Branches 610 615 +5
===========================================
+ Hits 2086 2113 +27
- Misses 325 332 +7
- Partials 417 419 +2
🚀 New features to boost your workflow:
|
Motivation
Aims to represent tensor layouts as strings and simplify shape dimension querying.
Technical Details
TensorShape::permute()method added to convert tensor shapes into other layouts.Tensor.shape("N")orTensorShape["W"].TensorShape::containsDim()/TensorLayout::containsDim()methods added to check if a dimension is present in a given tensor.Test Plan
TensorShape::permute()method works as intended.Test Result
Submission Checklist