Skip to content

feature: to_launch_arg() for CubeLaunch structs #1198

Description

@MarcelPa

As a follow-up to my question on discord, I started working on a (rather minimal) approach to implement a .to_launch_arg() method for structs that are annotated with the CubeLaunch macro. The idea is that one can use this similarly to the .to_arg() function for Tensors, making it easier to use a custom struct as an argument when launching CubeCL kernels.

I was not entirely sure where to place all of my code, here is a summary of my approach:

  • in cubecl-core, I added a new trait AsLaunchArgument defining the signature of the as_launch_arg() function
  • in cubecl-macros, I added a new macro called CubeLaunchArg that implements AsLaunchArgument for a struct
  • my implementation checks whether a field is a scalar (wrote a function TypeField::is_scalar(&Type) for this); if so, wrap the field in ScalarArg, if not, hope that the field implements AsLaunchArg.

This is very rudimentary, and is just enough to make my use case work. I would be happy to extend it further, but I think it makes sense to check out whether my approach makes sense to you (as in the CubeCL maintainers & devs).

Thanks!
Marcel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions