Skip to content
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

TilerHelper and 2D Tiling Visualizations #1870

Merged
merged 140 commits into from
Nov 18, 2024
Merged

TilerHelper and 2D Tiling Visualizations #1870

merged 140 commits into from
Nov 18, 2024

Conversation

hunhoffe
Copy link
Collaborator

@hunhoffe hunhoffe commented Oct 22, 2024

Description

This PR introduces some classes to help with data transformations/tiling and data visualization. The main classes introduced are:

  • TensorTile: A class representing information for specifying a 'chunk' of data, suitable for use in describing a npu_dma_memcpy_nd operation; also includes code for visualizing the TensorTile.
  • TensorTileSequence: A wrapper class for a list of TensorTiles; also includes code for visualization (including animations).
  • TensorTiler2D: A class that helps with data tiling. Provides simple_tiler(), group_tiler(), and step_tiler() methods to aid in generating iterative patterns of tiling over the tensor.

I also include:

  • A (non-exhaustive, but also not completely trivial) set of tests in test/python/tensortiler
  • A minor edit of a few programming examples (dma_transpose, matrix_scalar_add, row_wise_bias_add matrxi_multiplication/whole_array) to show how to use the TensorTiler2D
  • Two new programming examples (in programming_examples/basic/tiling_exploration) and an introductory notebook that use the device to create an access order map that can be compared to the map provided by the TensorTiler2D. These examples are meant to verify the TensorTiler2D can produce valid access patterns but also illustrate how to use the tensor tiling code.
  • A change to npu_dma_memcpy_nd to support taking a TensorTile directly instead of sizes/strides/offset

Some incidental things that got included in this PR:

  • First programming example with no inputs, only an output, which required some minor changes to support

Note for future contributions

  • Visualization of transformation chaining (e.g., toStream AND fromStream w/ ObjectFIFOLink)
  • Helper class for transformation chaining?
  • Support for overlapping data patterns (e.g., image transforms)
  • Integration of visualization into runtime sequence and/or memtile data movement.

Notes

Credit to Andre for his really excellent tool here: https://andreroesti.com/data-layout-viz/data_layout.html
This is my attempt at making something similar that can be integrated into a development tool directly, with the additional step of generating sizes/strides for you.

Copy link
Contributor

github-actions bot commented Oct 22, 2024

Coverage Report

Created: 2024-10-25 14:52

Click here for information about interpreting this report.

FilenameFunction CoverageLine CoverageRegion CoverageBranch Coverage
IR/AIEXDialect.cpp 100.00% 86.12% 88.69% 79.79%
Transforms/AIEDmaToNpu.cpp 100.00% 91.00% 85.61% 73.26%
Totals 100.00% 88.47% 87.68% 77.74%
Generated by llvm-cov -- llvm version 14.0.0

@hunhoffe hunhoffe changed the title [WIP] Experimental, Ignore me [WIP] TensorTiler2D Oct 25, 2024
@fifield
Copy link
Collaborator

fifield commented Oct 25, 2024

How hard is it to generalize from 2d?

@hunhoffe
Copy link
Collaborator Author

hunhoffe commented Oct 25, 2024

@fifield Great question but I'm not sure... This needs some work before it's ready for merge due to some complexities with translating between the sizes/strides generated by the TensorTiler2D and the limitations in sizes/sizes allowed by the hardware.

My plan right now is to get a bit more confident about the problem space in 2D (which is also easier to visualize) before moving on to something more complex.

@hunhoffe hunhoffe marked this pull request as ready for review November 12, 2024 23:25
@hunhoffe
Copy link
Collaborator Author

CI is currently failing because lit test for notebooks assumes dependencies which are only added in #1909

Copy link
Collaborator

@jgmelber jgmelber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nitpick would be to add an overall README to the tiling_exploration programming example directory.

@hunhoffe
Copy link
Collaborator Author

Notes:

@hunhoffe hunhoffe added this pull request to the merge queue Nov 18, 2024
Merged via the queue into main with commit 3b5799b Nov 18, 2024
52 checks passed
@hunhoffe hunhoffe deleted the tiler-helper branch November 18, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants