25 class OutputImageParam;
47 const std::string &
name()
const {
77 std::vector<Var> dim_vars;
81 void split(
const std::string &old,
const std::string &outer,
const std::string &inner,
83 void remove(
const std::string &var);
86 const std::vector<Internal::StorageDim> &storage_dims()
const {
87 return function.schedule().storage_dims();
90 Stage &compute_with(
LoopLevel loop_level,
const std::map<std::string, LoopAlignStrategy> &align);
94 : function(
std::move(f)), definition(
std::move(d)), stage_index(stage_index) {
97 dim_vars.reserve(
function.args().size());
98 for (
const auto &arg :
function.args()) {
99 dim_vars.emplace_back(arg);
115 std::string
name()
const;
187 Func rfactor(std::vector<std::pair<RVar, Var>> preserved);
332 Stage &compute_with(
LoopLevel loop_level,
const std::vector<std::pair<VarOrRVar, LoopAlignStrategy>> &align);
334 Stage &compute_with(
const Stage &s,
const VarOrRVar &var,
const std::vector<std::pair<VarOrRVar, LoopAlignStrategy>> &align);
363 const Expr &xfactor,
const Expr &yfactor,
365 Stage &
tile(
const std::vector<VarOrRVar> &previous,
366 const std::vector<VarOrRVar> &outers,
367 const std::vector<VarOrRVar> &inners,
368 const std::vector<Expr> &factors,
369 const std::vector<TailStrategy> &tails);
370 Stage &
tile(
const std::vector<VarOrRVar> &previous,
371 const std::vector<VarOrRVar> &outers,
372 const std::vector<VarOrRVar> &inners,
373 const std::vector<Expr> &factors,
375 Stage &
tile(
const std::vector<VarOrRVar> &previous,
376 const std::vector<VarOrRVar> &inners,
377 const std::vector<Expr> &factors,
381 template<
typename... Args>
384 std::vector<VarOrRVar> collected_args{x, y, std::forward<Args>(args)...};
385 return reorder(collected_args);
388 template<
typename... Args>
391 std::vector<VarOrRVar> collected_args{x, std::forward<Args>(args)...};
395 template<
typename... Args>
398 std::vector<VarOrRVar> collected_args{x, std::forward<Args>(args)...};
436 const Expr &x_size,
const Expr &y_size,
442 const Expr &x_size,
const Expr &y_size,
449 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
454 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
459 Stage &
atomic(
bool override_associativity_test =
false);
470 return prefetch(image.parameter(), at, from, std::move(offset), strategy);
499 int implicit_placeholder_pos;
501 std::vector<Expr> args;
502 std::vector<Expr> args_with_implicit_vars(
const std::vector<Expr> &e)
const;
507 template<
typename BinaryOp>
508 Stage func_ref_update(
const Tuple &e,
int init_val);
513 template<
typename BinaryOp>
514 Stage func_ref_update(
Expr e,
int init_val);
518 int placeholder_pos = -1,
int count = 0);
520 int placeholder_pos = -1,
int count = 0);
582 operator Expr()
const;
618 std::vector<Expr> args;
623 Tuple values_with_undefs(
const Expr &e)
const;
672 operator Expr()
const;
717 std::pair<int, int> add_implicit_vars(std::vector<Var> &)
const;
718 std::pair<int, int> add_implicit_vars(std::vector<Expr> &)
const;
729 Func &reorder_storage(
const std::vector<Var> &dims,
size_t start);
731 void invalidate_cache();
735 explicit Func(
const std::string &
name);
741 explicit Func(
const Type &required_type,
int required_dims,
const std::string &
name);
748 explicit Func(
const std::vector<Type> &required_types,
int required_dims,
const std::string &
name);
764 template<
typename T,
int Dims>
839 Realization realize(std::vector<int32_t> sizes = {},
const Target &target = Target());
846 Realization
realize(JITUserContext *context,
847 std::vector<int32_t> sizes = {},
848 const Target &target = Target());
856 void realize(Pipeline::RealizationArg
outputs,
const Target &target = Target());
863 void realize(JITUserContext *context,
864 Pipeline::RealizationArg
outputs,
865 const Target &target = Target());
884 const std::vector<int32_t> &sizes,
887 Pipeline::RealizationArg
outputs,
895 void compile_to_bitcode(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
906 void compile_to_llvm_assembly(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
918 void compile_to_object(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
920 void compile_to_object(
const std::string &filename,
const std::vector<Argument> &,
931 void compile_to_header(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name =
"",
940 void compile_to_assembly(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
951 const std::vector<Argument> &,
952 const std::string &fn_name =
"",
959 const std::vector<Argument> &
args,
972 void compile_to_file(
const std::string &filename_prefix,
const std::vector<Argument> &
args,
973 const std::string &fn_name =
"",
981 const std::string &fn_name =
"",
992 const std::vector<Argument> &
args,
993 const std::vector<Target> &targets);
1009 const std::vector<Argument> &
args,
1010 const std::vector<Target> &targets,
1011 const std::vector<std::string> &suffixes);
1022 void compile_to(
const std::map<OutputFileType, std::string> &output_files,
1023 const std::vector<Argument> &
args,
1024 const std::string &fn_name,
1056 template<
typename T>
1097 const std::string &
name()
const;
1100 std::vector<Var>
args()
const;
1119 const std::vector<Expr> &
update_args(
int idx = 0)
const;
1135 std::vector<RVar>
rvars(
int idx = 0)
const;
1153 const std::vector<ExternFuncArgument> ¶ms,
Type t,
1163 const std::vector<ExternFuncArgument> ¶ms,
1164 const std::vector<Type> &
types,
int dimensionality,
1171 const std::vector<ExternFuncArgument> ¶ms,
1172 const std::vector<Type> &
types,
int dimensionality,
1181 const std::vector<ExternFuncArgument> ¶ms,
Type t,
1182 const std::vector<Var> &arguments,
1185 define_extern(function_name, params, std::vector<Type>{t}, arguments,
1186 mangling, device_api);
1190 const std::vector<ExternFuncArgument> ¶ms,
1191 const std::vector<Type> &
types,
1192 const std::vector<Var> &arguments,
1208 const std::vector<Type> &
types()
const;
1235 template<
typename... Args>
1238 std::vector<Var> collected_args{std::forward<Args>(
args)...};
1252 template<
typename... Args>
1255 std::vector<Expr> collected_args{x, std::forward<Args>(
args)...};
1256 return (*
this)(collected_args);
1352 Func in(
const std::vector<Func> &fs);
1477 template<
typename... Args>
1480 std::vector<VarOrRVar> collected_args{x, std::forward<Args>(
args)...};
1494 template<
typename... Args>
1497 std::vector<VarOrRVar> collected_args{x, std::forward<Args>(
args)...};
1564 const Expr &xfactor,
const Expr &yfactor,
1571 const Expr &xfactor,
const Expr &yfactor,
1575 Func &
tile(
const std::vector<VarOrRVar> &previous,
1576 const std::vector<VarOrRVar> &outers,
1577 const std::vector<VarOrRVar> &inners,
1578 const std::vector<Expr> &factors,
1579 const std::vector<TailStrategy> &tails);
1582 Func &
tile(
const std::vector<VarOrRVar> &previous,
1583 const std::vector<VarOrRVar> &outers,
1584 const std::vector<VarOrRVar> &inners,
1585 const std::vector<Expr> &factors,
1589 Func &
tile(
const std::vector<VarOrRVar> &previous,
1590 const std::vector<VarOrRVar> &inners,
1591 const std::vector<Expr> &factors,
1596 Func &
reorder(
const std::vector<VarOrRVar> &vars);
1598 template<
typename... Args>
1601 std::vector<VarOrRVar> collected_args{x, y, std::forward<Args>(
args)...};
1602 return reorder(collected_args);
1664 Func &
atomic(
bool override_associativity_test =
false);
1937 const Expr &x_size,
const Expr &y_size,
1943 const Expr &x_size,
const Expr &y_size,
1950 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
1955 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
2049 template<
typename T>
2052 return prefetch(image.parameter(), at, from, std::move(offset), strategy);
2071 Func &reorder_storage(
const std::vector<Var> &dims);
2073 Func &reorder_storage(
const Var &x,
const Var &y);
2074 template<
typename... Args>
2077 std::vector<Var> collected_args{x, y, std::forward<Args>(
args)...};
2078 return reorder_storage(collected_args);
2556 operator Stage()
const;
2591 namespace Internal {
2593 template<
typename Last>
2595 using T =
typename std::remove_pointer<typename std::remove_reference<Last>::type>::type;
2597 <<
"Can't evaluate expression " 2598 << t[idx] <<
" of type " << t[idx].type()
2599 <<
" as a scalar of type " << type_of<T>() <<
"\n";
2602 template<
typename First,
typename Second,
typename... Rest>
2604 check_types<First>(t, idx);
2608 template<
typename Last>
2610 using T =
typename std::remove_pointer<typename std::remove_reference<Last>::type>::type;
2614 template<
typename First,
typename Second,
typename... Rest>
2616 assign_results<First>(r, idx, first);
2625 template<
typename T>
2628 <<
"Can't evaluate expression " 2629 << e <<
" of type " << e.
type()
2630 <<
" as a scalar of type " << type_of<T>() <<
"\n";
2638 template<
typename T>
2640 return evaluate<T>(
nullptr, e);
2644 template<
typename First,
typename... Rest>
2655 template<
typename First,
typename... Rest>
2657 evaluate<First, Rest...>(
nullptr, std::move(t), std::forward<First>(first), std::forward<Rest...>(rest...));
2660 namespace Internal {
2679 template<
typename T>
2682 <<
"Can't evaluate expression " 2683 << e <<
" of type " << e.
type()
2684 <<
" as a scalar of type " << type_of<T>() <<
"\n";
2695 template<
typename First,
typename... Rest>
std::vector< Range > Region
A multi-dimensional box.
JITHandlers & jit_handlers()
Get a struct containing the currently set custom functions used by JIT.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< Var, Args... >::value, FuncRef >::type operator()(Args &&...args) const
Construct either the left-hand-side of a definition, or a call to a functions that happens to only co...
VarOrRVar(const ImplicitVar< N > &u)
Create a small array of Exprs for defining and calling functions with multiple outputs.
Stage & gpu_tile(const VarOrRVar &x, const VarOrRVar &bx, const VarOrRVar &tx, const Expr &x_size, TailStrategy tail=TailStrategy::Auto, DeviceAPI device_api=DeviceAPI::Default_GPU)
Scheduling calls that control how the domain of this stage is traversed.
Expr max(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
A reference to a site in a Halide statement at the top of the body of a particular for loop...
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< VarOrRVar, Args... >::value, Func & >::type always_partition(const VarOrRVar &x, Args &&...args)
Set the loop partition policy to Always for some number of Vars and RVars.
Expr update_value(int idx=0) const
Get the right-hand-side of an update definition.
A schedule for a single stage of a Halide pipeline.
static Var outermost()
A Var that represents the location outside the outermost loop.
Func & memoize(const EvictionKey &eviction_key=EvictionKey())
Use the halide_memoization_cache_...
Func & store_in(MemoryType memory_type)
Set the type of memory this Func should be stored in.
A fragment of Halide syntax.
FuncTupleElementRef operator[](int) const
When a FuncRef refers to a function that provides multiple outputs, you can access each output as an ...
Func & store_root()
Equivalent to Func::store_at, but schedules storage outside the outermost loop.
A class representing a Halide pipeline.
Stage operator*=(Expr)
Define a stage that multiplies this Func by the given expression.
Func clone_in(const Func &f)
Similar to Func::in; however, instead of replacing the call to this Func with an identity Func that r...
Target get_target_from_environment()
Return the target that Halide will use.
Func & tile(const VarOrRVar &x, const VarOrRVar &y, const VarOrRVar &xo, const VarOrRVar &yo, const VarOrRVar &xi, const VarOrRVar &yi, const Expr &xfactor, const Expr &yfactor, TailStrategy tail=TailStrategy::Auto)
Split two dimensions at once by the given factors, and then reorder the resulting dimensions to be xi...
std::string name() const
Return the name of this stage, e.g.
void debug_to_file(const std::string &filename)
When this function is compiled, include code that dumps its values to a file after it is realized...
std::vector< OutputImageParam > output_buffers() const
Schedule the iteration over the initial definition of this function to be fused with another stage 's...
Func & compute_inline()
Aggressively inline all uses of this function.
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
A Realization is a vector of references to existing Buffer objects.
Func & trace_stores()
Trace all stores to the buffer backing this Func by emitting calls to halide_trace.
Defines the front-end syntax for reduction domains and reduction variables.
void compile_to_object(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name, const Target &target=get_target_from_environment())
Statically compile this function to an object file, with the given filename (which should probably en...
const std::vector< Type > & types() const
Get the type(s) of the outputs of this Func.
int dimensions() const
The dimensionality (number of arguments) of this function.
Defines the front-end class representing an entire Halide imaging pipeline.
Partition
Different ways to handle loops with a potentially optimizable boundary conditions.
void compile_to_header(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name="", const Target &target=get_target_from_environment())
Emit a header file with the given filename for this function.
Stage & rename(const VarOrRVar &old_name, const VarOrRVar &new_name)
Scheduling calls that control how the domain of this stage is traversed.
bool has_feature(Feature f) const
Func & compute_root()
Compute all of this function once ahead of time.
Defines Module, an IR container that fully describes a Halide program.
const std::vector< CustomLoweringPass > & custom_lowering_passes()
Get the custom lowering passes.
TailStrategy
Different ways to handle a tail case in a split when the factor does not provably divide the extent...
const std::vector< Expr > & args() const
Get the default (no-specialization) arguments (left-hand-side) of the definition. ...
Func & trace_realizations()
Trace all realizations of this Func by emitting calls to halide_trace.
Func & rename(const VarOrRVar &old_name, const VarOrRVar &new_name)
Rename a dimension.
OutputImageParam output_buffer() const
Get a handle on the output buffer for this Func.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< VarOrRVar, Args... >::value, Stage & >::type reorder(const VarOrRVar &x, const VarOrRVar &y, Args &&...args)
Scheduling calls that control how the domain of this stage is traversed.
A struct representing a target machine and os to generate code for.
Stage operator*=(const Expr &e)
Define a stage that multiplies Tuple component 'idx' of this Func by the given expression.
Func & unroll(const VarOrRVar &var)
Mark a dimension to be completely unrolled.
Func & bound(const Var &var, Expr min, Expr extent)
Statically declare that the range over which a function should be evaluated is given by the second an...
A reference-counted handle to a parameter to a halide pipeline.
Stage & serial(const VarOrRVar &var)
Scheduling calls that control how the domain of this stage is traversed.
#define internal_assert(c)
Stage & gpu_threads(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Scheduling calls that control how the domain of this stage is traversed.
Func & gpu_single_thread(DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide to run this stage using a single gpu thread and block.
A Halide variable, to be used when defining functions.
const std::string & name() const
void print_loop_nest()
Write out the loop nests specified by the schedule for this Function.
bool defined() const
Does this function have at least a pure definition.
Func & atomic(bool override_associativity_test=false)
Issue atomic updates for this Func.
Func & align_storage(const Var &dim, const Expr &alignment)
Pad the storage extent of a particular dimension of realizations of this function up to be a multiple...
std::vector< Var > make_argument_list(int dimensionality)
Make a list of unique arguments for definitions with unnamed arguments.
Callable compile_to_callable(const std::vector< Argument > &args, const Target &target=get_jit_target_from_environment())
Eagerly jit compile the function to machine code and return a callable struct that behaves like a fun...
A fragment of front-end syntax of the form f(x, y, z), where x, y, z are Vars or Exprs.
A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer.
Func & align_extent(const Var &var, Expr modulus)
Expand the region computed so that the extent is a multiple of 'modulus'.
const Internal::StageSchedule & get_schedule() const
Return the current StageSchedule associated with this initial Stage of this Func. ...
Func & gpu_threads(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide that the following dimensions correspond to GPU thread indices.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.
Stage(Internal::Function f, Internal::Definition d, size_t stage_index)
int index() const
Return index to the function outputs.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< VarOrRVar, Args... >::value, Stage & >::type never_partition(const VarOrRVar &x, Args &&...args)
Scheduling calls that control how the domain of this stage is traversed.
Stage operator+=(Expr)
Define a stage that adds the given expression to this Func.
Stage operator=(const Expr &)
Use this as the left-hand-side of a definition or an update definition (see RDom).
Stage & unroll(const VarOrRVar &var)
Scheduling calls that control how the domain of this stage is traversed.
bool has_update_definition() const
Does this function have at least one update definition?
A class that can represent Vars or RVars.
size_t size() const
How many outputs does the function this refers to produce.
Defines the structure that describes a Halide target.
std::vector< Var > args() const
Get the pure arguments.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< Var, Args... >::value, Func & >::type reorder_storage(const Var &x, const Var &y, Args &&...args)
Specify how the storage for the function is laid out.
Stage & prefetch(const T &image, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
Scheduling calls that control how the domain of this stage is traversed.
Func & always_partition_all()
Set the loop partition policy to Always for all Vars and RVar of the initial definition of the Func...
Tuple update_values(int idx=0) const
Get the right-hand-side of an update definition for functions that returns multiple values...
Func & allow_race_conditions()
Specify that race conditions are permitted for this Func, which enables parallelizing over RVars even...
void unscheduled()
Assert that this stage has intentionally been given no schedule, and suppress the warning about unsch...
Internal::Function function() const
What function is this calling?
void specialize_fail(const std::string &message)
Add a specialization to a Func that always terminates execution with a call to halide_error().
A fragment of front-end syntax of the form f(x, y, z)[index], where x, y, z are Vars or Exprs...
Func & trace_loads()
Trace all loads from this Func by emitting calls to halide_trace.
int num_update_definitions() const
How many update definitions does this function have?
void define_extern(const std::string &function_name, const std::vector< ExternFuncArgument > ¶ms, Type t, const std::vector< Var > &arguments, NameMangling mangling=NameMangling::Default, DeviceAPI device_api=DeviceAPI::Host)
Add an extern definition for this Func.
std::string dump_argument_list() const
Return a string describing the current var list taking into account all the splits, reorders, and tiles.
Defines the struct representing lifetime and dependencies of a JIT compiled halide pipeline...
Stage & hexagon(const VarOrRVar &x=Var::outermost())
Scheduling calls that control how the domain of this stage is traversed.
Stage & vectorize(const VarOrRVar &var)
Scheduling calls that control how the domain of this stage is traversed.
Func rfactor(std::vector< std::pair< RVar, Var >> preserved)
Calling rfactor() on an associative update definition a Func will split the update into an intermedia...
const std::vector< Expr > & update_args(int idx=0) const
Get the left-hand-side of the update definition.
Used to denote for loops that run on the same device as the containing code.
LoopAlignStrategy
Different ways to handle the case when the start/end of the loops of stages computed with (fused) are...
FuncRef(const Internal::Function &, const std::vector< Expr > &, int placeholder_pos=-1, int count=0)
Guard the prefetch with if-guards that ignores the prefetch if any of the prefetched region ever goes...
Func & never_partition(const std::vector< VarOrRVar > &vars)
Set the loop partition policy to Never for a vector of Vars and RVars.
Func & never_partition_all()
Set the loop partition policy to Never for all Vars and RVar of the initial definition of the Func...
Func & prefetch(const T &image, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
Prefetch data written to or read from a Func or an ImageParam by a subsequent loop iteration...
Func & split(const VarOrRVar &old, const VarOrRVar &outer, const VarOrRVar &inner, const Expr &factor, TailStrategy tail=TailStrategy::Auto)
Split a dimension into inner and outer subdimensions with the given names, where the inner dimension ...
Func & gpu(const VarOrRVar &block_x, const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide that the following dimensions correspond to GPU block indices and thread indices...
Func in()
Create and return a global identity wrapper, which wraps all calls to this Func by any other Func...
void define_extern(const std::string &function_name, const std::vector< ExternFuncArgument > ¶ms, const std::vector< Type > &types, int dimensionality, NameMangling mangling=NameMangling::Default, DeviceAPI device_api=DeviceAPI::Host)
Add an extern definition for this Func.
HALIDE_ALWAYS_INLINE Type type() const
Get the type of this expression node.
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt) ...
const std::string & name() const
Get the name of a Var.
void compile_to(const std::map< OutputFileType, std::string > &output_files, const std::vector< Argument > &args, const std::string &fn_name, const Target &target=get_target_from_environment())
Compile and generate multiple target files with single call.
Stage & always_partition(const std::vector< VarOrRVar > &vars)
Scheduling calls that control how the domain of this stage is traversed.
void compile_jit(const Target &target=get_jit_target_from_environment())
Eagerly jit compile the function to machine code.
void check_types(const Tuple &t, int idx)
Func & compute_with(const Stage &s, const VarOrRVar &var, const std::vector< std::pair< VarOrRVar, LoopAlignStrategy >> &align)
Schedule the iteration over the initial definition of this function to be fused with another stage 's...
std::vector< RVar > rvars(int idx=0) const
Get the RVars of the reduction domain for an update definition, if there is one.
void compile_to_c(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name="", const Target &target=get_target_from_environment())
Statically compile this function to C source code.
Match whatever is specified in the Target.
Func()
Declare a new undefined function with an automatically-generated unique name.
Stage specialize(const Expr &condition)
Specialize a Func.
A handle on the output buffer of a pipeline.
Classes for declaring scalar parameters to halide pipelines.
Stage & never_partition_all()
Scheduling calls that control how the domain of this stage is traversed.
Stage specialize(const Expr &condition)
Scheduling calls that control how the domain of this stage is traversed.
Let Halide select a storage type automatically.
Func copy_to_device(DeviceAPI d=DeviceAPI::Default_GPU)
Declare that this function should be implemented by a call to halide_buffer_copy with the given targe...
void schedule_scalar(Func f)
Stage & gpu(const VarOrRVar &block_x, const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Scheduling calls that control how the domain of this stage is traversed.
#define HALIDE_NO_USER_CODE_INLINE
Not visible externally, similar to 'static' linkage in C.
void assign_results(Realization &r, int idx, Last last)
bool has_gpu_feature() const
Is a fully feature GPU compute runtime enabled? I.e.
Stage & partition(const VarOrRVar &var, Partition partition_policy)
Scheduling calls that control how the domain of this stage is traversed.
const std::string & name() const
The name of this function, either given during construction, or automatically generated.
Func & gpu_blocks(const VarOrRVar &block_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide that the following dimensions correspond to GPU block indices.
Func & reorder(const std::vector< VarOrRVar > &vars)
Reorder variables to have the given nesting order, from innermost out.
Stage operator-=(Expr)
Define a stage that adds the negative of the given expression to this Func.
void compile_to_lowered_stmt(const std::string &filename, const std::vector< Argument > &args, StmtOutputFormat fmt=Text, const Target &target=get_target_from_environment())
Write out an internal representation of lowered code.
Stage operator/=(const Expr &e)
Define a stage that divides Tuple component 'idx' of this Func by the given expression.
Func & gpu_tile(const VarOrRVar &x, const VarOrRVar &bx, const VarOrRVar &tx, const Expr &x_size, TailStrategy tail=TailStrategy::Auto, DeviceAPI device_api=DeviceAPI::Default_GPU)
Short-hand for tiling a domain and mapping the tile indices to GPU block indices and the coordinates ...
Func & hexagon(const VarOrRVar &x=Var::outermost())
Schedule for execution on Hexagon.
FuncTupleElementRef(const FuncRef &ref, const std::vector< Expr > &args, int idx)
PrefetchBoundStrategy
Different ways to handle accesses outside the original extents in a prefetch.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< VarOrRVar, Args... >::value, Stage & >::type always_partition(const VarOrRVar &x, Args &&...args)
Scheduling calls that control how the domain of this stage is traversed.
bool defined() const
Definition objects are nullable.
HALIDE_NO_USER_CODE_INLINE Func(Buffer< T, Dims > &im)
Construct a new Func to wrap a Buffer.
ForType
An enum describing a type of loop traversal.
Func & bound_storage(const Var &dim, const Expr &bound)
Bound the extent of a Func's storage, but not extent of its compute.
const StageSchedule & schedule() const
Get the default (no-specialization) stage-specific schedule associated with this definition.
Stage & allow_race_conditions()
Scheduling calls that control how the domain of this stage is traversed.
Tuple values() const
The values returned by this function.
const Type & type() const
Get the type(s) of the outputs of this Func.
Stage & always_partition_all()
Scheduling calls that control how the domain of this stage is traversed.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< VarOrRVar, Args... >::value, Func & >::type never_partition(const VarOrRVar &x, Args &&...args)
Set the loop partition policy to Never for some number of Vars and RVars.
Func & fold_storage(const Var &dim, const Expr &extent, bool fold_forward=true)
Store realizations of this function in a circular buffer of a given extent.
Defines the Var - the front-end variable.
Func & compute_at(const Func &f, const Var &var)
Compute this function as needed for each unique value of the given var for the given calling function...
Func & align_bounds(const Var &var, Expr modulus, Expr remainder=0)
Expand the region computed so that the min coordinates is congruent to 'remainder' modulo 'modulus'...
Stage & gpu_single_thread(DeviceAPI device_api=DeviceAPI::Default_GPU)
Scheduling calls that control how the domain of this stage is traversed.
Func & set_estimates(const Region &estimates)
Set (min, extent) estimates for all dimensions in the Func at once; this is equivalent to calling set...
A context to be passed to Pipeline::realize.
Defines a type used for expressing the type signature of a generated halide pipeline.
Stage & never_partition(const std::vector< VarOrRVar > &vars)
Scheduling calls that control how the domain of this stage is traversed.
A reference-counted handle to Halide's internal representation of a function.
void compile_to_llvm_assembly(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name, const Target &target=get_target_from_environment())
Statically compile this function to llvm assembly, with the given filename (which should probably end...
Func & fuse(const VarOrRVar &inner, const VarOrRVar &outer, const VarOrRVar &fused)
Join two dimensions into a single fused dimension.
An Image parameter to a halide pipeline.
FuncRef operator()(std::vector< Var >) const
Construct either the left-hand-side of a definition, or a call to a functions that happens to only co...
An argument to an extern-defined Func.
void clear_custom_lowering_passes()
Remove all previously-set custom lowering passes.
Func & always_partition(const std::vector< VarOrRVar > &vars)
Set the loop partition policy to Always for a vector of Vars and RVars.
Types in the halide type system.
void infer_input_bounds(const std::vector< int32_t > &sizes, const Target &target=get_jit_target_from_environment())
For a given size of output, or a given output buffer, determine the bounds required of all unbound Im...
Stage operator-=(const Expr &e)
Define a stage that adds the negative of the given expression to Tuple component 'idx' of this Func...
Func & hoist_storage(const Func &f, const Var &var)
Hoist storage for this function within f's loop over var.
Func & store_at(const Func &f, const Var &var)
Allocate storage for this function within f's loop over var.
EvictionKey(const Expr &expr=Expr())
NameMangling
An enum to specify calling convention for extern stages.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< Expr, Args... >::value, FuncRef >::type operator()(const Expr &x, Args &&...args) const
Either calls to the function, or the left-hand-side of an update definition (see RDom).
Func & vectorize(const VarOrRVar &var)
Mark a dimension to be computed all-at-once as a single vector.
A Function definition which can either represent a init or an update definition.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< VarOrRVar, Args... >::value, Func & >::type reorder(const VarOrRVar &x, const VarOrRVar &y, Args &&...args)
void define_extern(const std::string &function_name, const std::vector< ExternFuncArgument > ¶ms, const std::vector< Type > &types, int dimensionality, NameMangling mangling)
Add an extern definition for this Func.
Stage & gpu_lanes(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Scheduling calls that control how the domain of this stage is traversed.
Helper class for identifying purpose of an Expr passed to memoize.
Stage operator+=(const Expr &e)
Define a stage that adds the given expression to Tuple component 'idx' of this Func.
const std::string & name() const
The name of this reduction variable.
void add_custom_lowering_pass(T *pass)
Add a custom pass to be used during lowering.
void compile_to_bitcode(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name, const Target &target=get_target_from_environment())
Statically compile this function to llvm bitcode, with the given filename (which should probably end ...
Expr value() const
The right-hand-side value of the pure definition of this function.
Stage & atomic(bool override_associativity_test=false)
Scheduling calls that control how the domain of this stage is traversed.
Stage operator/=(Expr)
Define a stage that divides this Func by the given expression.
A single definition of a Func.
Target get_jit_target_from_environment()
Return the target that Halide will use for jit-compilation.
Stage & parallel(const VarOrRVar &var)
Scheduling calls that control how the domain of this stage is traversed.
int outputs() const
Get the number of outputs of this Func.
Stage & tile(const VarOrRVar &x, const VarOrRVar &y, const VarOrRVar &xo, const VarOrRVar &yo, const VarOrRVar &xi, const VarOrRVar &yi, const Expr &xfactor, const Expr &yfactor, TailStrategy tail=TailStrategy::Auto)
Scheduling calls that control how the domain of this stage is traversed.
A reduction variable represents a single dimension of a reduction domain (RDom).
A multi-dimensional domain over which to iterate.
std::string source_location() const
Get the source location of the pure definition of this Func.
Func & serial(const VarOrRVar &var)
Mark a dimension to be traversed serially.
HALIDE_NO_USER_CODE_INLINE T evaluate_may_gpu(const Expr &e)
JIT-Compile and run enough code to evaluate a Halide expression.
Func & add_trace_tag(const std::string &trace_tag)
Add a string of arbitrary text that will be passed thru to trace inspection code if the Func is reali...
void define_extern(const std::string &function_name, const std::vector< ExternFuncArgument > ¶ms, Type t, int dimensionality, NameMangling mangling=NameMangling::Default, DeviceAPI device_api=DeviceAPI::Host)
Add an extern definition for this Func.
A base class for passes over the IR which modify it (e.g.
Func & gpu_lanes(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
The given dimension corresponds to the lanes in a GPU warp.
HALIDE_NO_USER_CODE_INLINE T evaluate(JITUserContext *ctx, const Expr &e)
JIT-Compile and run enough code to evaluate a Halide expression.
Module compile_to_module(const std::vector< Argument > &args, const std::string &fn_name="", const Target &target=get_target_from_environment())
Store an internal representation of lowered code as a self contained Module suitable for further comp...
void compile_to_multitarget_static_library(const std::string &filename_prefix, const std::vector< Argument > &args, const std::vector< Target > &targets)
Compile to static-library file and header pair once for each target; each resulting function will be ...
Func & partition(const VarOrRVar &var, Partition partition_policy)
Set the loop partition policy.
void specialize_fail(const std::string &message)
Scheduling calls that control how the domain of this stage is traversed.
void compile_to_multitarget_object_files(const std::string &filename_prefix, const std::vector< Argument > &args, const std::vector< Target > &targets, const std::vector< std::string > &suffixes)
Like compile_to_multitarget_static_library(), except that the object files are all output as object f...
DeviceAPI
An enum describing a type of device API.
Func copy_to_host()
Declare that this function should be implemented by a call to halide_buffer_copy with a NULL target d...
VarOrRVar(const std::string &n, bool r)
const Internal::StageSchedule & get_schedule() const
Return the current StageSchedule associated with this Stage.
Stage & fuse(const VarOrRVar &inner, const VarOrRVar &outer, const VarOrRVar &fused)
Scheduling calls that control how the domain of this stage is traversed.
Defines Tuple - the front-end handle on small arrays of expressions.
Stage & prefetch(const Func &f, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
Scheduling calls that control how the domain of this stage is traversed.
std::vector< Argument > infer_arguments() const
Infer the arguments to the Func, sorted into a canonical order: all buffers (sorted alphabetically by...
Func & hoist_storage_root()
Equivalent to Func::hoist_storage_root, but schedules storage outside the outermost loop...
Stage & gpu_blocks(const VarOrRVar &block_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Scheduling calls that control how the domain of this stage is traversed.
Func & async()
Produce this Func asynchronously in a separate thread.
Stage update(int idx=0)
Get a handle on an update step for the purposes of scheduling it.
void compile_to_assembly(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name, const Target &target=get_target_from_environment())
Statically compile this function to text assembly equivalent to the object file generated by compile_...
Func & set_estimate(const Var &var, const Expr &min, const Expr &extent)
Statically declare the range over which the function will be evaluated in the general case...
Realization realize(std::vector< int32_t > sizes={}, const Target &target=Target())
Evaluate this function over some rectangular domain and return the resulting buffer or buffers...
void compile_to_file(const std::string &filename_prefix, const std::vector< Argument > &args, const std::string &fn_name="", const Target &target=get_target_from_environment())
Compile to object file and header pair, with the given arguments.
Func & bound_extent(const Var &var, Expr extent)
Bound the extent of a Func's realization, but not its min.
std::string source_location() const
Attempt to get the source file and line where this stage was defined by parsing the process's own deb...
Func & prefetch(const Func &f, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
Prefetch data written to or read from a Func or an ImageParam by a subsequent loop iteration...
void compile_to_static_library(const std::string &filename_prefix, const std::vector< Argument > &args, const std::string &fn_name="", const Target &target=get_target_from_environment())
Compile to static-library file and header pair, with the given arguments.
Stage & reorder(const std::vector< VarOrRVar > &vars)
Scheduling calls that control how the domain of this stage is traversed.
Func & parallel(const VarOrRVar &var)
Mark a dimension to be traversed in parallel.
bool is_extern() const
Is this function an external stage? That is, was it defined using define_extern?
const std::string & extern_function_name() const
Get the name of the extern function called for an extern definition.
Stage operator=(const Expr &e)
Use this as the left-hand-side of an update definition of Tuple component 'idx' of a Func (see RDom)...
StmtOutputFormat
Used to determine if the output printed to file should be as a normal string or as an HTML file which...
MemoryType
An enum describing different address spaces to be used with Func::store_in.