Skip to content

Add FuncVec convenience type - #9387

Open
alexreinking wants to merge 2 commits into
alexreinking/rfactor-hoistingfrom
alexreinking/funcvecs
Open

Add FuncVec convenience type#9387
alexreinking wants to merge 2 commits into
alexreinking/rfactor-hoistingfrom
alexreinking/funcvecs

Conversation

@alexreinking

Copy link
Copy Markdown
Member

Add a FuncVec type that decays to Func in the n=1 case. This:

  1. Allows one to write Func output = pipeline.outputs() when you know that your pipeline is single-output.
  2. Sets the stage for future scheduling directives to return FuncVecs with the same single-func affordances (hoist_invariants in the future)
  3. Simplifies the creation of groups of related funcs: see the apps/ changes.

Breaking changes

None — the FuncVec type inherits from std::vector without adding state.

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

Stack created with GitHub Stacks CLIGive Feedback 💬

@alexreinking
alexreinking requested a review from abadams August 25, 2026 16:37
std::vector<Halide::Func> func_vector(const std::string &name, int size) {
std::vector<Halide::Func> funcs;
for (int i = 0; i < size; i++) {
funcs.emplace_back(Halide::Func{name + "_" + std::to_string(i)});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you think about: name + "[" + std::to_string(i) + "]"

@alexreinking alexreinking Aug 25, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure what [ would do in a Func name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think I prefer to keep f0, f1, ..., fN rather than burn two characters (on []) of std::string's short-string optimizations.

@shoaibkamil shoaibkamil Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think [ eventually gets legalized into ___ (three underscoeres)
except if the Func is used as an input/output generator, in which case it gets rejected. Seems safer to avoid [.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I really like e.g. gPyramid[3] because it reads way better in the profiler output and corresponds more closely to source code. That's what I've been using locally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we hard-reject it for output funcs though, that seems decisive

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about this: Have the constructor also take an optional suffix string. Right now it's a prefix string and a count. If it had a suffix too I could just say:

FuncVec v("foo[", 17, "]");

Comment thread apps/stencil_chain/stencil_chain_generator.cpp
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.06%. Comparing base (ca8cb9a) to head (8ed11d4).

Files with missing lines Patch % Lines
src/Func.h 33.33% 2 Missing ⚠️
Additional details and impacted files
@@                      Coverage Diff                       @@
##           alexreinking/rfactor-hoisting    #9387   +/-   ##
==============================================================
  Coverage                          70.06%   70.06%           
==============================================================
  Files                                261      261           
  Lines                              79471    79483   +12     
  Branches                           19379    19382    +3     
==============================================================
+ Hits                               55683    55693   +10     
+ Misses                             17913    17911    -2     
- Partials                            5875     5879    +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcourteaux
mcourteaux force-pushed the alexreinking/funcvecs branch from 1ebb1b7 to 8ed11d4 Compare August 26, 2026 07:20
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