Halide
12.0.1
Halide compiler and libraries
|
ValueTracker is an internal utility class that attempts to track and flag certain obvious Stub-related errors at Halide compile time: it tracks the constraints set on any Parameter-based argument (i.e., Input<Buffer> and Output<Buffer>) to ensure that incompatible values aren't set. More...
#include <Generator.h>
Public Member Functions | |
ValueTracker (size_t max_unique_values=2) | |
void | track_values (const std::string &name, const std::vector< Expr > &values) |
ValueTracker is an internal utility class that attempts to track and flag certain obvious Stub-related errors at Halide compile time: it tracks the constraints set on any Parameter-based argument (i.e., Input<Buffer> and Output<Buffer>) to ensure that incompatible values aren't set.
e.g.: if a Generator A requires stride[0] == 1, and Generator B uses Generator A via stub, but requires stride[0] == 4, we should be able to detect this at Halide compilation time, and fail immediately, rather than producing code that fails at runtime and/or runs slowly due to vectorization being unavailable.
We do this by tracking the active values at entrance and exit to all user-provided Generator methods (build()/generate()/schedule()); if we ever find more than two unique values active, we know we have a potential conflict. ("two" here because the first value is the default value for a given constraint.)
Note that this won't catch all cases: – JIT compilation has no way to check for conflicts at the top-level – constraints that match the default value (e.g. if dim(0).set_stride(1) is the first value seen by the tracker) will be ignored, so an explicit requirement set this way can be missed
Nevertheless, this is likely to be much better than nothing when composing multiple layers of Stubs in a single fused result.
Definition at line 316 of file Generator.h.
|
inlineexplicit |
Definition at line 322 of file Generator.h.
void Halide::Internal::ValueTracker::track_values | ( | const std::string & | name, |
const std::vector< Expr > & | values | ||
) |