Go to the documentation of this file.
25 class OutputImageParam;
48 const std::string &
name()
const {
78 std::vector<Var> dim_vars;
82 void split(
const std::string &old,
const std::string &outer,
const std::string &inner,
84 void remove(
const std::string &var);
87 const std::vector<Internal::StorageDim> &storage_dims()
const {
88 return function.schedule().storage_dims();
91 Stage &compute_with(
LoopLevel loop_level,
const std::map<std::string, LoopAlignStrategy> &align);
95 : function(std::move(f)), definition(std::move(d)), stage_index(stage_index) {
98 dim_vars.reserve(
function.args().size());
99 for (
const auto &arg :
function.args()) {
100 dim_vars.emplace_back(arg);
116 std::string
name()
const;
188 Func rfactor(std::vector<std::pair<RVar, Var>> preserved);
333 Stage &compute_with(
LoopLevel loop_level,
const std::vector<std::pair<VarOrRVar, LoopAlignStrategy>> &align);
335 Stage &compute_with(
const Stage &s,
const VarOrRVar &var,
const std::vector<std::pair<VarOrRVar, LoopAlignStrategy>> &align);
358 const Expr &xfactor,
const Expr &yfactor,
360 Stage &
tile(
const std::vector<VarOrRVar> &previous,
361 const std::vector<VarOrRVar> &outers,
362 const std::vector<VarOrRVar> &inners,
363 const std::vector<Expr> &factors,
364 const std::vector<TailStrategy> &tails);
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,
370 Stage &
tile(
const std::vector<VarOrRVar> &previous,
371 const std::vector<VarOrRVar> &inners,
372 const std::vector<Expr> &factors,
376 template<
typename... Args>
379 std::vector<VarOrRVar> collected_args{x, y, std::forward<Args>(args)...};
380 return reorder(collected_args);
417 const Expr &x_size,
const Expr &y_size,
423 const Expr &x_size,
const Expr &y_size,
430 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
435 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
440 Stage &
atomic(
bool override_associativity_test =
false);
451 return prefetch(image.parameter(), at, from, std::move(offset), strategy);
480 int implicit_placeholder_pos;
482 std::vector<Expr> args;
483 std::vector<Expr> args_with_implicit_vars(
const std::vector<Expr> &e)
const;
488 template<
typename BinaryOp>
489 Stage func_ref_update(
const Tuple &e,
int init_val);
494 template<
typename BinaryOp>
495 Stage func_ref_update(
Expr e,
int init_val);
499 int placeholder_pos = -1,
int count = 0);
501 int placeholder_pos = -1,
int count = 0);
563 operator Expr()
const;
599 std::vector<Expr> args;
604 Tuple values_with_undefs(
const Expr &e)
const;
653 operator Expr()
const;
698 std::pair<int, int> add_implicit_vars(std::vector<Var> &)
const;
699 std::pair<int, int> add_implicit_vars(std::vector<Expr> &)
const;
710 Func &reorder_storage(
const std::vector<Var> &dims,
size_t start);
712 void invalidate_cache();
716 explicit Func(
const std::string &
name);
722 explicit Func(
const Type &required_type,
int required_dims,
const std::string &
name);
729 explicit Func(
const std::vector<Type> &required_types,
int required_dims,
const std::string &
name);
745 template<
typename T,
int Dims>
841 Realization
realize(JITUserContext *context,
842 std::vector<int32_t> sizes = {},
843 const Target &target = Target(),
852 void realize(Pipeline::RealizationArg
outputs,
const Target &target = Target(),
860 void realize(JITUserContext *context,
861 Pipeline::RealizationArg
outputs,
862 const Target &target = Target(),
901 const std::vector<int32_t> &sizes,
905 Pipeline::RealizationArg
outputs,
914 void compile_to_bitcode(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
925 void compile_to_llvm_assembly(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
937 void compile_to_object(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
939 void compile_to_object(
const std::string &filename,
const std::vector<Argument> &,
950 void compile_to_header(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name =
"",
959 void compile_to_assembly(
const std::string &filename,
const std::vector<Argument> &,
const std::string &fn_name,
970 const std::vector<Argument> &,
971 const std::string &fn_name =
"",
978 const std::vector<Argument> &
args,
991 void compile_to_file(
const std::string &filename_prefix,
const std::vector<Argument> &
args,
992 const std::string &fn_name =
"",
1000 const std::string &fn_name =
"",
1011 const std::vector<Argument> &
args,
1012 const std::vector<Target> &targets);
1028 const std::vector<Argument> &
args,
1029 const std::vector<Target> &targets,
1030 const std::vector<std::string> &suffixes);
1041 void compile_to(
const std::map<OutputFileType, std::string> &output_files,
1042 const std::vector<Argument> &
args,
1043 const std::string &fn_name,
1075 template<
typename T>
1116 const std::string &
name()
const;
1119 std::vector<Var>
args()
const;
1138 const std::vector<Expr> &
update_args(
int idx = 0)
const;
1154 std::vector<RVar>
rvars(
int idx = 0)
const;
1172 const std::vector<ExternFuncArgument> ¶ms,
Type t,
1182 const std::vector<ExternFuncArgument> ¶ms,
1183 const std::vector<Type> &
types,
int dimensionality,
1190 const std::vector<ExternFuncArgument> ¶ms,
1191 const std::vector<Type> &
types,
int dimensionality,
1200 const std::vector<ExternFuncArgument> ¶ms,
Type t,
1201 const std::vector<Var> &arguments,
1204 define_extern(function_name, params, std::vector<Type>{t}, arguments,
1205 mangling, device_api);
1209 const std::vector<ExternFuncArgument> ¶ms,
1210 const std::vector<Type> &
types,
1211 const std::vector<Var> &arguments,
1227 const std::vector<Type> &
types()
const;
1254 template<
typename... Args>
1257 std::vector<Var> collected_args{std::forward<Args>(
args)...};
1271 template<
typename... Args>
1274 std::vector<Expr> collected_args{x, std::forward<Args>(
args)...};
1275 return (*
this)(collected_args);
1371 Func in(
const std::vector<Func> &fs);
1541 const Expr &xfactor,
const Expr &yfactor,
1548 const Expr &xfactor,
const Expr &yfactor,
1552 Func &
tile(
const std::vector<VarOrRVar> &previous,
1553 const std::vector<VarOrRVar> &outers,
1554 const std::vector<VarOrRVar> &inners,
1555 const std::vector<Expr> &factors,
1556 const std::vector<TailStrategy> &tails);
1559 Func &
tile(
const std::vector<VarOrRVar> &previous,
1560 const std::vector<VarOrRVar> &outers,
1561 const std::vector<VarOrRVar> &inners,
1562 const std::vector<Expr> &factors,
1566 Func &
tile(
const std::vector<VarOrRVar> &previous,
1567 const std::vector<VarOrRVar> &inners,
1568 const std::vector<Expr> &factors,
1573 Func &
reorder(
const std::vector<VarOrRVar> &vars);
1575 template<
typename... Args>
1578 std::vector<VarOrRVar> collected_args{x, y, std::forward<Args>(
args)...};
1579 return reorder(collected_args);
1641 Func &
atomic(
bool override_associativity_test =
false);
1914 const Expr &x_size,
const Expr &y_size,
1920 const Expr &x_size,
const Expr &y_size,
1927 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
1932 const Expr &x_size,
const Expr &y_size,
const Expr &z_size,
2026 template<
typename T>
2029 return prefetch(image.parameter(), at, from, std::move(offset), strategy);
2048 Func &reorder_storage(
const std::vector<Var> &dims);
2050 Func &reorder_storage(
const Var &x,
const Var &y);
2051 template<
typename... Args>
2054 std::vector<Var> collected_args{x, y, std::forward<Args>(
args)...};
2055 return reorder_storage(collected_args);
2444 operator Stage()
const;
2479 namespace Internal {
2481 template<
typename Last>
2483 using T =
typename std::remove_pointer<typename std::remove_reference<Last>::type>::type;
2485 <<
"Can't evaluate expression "
2486 << t[idx] <<
" of type " << t[idx].type()
2487 <<
" as a scalar of type " << type_of<T>() <<
"\n";
2490 template<
typename First,
typename Second,
typename... Rest>
2492 check_types<First>(t, idx);
2496 template<
typename Last>
2498 using T =
typename std::remove_pointer<typename std::remove_reference<Last>::type>::type;
2502 template<
typename First,
typename Second,
typename... Rest>
2504 assign_results<First>(r, idx, first);
2513 template<
typename T>
2516 <<
"Can't evaluate expression "
2517 << e <<
" of type " << e.
type()
2518 <<
" as a scalar of type " << type_of<T>() <<
"\n";
2526 template<
typename T>
2528 return evaluate<T>(
nullptr, e);
2532 template<
typename First,
typename... Rest>
2543 template<
typename First,
typename... Rest>
2545 evaluate<First, Rest...>(
nullptr, std::move(t), std::forward<First>(first), std::forward<Rest...>(rest...));
2548 namespace Internal {
2567 template<
typename T>
2570 <<
"Can't evaluate expression "
2571 << e <<
" of type " << e.
type()
2572 <<
" as a scalar of type " << type_of<T>() <<
"\n";
2583 template<
typename First,
typename... Rest>
Stage & fuse(const VarOrRVar &inner, const VarOrRVar &outer, const VarOrRVar &fused)
Stage & gpu_blocks(const VarOrRVar &block_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
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...
Stage & parallel(const VarOrRVar &var)
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...
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)
void compile_jit(const Target &target=get_jit_target_from_environment())
Eagerly jit compile the function to machine code.
const std::string & name() const
std::vector< RVar > rvars(int idx=0) const
Get the RVars of the reduction domain for an update definition, if there is one.
bool has_feature(Feature f) const
Func()
Declare a new undefined function with an automatically-generated unique name.
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.
const std::string & name() const
The name of this function, either given during construction, or automatically generated.
Stage & reorder(const std::vector< VarOrRVar > &vars)
Stage specialize(const Expr &condition)
Specialize a Func.
Func & gpu_blocks(const VarOrRVar &block_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide that the following dimensions correspond to GPU block indices.
#define internal_assert(c)
std::vector< Range > Region
A multi-dimensional box.
A Halide variable, to be used when defining functions.
std::string name() const
Return the name of this stage, e.g.
Stage operator/=(const Expr &e)
Define a stage that divides Tuple component 'idx' of this Func by the given expression.
HALIDE_NO_USER_CODE_INLINE T evaluate(JITUserContext *ctx, const Expr &e)
JIT-Compile and run enough code to evaluate a Halide 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 ...
FuncTupleElementRef(const FuncRef &ref, const std::vector< Expr > &args, int idx)
HALIDE_NO_USER_CODE_INLINE Func(Buffer< T, Dims > &im)
Construct a new Func to wrap a Buffer.
A reference-counted handle to a parameter to a halide pipeline.
@ Host
Used to denote for loops that run on the same device as the containing code.
Tuple values() const
The values returned by this 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 & serial(const VarOrRVar &var)
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 & gpu_threads(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Func & reorder(const std::vector< VarOrRVar > &vars)
Reorder variables to have the given nesting order, from innermost out.
Expr min(const FuncRef &a, const FuncRef &b)
Explicit overloads of min and max for FuncRef.
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...
StmtOutputFormat
Used to determine if the output printed to file should be as a normal string or as an HTML file which...
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)
FuncTupleElementRef operator[](int) const
When a FuncRef refers to a function that provides multiple outputs, you can access each output as an ...
Func & hexagon(const VarOrRVar &x=Var::outermost())
Schedule for execution on Hexagon.
ForType
An enum describing a type of loop traversal.
size_t size() const
How many outputs does the function this refers to produce.
Stage & rename(const VarOrRVar &old_name, const VarOrRVar &new_name)
const Type & type() const
Get the type(s) of the outputs of this Func.
Func & store_at(const Func &f, const Var &var)
Allocate storage for this function within f's loop over var.
Func & bound_storage(const Var &dim, const Expr &bound)
Bound the extent of a Func's storage, but not extent of its compute.
An Image parameter to a halide pipeline.
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< Expr, Args... >::value, FuncRef >::type operator()(const Expr &x, Args &&...args) const
Func & vectorize(const VarOrRVar &var)
Mark a dimension to be computed all-at-once as a single vector.
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.
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)
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 & set_estimates(const Region &estimates)
Set (min, extent) estimates for all dimensions in the Func at once; this is equivalent to calling set...
LoopAlignStrategy
Different ways to handle the case when the start/end of the loops of stages computed with (fused) are...
Internal::Function function() const
What function is this calling?
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...
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 ...
Stage operator+=(const Expr &e)
Define a stage that adds the given expression to Tuple component 'idx' of this Func.
void add_custom_lowering_pass(T *pass)
Add a custom pass to be used during lowering.
@ GuardWithIf
Guard the prefetch with if-guards that ignores the prefetch if any of the prefetched region ever goes...
Target get_target_from_environment()
Return the target that Halide will use.
bool has_gpu_feature() const
Is a fully feature GPU compute runtime enabled? I.e.
@ Default
Match whatever is specified in the Target.
static Var outermost()
A Var that represents the location outside the outermost loop.
Func & fuse(const VarOrRVar &inner, const VarOrRVar &outer, const VarOrRVar &fused)
Join two dimensions into a single fused dimension.
void clear_custom_lowering_passes()
Remove all previously-set custom lowering passes.
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...
Realization realize(std::vector< int32_t > sizes={}, const Target &target=Target(), const ParamMap ¶m_map=ParamMap::empty_map())
Evaluate this function over some rectangular domain and return the resulting buffer or buffers.
Stage & prefetch(const T &image, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
A Function definition which can either represent a init or an update definition.
FuncRef(const Internal::Function &, const std::vector< Expr > &, int placeholder_pos=-1, int count=0)
Stage operator-=(const Expr &e)
Define a stage that adds the negative of the given expression to Tuple component 'idx' of this Func.
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 unscheduled()
Assert that this stage has intentionally been given no schedule, and suppress the warning about unsch...
TailStrategy
Different ways to handle a tail case in a split when the factor does not provably divide the extent.
Stage operator+=(Expr)
Define a stage that adds the given expression to this Func.
A context to be passed to Pipeline::realize.
Types in the halide type system.
void define_extern(const std::string &function_name, const std::vector< ExternFuncArgument > ¶ms, const std::vector< Type > &types, int dimensionality, NameMangling mangling)
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)
A class representing a Halide pipeline.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
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 ...
Expr value() const
The right-hand-side value of the pure definition of this function.
An argument to an extern-defined Func.
Func copy_to_host()
Declare that this function should be implemented by a call to halide_buffer_copy with a NULL target d...
@ Internal
Not visible externally, similar to 'static' linkage in C.
std::string source_location() const
Get the source location of the pure definition of this Func.
int outputs() const
Get the number of outputs of this Func.
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.
Stage update(int idx=0)
Get a handle on an update step for the purposes of scheduling it.
std::vector< Argument > infer_arguments() const
Infer the arguments to the Func, sorted into a canonical order: all buffers (sorted alphabetically by...
Func & serial(const VarOrRVar &var)
Mark a dimension to be traversed serially.
std::vector< Var > make_argument_list(int dimensionality)
Make a list of unique arguments for definitions with unnamed arguments.
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.
Stage operator=(const Expr &)
Use this as the left-hand-side of a definition or an update definition (see RDom).
Func & bound_extent(const Var &var, Expr extent)
Bound the extent of a Func's realization, but not its min.
@ Auto
By default, LoopAlignStrategy is set to NoAlign.
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.
std::string dump_argument_list() const
Return a string describing the current var list taking into account all the splits,...
A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer.
const std::vector< Expr > & args() const
Get the default (no-specialization) arguments (left-hand-side) of the definition.
Stage(Internal::Function f, Internal::Definition d, size_t stage_index)
Func & gpu_lanes(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
The given dimension corresponds to the lanes in a GPU warp.
void infer_input_bounds(const std::vector< int32_t > &sizes, const Target &target=get_jit_target_from_environment(), const ParamMap ¶m_map=ParamMap::empty_map())
For a given size of output, or a given output buffer, determine the bounds required of all unbound Im...
Stage & unroll(const VarOrRVar &var)
const std::string & extern_function_name() const
Get the name of the extern function called for an extern definition.
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...
JITHandlers & jit_handlers()
Get a struct containing the currently set custom functions used by JIT.
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...
Expr update_value(int idx=0) const
Get the right-hand-side of an update definition.
bool defined() const
Definition objects are nullable.
Func & async()
Produce this Func asynchronously in a separate thread.
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 & store_root()
Equivalent to Func::store_at, but schedules storage outside the outermost loop.
HALIDE_ALWAYS_INLINE Type type() const
Get the type of this expression node.
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.
A handle on the output buffer of a pipeline.
Func & parallel(const VarOrRVar &var)
Mark a dimension to be traversed in parallel.
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,...
bool is_extern() const
Is this function an external stage? That is, was it defined using define_extern?
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).
HALIDE_NO_USER_CODE_INLINE std::enable_if< Internal::all_are_convertible< Var, Args... >::value, FuncRef >::type operator()(Args &&...args) const
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...
Stage & hexagon(const VarOrRVar &x=Var::outermost())
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...
Stage & vectorize(const VarOrRVar &var)
std::vector< OutputImageParam > output_buffers() const
Stage specialize(const Expr &condition)
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,...
@ Auto
For pure definitions use ShiftInwards.
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...
Stage operator-=(Expr)
Define a stage that adds the negative of the given expression to this Func.
Func & memoize(const EvictionKey &eviction_key=EvictionKey())
Use the halide_memoization_cache_...
NameMangling
An enum to specify calling convention for extern stages.
Func & store_in(MemoryType memory_type)
Set the type of memory this Func should be stored in.
Stage & gpu(const VarOrRVar &block_x, const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
const std::vector< CustomLoweringPass > & custom_lowering_passes()
Get the custom lowering passes.
Func & compute_root()
Compute all of this function once ahead of time.
EvictionKey(const Expr &expr=Expr())
A base class for passes over the IR which modify it (e.g.
#define HALIDE_NO_USER_CODE_INLINE
Stage & gpu_single_thread(DeviceAPI device_api=DeviceAPI::Default_GPU)
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...
Func & trace_stores()
Trace all stores to the buffer backing this Func by emitting calls to halide_trace.
A reference-counted handle to Halide's internal representation of a function.
Func & compute_inline()
Aggressively inline all uses of this function.
void assign_results(Realization &r, int idx, Last last)
VarOrRVar(const ImplicitVar< N > &u)
const std::vector< Type > & types() const
bool defined() const
Does this function have at least a pure definition.
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.
int dimensions() const
The dimensionality (number of arguments) of this function.
HALIDE_NO_USER_CODE_INLINE T evaluate_may_gpu(const Expr &e)
JIT-Compile and run enough code to evaluate a Halide expression.
A reference to a site in a Halide statement at the top of the body of a particular for loop.
Stage operator*=(const Expr &e)
Define a stage that multiplies Tuple component 'idx' of this Func by the given expression.
Func & rename(const VarOrRVar &old_name, const VarOrRVar &new_name)
Rename a dimension.
A reduction variable represents a single dimension of a reduction domain (RDom).
A multi-dimensional domain over which to iterate.
Func & align_extent(const Var &var, Expr modulus)
Expand the region computed so that the extent is a multiple of 'modulus'.
Func & trace_realizations()
Trace all realizations of this Func by emitting calls to halide_trace.
const Internal::StageSchedule & get_schedule() const
Return the current StageSchedule associated with this initial Stage of this Func.
OutputImageParam output_buffer() const
Get a handle on the output buffer for this Func.
const std::string & name() const
The name of this reduction variable.
Func & gpu_threads(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide that the following dimensions correspond to GPU thread indices.
Func & gpu_single_thread(DeviceAPI device_api=DeviceAPI::Default_GPU)
Tell Halide to run this stage using a single gpu thread and block.
bool has_update_definition() const
Does this function have at least one update definition?
Target get_jit_target_from_environment()
Return the target that Halide will use for jit-compilation.
void print_loop_nest()
Write out the loop nests specified by the schedule for this Function.
std::vector< Var > args() const
Get the pure arguments.
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...
Stage operator/=(Expr)
Define a stage that divides this Func by the given expression.
PrefetchBoundStrategy
Different ways to handle accesses outside the original extents in a prefetch.
const StageSchedule & schedule() const
Get the default (no-specialization) stage-specific schedule associated with this definition.
Func & allow_race_conditions()
Specify that race conditions are permitted for this Func, which enables parallelizing over RVars even...
void specialize_fail(const std::string &message)
Add a specialization to a Func that always terminates execution with a call to halide_error().
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...
Stage & allow_race_conditions()
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...
A fragment of Halide syntax.
Helper class for identifying purpose of an Expr passed to memoize.
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)
A Realization is a vector of references to existing Buffer objects.
A class that can represent Vars or RVars.
int index() const
Return index to the function outputs.
A fragment of front-end syntax of the form f(x, y, z)[index], where x, y, z are Vars or Exprs.
MemoryType
An enum describing different address spaces to be used with Func::store_in.
void specialize_fail(const std::string &message)
Func in()
Create and return a global identity wrapper, which wraps all calls to this Func by any other Func.
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)
Func & prefetch(const T &image, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
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)
Expr max(const FuncRef &a, const FuncRef &b)
A schedule for a single stage of a Halide pipeline.
Stage & prefetch(const Func &f, const VarOrRVar &at, const VarOrRVar &from, Expr offset=1, PrefetchBoundStrategy strategy=PrefetchBoundStrategy::GuardWithIf)
Tuple update_values(int idx=0) const
Get the right-hand-side of an update definition for functions that returns multiple values.
A single definition of a Func.
void check_types(const Tuple &t, int idx)
Create a small array of Exprs for defining and calling functions with multiple outputs.
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.
A fragment of front-end syntax of the form f(x, y, z), 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?
A struct representing a target machine and os to generate code for.
Stage & gpu_lanes(const VarOrRVar &thread_x, DeviceAPI device_api=DeviceAPI::Default_GPU)
const std::vector< Expr > & update_args(int idx=0) const
Get the left-hand-side of the update definition.
Stage operator*=(Expr)
Define a stage that multiplies this Func by the given expression.
Stage & atomic(bool override_associativity_test=false)
DeviceAPI
An enum describing a type of device API.
void schedule_scalar(Func f)
const std::string & name() const
Get the name of a Var.
static const ParamMap & empty_map()
A const ref to an empty ParamMap.
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.
const Internal::StageSchedule & get_schedule() const
Return the current StageSchedule associated with this Stage.
VarOrRVar(const std::string &n, bool r)