Skip to content

Conversation

@cliffburdick
Copy link
Collaborator

Add apply operator for custom element-wise transformations

Introduces a new 'apply' operator that allows users to define custom
element-wise transformations using lambda functions or functors on one
or more input operators.

Key features:

  • Accepts variadic number of input operators
  • Supports host, device, or both annotations on functions
  • Automatically deduces return type from lambda/functor
  • Output rank matches first input operator's rank
  • Output size matches first input operator's size
  • Full capability forwarding from nested operators

Implementation details:

  • Created ApplyOp class in include/matx/operators/apply.h

Build system changes:

  • Added MATX_EN_EXTENDED_LAMBDA CMake option (default ON)
  • Automatically adds --extended-lambda flag when enabled
  • Required for host device lambdas in certain contexts

Testing:

  • Comprehensive test suite in test/00_operators/apply_test.cu
  • Tests single, dual, and triple input operators
  • Tests with 1D, 2D, 3D tensors
  • Tests nested operators, chaining, and scalars
  • Tests with all numeric types and executors
  • Uses functors to avoid extended lambda restrictions in test contexts

Documentation:

  • Added docs_input/api/manipulation/basic/apply.rst
  • Enhanced Doxygen comments with usage examples
  • Includes notes about std::apply naming collision
  • Added example code markers in test file for doc generation

@copy-pr-bot
Copy link

copy-pr-bot bot commented Oct 20, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@cliffburdick cliffburdick marked this pull request as ready for review October 20, 2025 22:39
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@cliffburdick
Copy link
Collaborator Author

/build

1 similar comment
@cliffburdick
Copy link
Collaborator Author

/build

@cliffburdick
Copy link
Collaborator Author

/build

@cliffburdick
Copy link
Collaborator Author

/build

@cliffburdick
Copy link
Collaborator Author

/build

@cliffburdick cliffburdick merged commit 56e7e60 into main Oct 23, 2025
1 check passed
@cliffburdick cliffburdick deleted the apply branch October 23, 2025 23:54
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.

2 participants