Skip to content

Conversation

@Lunderberg
Copy link
Contributor

This extends the existing @T.prim_func decorator to accept a keyword-only argument @T.prim_func(params=param_dict), defining a string to object mapping. This mapping can be used to refer to external parameters from within the PrimFunc definition.

This extends the existing `@T.prim_func` decorator to accept a
keyword-only argument `@T.prim_func(params=param_dict)`, defining a
string to object mapping.  This mapping allows variables inside a
PrimFunc to refer to values set outside the `PrimFunc` definition.
@Lunderberg
Copy link
Contributor Author

I was thinking of this as complementary to the existing PrimFunc.specialize. Where specialize can operate on existing PrimFunc objects, and can be used from C++, these parameters can only be used when generating a new PrimFunc object from Python.

The advantage of using the prim_func parameters is that they do not require adding the parameter to the PrimFunc arguments and do not require running through an additional transformation, making them easier to read when writing test cases.

@junrushao
Copy link
Member

@Hzfengsy has some preliminary work on metaprogramming. Would you mind sharing?

@Lunderberg
Copy link
Contributor Author

@junrushao1994 Not sure if you're asking me or @Hzfengsy on it, but I'm certainly okay with sharing. This was useful in some test cases I was sketching out, and figured it would be good to start a conversation on it.

@junrushao
Copy link
Member

Oh sorry for the confusion! I was asking Siyuan

@Hzfengsy
Copy link
Member

Here is a related PR: #11097

@Lunderberg
Copy link
Contributor Author

Closing in favor of #11097, any deltas can be added in later PRs.

@Lunderberg Lunderberg closed this Apr 26, 2022
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