Skip to content

Conversation

@PragmaTwice
Copy link
Member

Currently for_each accepts a callable with parameters typed (size_t, Arg).

In this PR we extend it to three kinds of parameter types:

  • (size_t, Arg): same as original one
  • (Arg): size_t can be omitted if possible
  • (std::integral_constant<size_t, I>, Arg): the index is passed as a constexpr value so that it can be used in template arguments (e.g. for std::get<I>) and if constexprs.

Also as a demonstration we replace the struct Arg2Str with a simple for_each call.

@PragmaTwice PragmaTwice changed the title [FFI] Replace Arg2Str with a more powerful for_each [FFI] Replace Arg2Str with a more powerful for_each Jul 5, 2025
@PragmaTwice PragmaTwice marked this pull request as ready for review July 5, 2025 08:01
@Hzfengsy Hzfengsy merged commit 49b139b into apache:main Jul 6, 2025
14 of 15 checks passed
@tqchen
Copy link
Member

tqchen commented Jul 7, 2025

Thanks for the contribution, for this particular case, let us remain as simplified as original version, mainly for the reason of simplicity and readability. We want to avoid indirections and polymorphism in template overloading, likely also simplifies compile time

@tqchen
Copy link
Member

tqchen commented Jul 7, 2025

followup on #18121

Hzfengsy pushed a commit that referenced this pull request Jul 7, 2025
)

Revert "[FFI] Replace `Arg2Str` with a more powerful `for_each` (#18117)"

This reverts commit 49b139b.
ShiboXing pushed a commit to ShiboXing/tvm that referenced this pull request Aug 10, 2025
[FFI] Replace Arg2Str with a more powerful for_each
ShiboXing pushed a commit to ShiboXing/tvm that referenced this pull request Aug 10, 2025
…che#18121)

Revert "[FFI] Replace `Arg2Str` with a more powerful `for_each` (apache#18117)"

This reverts commit 49b139b.
tqchen pushed a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
[FFI] Replace Arg2Str with a more powerful for_each
tqchen added a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
…che#18121)

Revert "[FFI] Replace `Arg2Str` with a more powerful `for_each` (apache#18117)"

This reverts commit ad328f5.
tqchen pushed a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
[FFI] Replace Arg2Str with a more powerful for_each
tqchen added a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
…che#18121)

Revert "[FFI] Replace `Arg2Str` with a more powerful `for_each` (apache#18117)"

This reverts commit ad328f5.
tqchen pushed a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
[FFI] Replace Arg2Str with a more powerful for_each
tqchen added a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
…che#18121)

Revert "[FFI] Replace `Arg2Str` with a more powerful `for_each` (apache#18117)"

This reverts commit ad328f5.
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