Skip to content

Conversation

@zacharyvincze
Copy link
Contributor

@zacharyvincze zacharyvincze commented Jan 16, 2026

Motivation

Aims to represent tensor layouts as strings and simplify shape dimension querying.

Technical Details

  • TensorLayouts are now represented internally as strings.
  • TensorShape::permute() method added to convert tensor shapes into other layouts.
  • Dimension sizes can now be queried using string representations of the dimension. For example: Tensor.shape("N") or TensorShape["W"].
  • TensorShape::containsDim()/TensorLayout::containsDim() methods added to check if a dimension is present in a given tensor.

Test Plan

  • Ensure current Python/C++ tests continue to pass.
  • Write new unit tests to ensure string-based dimension size querying and the new TensorShape::permute() method works as intended.

Test Result

  • All tests pass as intended.

Submission Checklist

Copy link

Copilot AI left a 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 TensorLayoutDesc struct-based system with a string-based representation using layoutStringTable
  • 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 uses std::string in layoutStringTable (line 53), m_layoutString (line 139), and the return type of string() method (line 88), as well as std::string_view in method signatures indexOf() (line 73) and dimAt() (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-commenter
Copy link

codecov-commenter commented Jan 16, 2026

Codecov Report

❌ Patch coverage is 72.72727% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/core/tensor_layout.cpp 56.00% 8 Missing and 3 partials ⚠️
include/core/tensor_layout.hpp 80.00% 2 Missing ⚠️
include/core/tensor_shape.hpp 0.00% 1 Missing ⚠️
src/core/tensor.cpp 0.00% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
include/core/tensor.hpp 62.50% <ø> (ø)
src/core/tensor_shape.cpp 82.76% <100.00%> (+4.19%) ⬆️
include/core/tensor_shape.hpp 0.00% <0.00%> (ø)
src/core/tensor.cpp 70.37% <0.00%> (-0.66%) ⬇️
include/core/tensor_layout.hpp 83.33% <80.00%> (+13.33%) ⬆️
src/core/tensor_layout.cpp 56.00% <56.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:precheckin enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants