Go to the documentation of this file. 1 #ifndef HALIDE_FUNCTION_H
2 #define HALIDE_FUNCTION_H
19 struct ExternFuncArgument;
48 return a.contents < b.contents;
59 explicit Function(
const std::string &n);
88 std::map<FunctionPtr, FunctionPtr> &copied_map)
const;
116 const std::string &
name()
const;
130 const std::vector<std::string> &
args()
const;
149 const std::vector<Expr> &
values()
const;
188 const std::vector<Definition> &
updates()
const;
217 const std::vector<ExternFuncArgument> &
args,
218 const std::vector<Type> &types,
219 const std::vector<Var> &dims,
237 return contents.
same_as(other.contents);
288 const std::map<std::string, FunctionPtr> &
wrappers()
const;
313 void check_types(
const std::vector<Expr> &exprs)
const;
314 void check_types(
const std::vector<Type> &types)
const;
326 std::pair<std::vector<Function>, std::map<std::string, Function>>
deep_copy(
327 const std::vector<Function> &outputs,
328 const std::map<std::string, Function> &env);
This lets you use a Function as a key in a map of the form map<Function, Foo, Function::Compare>
int required_dimensions() const
Get the dimensionality constaints on the outputs (if any).
#define internal_assert(c)
const Call * is_wrapper() const
Check if a Function is a trivial wrapper around another Function, Buffer, or Parameter.
A schedule for a Function of a Halide pipeline.
const std::vector< Type > & output_types() const
Get the types of the outputs.
int dimensions() const
Get the dimensionality.
Expr substitute(const std::string &name, const Expr &replacement, const Expr &expr)
Substitute variables with the given name with the replacement expression within expr.
A base class for algorithms that need to recursively walk over the IR.
std::pair< std::vector< Function >, std::map< std::string, Function > > deep_copy(const std::vector< Function > &outputs, const std::map< std::string, Function > &env)
Deep copy an entire Function DAG.
bool has_pure_definition() const
Does this function have a pure definition?
bool operator()(const Function &a, const Function &b) const
bool has_update_definition() const
Does this function have an update definition?
NameMangling extern_definition_name_mangling() const
Get the name mangling specified for the extern definition.
void deep_copy(const FunctionPtr ©, std::map< FunctionPtr, FunctionPtr > &copied_map) const
Deep copy this Function into 'copy'.
StageSchedule & update_schedule(int idx=0)
Get a mutable handle to the stage-specfic schedule for the update stage.
const std::vector< std::string > & get_trace_tags() const
void define_extern(const std::string &function_name, const std::vector< ExternFuncArgument > &args, const std::vector< Type > &types, const std::vector< Var > &dims, NameMangling mangling, DeviceAPI device_api)
Add an external definition of this Func.
void trace_realizations()
void define_update(const std::vector< Expr > &args, std::vector< Expr > values)
Add an update definition to this function.
@ Default
Match whatever is specified in the Target.
A Function definition which can either represent a init or an update definition.
bool same_as(const FunctionPtr &other) const
Check if two FunctionPtrs refer to the same Function.
bool is_tracing_stores() const
bool is_tracing_realizations() const
Types in the halide type system.
Expr extern_definition_proxy_expr() const
Get the proxy Expr for the extern stage.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
An argument to an extern-defined Func.
const std::vector< Parameter > & output_buffers() const
Get a handle on the output buffer used for setting constraints on it.
@ CPlusPlus
C++ name mangling.
bool is_tracing_loads() const
DeviceAPI extern_function_device_api() const
Get the DeviceAPI declared for an extern function.
const std::vector< ExternFuncArgument > & extern_arguments() const
Retrive the arguments of the extern definition.
void add_trace_tag(const std::string &trace_tag)
bool is_pure_arg(const std::string &name) const
Return true iff the name matches one of the Function's pure args.
void accept(IRVisitor *visitor) const
Accept a visitor to visit all of the definitions and arguments of this function.
const std::string & extern_function_name() const
Get the name of the extern function called for an extern definition.
void check_types(const Expr &e) const
If the Function has type requirements, check that the given argument is compatible with them.
void add_wrapper(const std::string &f, Function &wrapper)
Mark calls of this function by 'f' to be replaced with its wrapper during the lowering stage.
void check_dims(int dims) const
If the Function has dimension requirements, check that the given argument is compatible with them.
FuncSchedule & schedule()
Get a handle to the function-specific schedule for the purpose of modifying it.
bool frozen() const
Check if a function has been frozen.
const std::string & origin_name() const
If this is a wrapper of another func, created by a chain of in or clone_in calls, returns the name of...
int outputs() const
Get the number of outputs.
bool is_pure() const
Does this function only have a pure definition?
Function new_function_in_same_group(const std::string &)
Make a new Function with the same lifetime as this one, and return a strong reference to it.
Definition & definition()
Get a mutable handle to the init definition.
Expr make_call_to_extern_definition(const std::vector< Expr > &args, const Target &t) const
Make a call node to the extern definition.
NameMangling
An enum to specify calling convention for extern stages.
A possibly-weak pointer to a Halide function.
A base class for passes over the IR which modify it (e.g.
FunctionPtr get_contents() const
Get a handle on the halide function contents that this Function represents.
A reference-counted handle to Halide's internal representation of a function.
bool same_as(const Function &other) const
Test for equality of identity.
bool defined() const
Check if the reference is defined.
Function & substitute_calls(const std::map< FunctionPtr, FunctionPtr > &substitutions)
Replace every call to Functions in 'substitutions' keys by all Exprs referenced in this Function to c...
const std::vector< Type > & required_types() const
Get the type constaints on the outputs (if any).
void mutate(IRMutator *mutator)
Accept a mutator to mutator all of the definitions and arguments of this function.
const std::string & debug_file() const
Get a const handle to the debug filename.
Definition & update(int idx=0)
Get a mutable handle to this function's update definition at index 'idx'.
A fragment of Halide syntax.
void freeze()
Mark function as frozen, which means it cannot accept new definitions.
Function()=default
Construct a new function with no definitions and no name.
A schedule for a single stage of a Halide pipeline.
Create a small array of Exprs for defining and calling functions with multiple outputs.
const std::vector< std::string > & args() const
Get the pure arguments.
const std::vector< Expr > & values() const
Get the right-hand-side of the pure definition.
const std::map< std::string, FunctionPtr > & wrappers() const
A struct representing a target machine and os to generate code for.
const std::string & name() const
Get the name of the function.
void trace_loads()
Tracing calls and accessors, passed down from the Func equivalents.
void define(const std::vector< std::string > &args, std::vector< Expr > values)
Add a pure definition to this function.
void lock_loop_levels()
Replace this Function's LoopLevels with locked copies that cannot be mutated further.
const std::vector< Definition > & updates() const
Get a const reference to this function's update definitions.
void create_output_buffers(const std::vector< Type > &types, int dims) const
Define the output buffers.
DeviceAPI
An enum describing a type of device API.
bool can_be_inlined() const
Is it legal to inline this function?
bool has_extern_definition() const
Check if the function has an extern definition.