Skip to content

Conversation

@Snektron
Copy link
Contributor

@Snektron Snektron commented Jan 8, 2026

Proposed changes

While thinking about adding support for bwd, I realized that this would require duplicating a lot of code for the different versions of Input, Output, and related functions. Instead of writing those all out, I figured that it would be possible to derive most of them by providing some reflection utilities. So, this is an idea of how to do that. I'm looking for a bit of feedback, since this is relatively complex in terms of code.

Design

A new concept, TensorReflectable, can be implemented by Inputs and Outputs to automatically provide support for UniqueInputs, UniqueOutputs, alloc_inputs, alloc_outputs, and validate(). Basically, Inputs::reflect and Outputs::reflect call an inspection function with each of its fields, and this can then be used to automatically implement the other functions. Its pretty straight forward, the main complex part is that inspect() has to be called with a member variable pointer so as to allow the function to be static. To be honest, the main reason for that is so that the automatic implementation of validate() can be a bit cleaner. Let me know what you think.

Copy link
Contributor

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 PR introduces a reflection mechanism for tensor input/output structures to reduce code duplication. By implementing a TensorReflectable concept, types can automatically derive UniqueInputs, UniqueOutputs, alloc_inputs, alloc_outputs, and validate functions through a reflect method that iterates over their fields.

Key Changes:

  • Added TensorReflectable concept and automatic implementations for related functions
  • Implemented align_fwd utility for memory alignment
  • Refactored forward convolution to use reflection instead of manual implementations

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
experimental/builder/include/ck_tile/builder/testing/testing_reflect.hpp New header defining the reflection mechanism and automatic implementations
experimental/builder/include/ck_tile/builder/testing/testing.hpp Updated documentation to reference reflection support and made functions explicitly deleted
experimental/builder/include/ck_tile/builder/testing/tensor_buffer.hpp Added align_fwd utility function for memory alignment
experimental/builder/include/ck_tile/builder/testing/conv_fwd.hpp Replaced manual implementations with reflection-based approach
experimental/builder/test/unit_conv_fwd_testing.cpp Added tests for reflection and validation functionality
experimental/builder/test/unit_device_buffer.cpp Added tests for align_fwd function
experimental/builder/test/unit_validation.cpp Added blank line and comment for explicit validate implementation
experimental/builder/test/CMakeLists.txt Added new test file and utility library dependency
Comments suppressed due to low confidence (1)

experimental/builder/include/ck_tile/builder/testing/testing.hpp:262

  • Return type should be UniqueOutputs<SIGNATURE> instead of UniqueInputs<SIGNATURE> for the alloc_outputs function.
UniqueInputs<SIGNATURE> alloc_outputs(const Args<SIGNATURE>& args) = delete;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Snektron Snektron force-pushed the rvoetter/conv-testing-reflect branch from d89eb7c to 8b4916f Compare January 8, 2026 17:05
This adds some utilities to automatically generate UniqueInputs,
UniqueOutputs, alloc_inputs, alloc_outputs, and validate, based
on a Inputs::reflect() and Outputs::reflect().
@Snektron Snektron force-pushed the rvoetter/conv-testing-reflect branch from 8b4916f to 6f2b01c Compare January 8, 2026 17:06
@Snektron Snektron merged commit b352a68 into develop Jan 12, 2026
21 checks passed
@Snektron Snektron deleted the rvoetter/conv-testing-reflect branch January 12, 2026 08:45
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