Halide 22.0.0 Halide compiler and libraries

Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
Halide Namespace Reference

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. More...

## Namespaces
namespace | BoundaryConditions
| namespace to hold functions for imposing boundary conditions on Halide Funcs.
namespace | ConciseCasts
namespace | Internal
namespace | PythonBindings
namespace | PyTorch
namespace | Runtime

## Classes
struct | Argument
| A struct representing an argument to a halide-generated function. More...
struct | ArgumentEstimates
struct | AutoschedulerParams
| Special the Autoscheduler to be used (if any), along with arbitrary additional arguments specific to the given Autoscheduler. More...
struct | AutoSchedulerResults
struct | bfloat16_t
| Class that provides a type that implements half precision floating point using the bfloat16 format. More...
class | Buffer
| A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer. More...
struct | BufferConstraint
class | Callable
struct | CompileError
| An error that occurs while compiling a Halide pipeline that Halide attributes to a user error. More...
class | CompileTimeErrorReporter
| CompileTimeErrorReporter is used at compile time (not runtime) when an error or warning is generated by Halide. More...
class | CostModel
struct | CustomLoweringPass
| A custom lowering pass. More...
class | DefaultCostModel
class | Derivative
| Helper structure storing the adjoints Func. More...
struct | Error
| A base class for Halide errors. More...
class | EvictionKey
| Helper class for identifying purpose of an Expr passed to memoize. More...
struct | Expr
| A fragment of Halide syntax. More...
struct | ExprCompare
| This lets you use an Expr as a key in a map of the form map<Expr, Foo, ExprCompare> More...
struct | ExternCFunction
struct | ExternFuncArgument
| An argument to an extern-defined Func. More...
struct | ExternSignature
struct | float16_t
| Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in software. More...
class | Func
| A halide function. More...
class | FuncRef
| A fragment of front-end syntax of the form f(x, y, z), where x, y, z are Vars or Exprs. More...
class | FuncTupleElementRef
| A fragment of front-end syntax of the form f(x, y, z)[index], where x, y, z are Vars or Exprs. More...
struct | FuseLoopLevel
class | Generator
class | GeneratorContext
| GeneratorContext is a class that is used when using Generators (or Stubs) directly; it is used to allow the outer context (typically, either a Generator or "top-level" code) to specify certain information to the inner context to ensure that inner and outer Generators are compiled in a compatible way. More...
class | GeneratorInput
class | GeneratorOutput
class | GeneratorParam
| GeneratorParam is a templated class that can be used to modify the behavior of the Generator at code-generation time. More...
class | ImageParam
| An Image parameter to a halide pipeline. More...
struct | ImplicitVar
struct | InternalError
| An error that occurs while compiling a Halide pipeline that Halide attributes to an internal compiler bug, or to an invalid use of Halide's internals. More...
struct | JITExtern
struct | JITHandlers
| A set of custom overrides of runtime functions. More...
struct | JITUserContext
| A context to be passed to Pipeline::realize. More...
class | LoopLevel
| A reference to a site in a Halide statement at the top of the body of a particular for loop. More...
class | Module
| A halide module. More...
class | NamesInterface
class | OutputImageParam
| A handle on the output buffer of a pipeline. More...
class | Param
| A scalar parameter to a halide pipeline. More...
class | Parameter
| A reference-counted handle to a parameter to a halide pipeline. More...
class | Pipeline
| A class representing a Halide pipeline. More...
struct | Range
| A single-dimensional span. More...
class | RDom
| A multi-dimensional domain over which to iterate. More...
class | Realization
| A Realization is a vector of references to existing Buffer objects. More...
struct | RuntimeError
| An error that occurs while running a JIT-compiled Halide pipeline. More...
class | RVar
| A reduction variable represents a single dimension of a reduction domain (RDom). More...
class | SimdOpCheckTest
class | Stage
| A single definition of a Func. More...
struct | Target
| A struct representing a target machine and os to generate code for. More...
struct | Task
struct | TestResult
class | Tuple
| Create a small array of Exprs for defining and calling functions with multiple outputs. More...
struct | Type
| Types in the halide type system. More...
class | Var
| A Halide variable, to be used when defining functions. More...
struct | VarOrRVar
| A class that can represent Vars or RVars. More...

## Typedefs
using | GeneratorParamsMap = std::map< std::string, std::string >
typedef std::vector< Range > | Region
| A multi-dimensional box. More...
typedef Stage | ScheduleHandle
using | MetadataNameMap = std::map< std::string, std::string >
using | ModuleFactory = std::function< Module(const std::string &fn_name, const Target &target)>
using | CompilerLoggerFactory = std::function< std::unique_ptr< Internal::CompilerLogger >(const std::string &fn_name, const Target &target)>
using | AutoSchedulerFn = std::function< void(const Pipeline &, const Target &, const AutoschedulerParams &, AutoSchedulerResults *outputs)>

## Enumerations
enum class | DeviceAPI { None , Host , Default_GPU , CUDA , OpenCL , Metal , Hexagon , HexagonDma , D3D12Compute , Vulkan , WebGPU }
| An enum describing a type of device API. More...
enum class | MemoryType { Auto , Heap , Stack , Register , GPUShared , GPUTexture , LockedCache , VTCM , AMXTile }
| An enum describing different address spaces to be used with Func::store_in. More...
enum class | NameMangling { Default , C , CPlusPlus }
| An enum to specify calling convention for extern stages. More...
enum class | Partition { Auto , Never , Always }
| Different ways to handle loops with a potentially optimizable boundary conditions. More...
enum class | OutputFileType { assembly , bitcode , c_header , c_source , compiler_log , cpp_stub , featurization , function_info_header , hlpipe , llvm_assembly , object , python_extension , pytorch_wrapper , registration , schedule , static_library , stmt , conceptual_stmt , stmt_html , conceptual_stmt_html , device_code }
| Enums specifying various kinds of outputs that can be produced from a Halide Pipeline. More...
enum class | LinkageType { External , ExternalPlusMetadata , ExternalPlusArgv , Internal }
| Type of linkage a function in a lowered Halide module can have. More...
enum | StmtOutputFormat { Text , HTML }
| Used to determine if the output printed to file should be as a normal string or as an HTML file which can be opened in a browerser and manipulated via JS and CSS. More...
enum class | PrefetchBoundStrategy { Clamp , GuardWithIf , NonFaulting }
| Different ways to handle accesses outside the original extents in a prefetch. More...
enum class | TailStrategy { RoundUp , GuardWithIf , Predicate , PredicateLoads , PredicateStores , ShiftInwards , ShiftInwardsAndBlend , RoundUpAndBlend , Auto }
| Different ways to handle a tail case in a split when the factor does not provably divide the extent. More...
enum class | LoopAlignStrategy { AlignStart , AlignEnd , NoAlign , Auto }
| Different ways to handle the case when the start/end of the loops of stages computed with (fused) are not aligned. More...

## Functions
std::unique_ptr< DefaultCostModel > | make_default_cost_model (const std::string &weights_in_dir="", const std::string &weights_out_dir="", bool randomize_weights=false)
std::unique_ptr< DefaultCostModel > | make_default_cost_model (Internal::Autoscheduler::Statistics &stats, const std::string &weights_in_dir="", const std::string &weights_out_dir="", bool randomize_weights=false)
std::unique_ptr< llvm::Module > | codegen_llvm (const Module &module, llvm::LLVMContext &context)
| Given a Halide module, generate an llvm::Module. More...
Internal::ConstantInterval | cast (Type t, const Internal::ConstantInterval &a)
| Cast operators for ConstantIntervals. More...
Internal::ConstantInterval | saturating_cast (Type t, const Internal::ConstantInterval &a)
std::ostream & | operator<< (std::ostream &stream, const Expr &)
| Emit an expression on an output stream (such as std::cout) in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const Type &)
| Emit a halide type on an output stream (such as std::cout) in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const Module &)
| Emit a halide Module on an output stream (such as std::cout) in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const Target &)
| Emit a halide Target in a human readable form. More...
Derivative | propagate_adjoints (const Func &output, const Func &adjoint, const Region &output_bounds)
| Given a Func and a corresponding adjoint, (back)propagate the adjoint to all dependent Funcs, buffers, and parameters. More...
Derivative | propagate_adjoints (const Func &output, const Buffer< float > &adjoint)
| Given a Func and a corresponding adjoint buffer, (back)propagate the adjoint to all dependent Funcs, buffers, and parameters. More...
Derivative | propagate_adjoints (const Func &output)
| Given a scalar Func with size 1, (back)propagate the gradient to all dependent Funcs, buffers, and parameters. More...
Pipeline | deserialize_pipeline (const std::string &filename, const std::map< std::string, Parameter > &user_params)
| Deserialize a Halide pipeline from a file. More...
Pipeline | deserialize_pipeline (std::istream &in, const std::map< std::string, Parameter > &user_params)
| Deserialize a Halide pipeline from an input stream. More...
Pipeline | deserialize_pipeline (const std::vector< uint8_t > &data, const std::map< std::string, Parameter > &user_params)
| Deserialize a Halide pipeline from a byte buffer containing a serialized pipeline in binary format. More...
std::map< std::string, Parameter > | deserialize_parameters (const std::string &filename)
| Deserialize the external parameters for the Halide pipeline from a file. More...
std::map< std::string, Parameter > | deserialize_parameters (std::istream &in)
| Deserialize the external parameters for the Halide pipeline from input stream. More...
std::map< std::string, Parameter > | deserialize_parameters (const std::vector< uint8_t > &data)
| Deserialize the external parameters for the Halide pipeline from a byte buffer containing a serialized pipeline in binary format. More...
const halide_device_interface_t * | get_device_interface_for_device_api (DeviceAPI d, const Target &t=get_jit_target_from_environment(), const char *error_site=nullptr)
| Gets the appropriate halide_device_interface_t * for a DeviceAPI. More...
DeviceAPI | get_default_device_api_for_target (const Target &t)
| Get the specific DeviceAPI that Halide would select when presented with DeviceAPI::Default_GPU for a given target. More...
bool | host_supports_target_device (const Target &t)
| This attempts to sniff whether a given Target (and its implied DeviceAPI) is usable on the current host. More...
bool | exceptions_enabled ()
| Query whether Halide was compiled with exceptions. More...
void | set_custom_compile_time_error_reporter (CompileTimeErrorReporter *error_reporter)
| The default error reporter logs to stderr, then throws an exception (if HALIDE_WITH_EXCEPTIONS) or calls abort (if not). More...
Expr | fast_integer_divide (const Expr &numerator, const Expr &denominator)
| Integer division by small values can be done exactly as multiplies and shifts. More...
Expr | fast_integer_divide_round_to_zero (const Expr &numerator, const Expr &denominator)
| A variant of the above which rounds towards zero instead of rounding towards negative infinity. More...
Expr | fast_integer_modulo (const Expr &numerator, const Expr &denominator)
| Use the fast integer division tables to implement a modulo operation via the Euclidean identity: ab = a - (a/b)*b. More...
Expr | min (const FuncRef &a, const FuncRef &b)
| Explicit overloads of min and max for FuncRef. More...
Expr | max (const FuncRef &a, const FuncRef &b)
template<typename T >
HALIDE_NO_USER_CODE_INLINE T | evaluate (JITUserContext *ctx, const Expr &e)
| JIT-Compile and run enough code to evaluate a Halide expression. More...
template<typename T >
HALIDE_NO_USER_CODE_INLINE T | evaluate (const Expr &e)
| evaluate with a default user context More...
template<typename First , typename... Rest>
HALIDE_NO_USER_CODE_INLINE void | evaluate (JITUserContext *ctx, Tuple t, First first, Rest &&...rest)
| JIT-compile and run enough code to evaluate a Halide Tuple. More...
template<typename First , typename... Rest>
HALIDE_NO_USER_CODE_INLINE void | evaluate (Tuple t, First first, Rest &&...rest)
| JIT-compile and run enough code to evaluate a Halide Tuple. More...
template<typename T >
HALIDE_NO_USER_CODE_INLINE T | evaluate_may_gpu (const Expr &e)
| JIT-Compile and run enough code to evaluate a Halide expression. More...
template<typename First , typename... Rest>
HALIDE_NO_USER_CODE_INLINE void | evaluate_may_gpu (Tuple t, First first, Rest &&...rest)
| JIT-compile and run enough code to evaluate a Halide Tuple. More...
template<typename Other , typename T >
auto | operator+ (const Other &a, const GeneratorParam< T > &b) -> decltype(a+(T) b)
| Addition between GeneratorParam<T> and any type that supports operator+ with T. More...
template<typename Other , typename T >
auto | operator+ (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a+b)
template<typename Other , typename T >
auto | operator- (const Other &a, const GeneratorParam< T > &b) -> decltype(a -(T) b)
| Subtraction between GeneratorParam<T> and any type that supports operator- with T. More...
template<typename Other , typename T >
auto | operator- (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a - b)
template<typename Other , typename T >
auto | operator* (const Other &a, const GeneratorParam< T > &b) -> decltype(a *(T) b)
| Multiplication between GeneratorParam<T> and any type that supports operator* with T. More...
template<typename Other , typename T >
auto | operator* (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a *b)
template<typename Other , typename T >
auto | operator/ (const Other &a, const GeneratorParam< T > &b) -> decltype(a/(T) b)
| Division between GeneratorParam<T> and any type that supports operator/ with T. More...
template<typename Other , typename T >
auto | operator/ (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a/b)
template<typename Other , typename T >
auto | operator% (const Other &a, const GeneratorParam< T > &b) -> decltype(a %(T) b)
| Modulo between GeneratorParam<T> and any type that supports operator% with T. More...
template<typename Other , typename T >
auto | operator% (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a % b)
template<typename Other , typename T >
auto | operator> (const Other &a, const GeneratorParam< T > &b) -> decltype(a >(T) b)
| Greater than comparison between GeneratorParam<T> and any type that supports operator> with T. More...
template<typename Other , typename T >
auto | operator> (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a > b)
template<typename Other , typename T >
auto | operator< (const Other &a, const GeneratorParam< T > &b) -> decltype(a<(T) b)
| Less than comparison between GeneratorParam<T> and any type that supports operator< with T. More...
template<typename Other , typename T >
auto | operator< (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a< b)
template<typename Other , typename T >
auto | operator>= (const Other &a, const GeneratorParam< T > &b) -> decltype(a >=(T) b)
| Greater than or equal comparison between GeneratorParam<T> and any type that supports operator>= with T. More...
template<typename Other , typename T >
auto | operator>= (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a >=b)
template<typename Other , typename T >
auto | operator<= (const Other &a, const GeneratorParam< T > &b) -> decltype(a<=(T) b)
| Less than or equal comparison between GeneratorParam<T> and any type that supports operator<= with T. More...
template<typename Other , typename T >
auto | operator<= (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a<=b)
template<typename Other , typename T >
auto | operator== (const Other &a, const GeneratorParam< T > &b) -> decltype(a==(T) b)
| Equality comparison between GeneratorParam<T> and any type that supports operator== with T. More...
template<typename Other , typename T >
auto | operator== (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a==b)
template<typename Other , typename T >
auto | operator!= (const Other &a, const GeneratorParam< T > &b) -> decltype(a !=(T) b)
| Inequality comparison between between GeneratorParam<T> and any type that supports operator!= with T. More...
template<typename Other , typename T >
auto | operator!= (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a !=b)
template<typename Other , typename T >
auto | operator&& (const Other &a, const GeneratorParam< T > &b) -> decltype(a &&(T) b)
| Logical and between between GeneratorParam<T> and any type that supports operator&& with T. More...
template<typename Other , typename T >
auto | operator&& (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a &&b)
template<typename T >
auto | operator&& (const GeneratorParam< T > &a, const GeneratorParam< T > &b) -> decltype((T) a &&(T) b)
template<typename Other , typename T >
auto | operator|| (const Other &a, const GeneratorParam< T > &b) -> decltype(a||(T) b)
| Logical or between between GeneratorParam<T> and any type that supports operator|| with T. More...
template<typename Other , typename T >
auto | operator|| (const GeneratorParam< T > &a, const Other &b) -> decltype((T) a||b)
template<typename T >
auto | operator|| (const GeneratorParam< T > &a, const GeneratorParam< T > &b) -> decltype((T) a||(T) b)
template<typename Other , typename T >
auto | min (const Other &a, const GeneratorParam< T > &b) -> decltype(Internal::GeneratorMinMax::min_forward(a, b))
| Compute minimum between GeneratorParam<T> and any type that supports min with T. More...
template<typename Other , typename T >
auto | min (const GeneratorParam< T > &a, const Other &b) -> decltype(Internal::GeneratorMinMax::min_forward(a, b))
template<typename Other , typename T >
auto | max (const Other &a, const GeneratorParam< T > &b) -> decltype(Internal::GeneratorMinMax::max_forward(a, b))
| Compute the maximum value between GeneratorParam<T> and any type that supports max with T. More...
template<typename Other , typename T >
auto | max (const GeneratorParam< T > &a, const Other &b) -> decltype(Internal::GeneratorMinMax::max_forward(a, b))
template<typename T >
auto | operator! (const GeneratorParam< T > &a) -> decltype(!(T) a)
| Not operator for GeneratorParam. More...
Callable | create_callable_from_generator (const GeneratorContext &context, const std::string &name, const GeneratorParamsMap &generator_params={})
| Create a Generator from the currently-registered Generators, use it to create a Callable. More...
Callable | create_callable_from_generator (const Target &target, const std::string &name, const GeneratorParamsMap &generator_params={})
Expr | sum (Expr, const std::string &s="sum")
| An inline reduction. More...
Expr | saturating_sum (Expr, const std::string &s="saturating_sum")
Expr | product (Expr, const std::string &s="product")
Expr | maximum (Expr, const std::string &s="maximum")
Expr | minimum (Expr, const std::string &s="minimum")
Expr | sum (const RDom &, Expr, const std::string &s="sum")
| Variants of the inline reduction in which the RDom is stated explicitly. More...
Expr | saturating_sum (const RDom &r, Expr e, const std::string &s="saturating_sum")
Expr | product (const RDom &, Expr, const std::string &s="product")
Expr | maximum (const RDom &, Expr, const std::string &s="maximum")
Expr | minimum (const RDom &, Expr, const std::string &s="minimum")
Tuple | argmax (Expr, const std::string &s="argmax")
| Returns an Expr or Tuple representing the coordinates of the point in the RDom which minimizes or maximizes the expression. More...
Tuple | argmin (Expr, const std::string &s="argmin")
Tuple | argmax (const RDom &, Expr, const std::string &s="argmax")
Tuple | argmin (const RDom &, Expr, const std::string &s="argmin")
Expr | sum (Expr, const Func &)
| Inline reductions create an anonymous helper Func to do the work. More...
Expr | saturating_sum (Expr, const Func &)
Expr | product (Expr, const Func &)
Expr | maximum (Expr, const Func &)
Expr | minimum (Expr, const Func &)
Expr | sum (const RDom &, Expr, const Func &)
Expr | saturating_sum (const RDom &r, Expr e, const Func &)
Expr | product (const RDom &, Expr, const Func &)
Expr | maximum (const RDom &, Expr, const Func &)
Expr | minimum (const RDom &, Expr, const Func &)
Tuple | argmax (Expr, const Func &)
Tuple | argmin (Expr, const Func &)
Tuple | argmax (const RDom &, Expr, const Func &)
Tuple | argmin (const RDom &, Expr, const Func &)
template<typename T >
Expr | cast (Expr a)
| Cast an expression to the halide type corresponding to the C++ type T. More...
Expr | cast (Type t, Expr a)
| Cast an expression to a new type. More...
Expr | operator+ (Expr a, Expr b)
| Return the sum of two expressions, doing any necessary type coercion using Internal::match_types. More...
Expr | operator+ (Expr a, int b)
| Add an expression and a constant integer. More...
Expr | operator+ (int a, Expr b)
| Add a constant integer and an expression. More...
Expr & | operator+= (Expr &a, Expr b)
| Modify the first expression to be the sum of two expressions, without changing its type. More...
Expr | operator- (Expr a, Expr b)
| Return the difference of two expressions, doing any necessary type coercion using Internal::match_types. More...
Expr | operator- (Expr a, int b)
| Subtracts a constant integer from an expression. More...
Expr | operator- (int a, Expr b)
| Subtracts an expression from a constant integer. More...
Expr | operator- (Expr a)
| Return the negative of the argument. More...
Expr & | operator-= (Expr &a, Expr b)
| Modify the first expression to be the difference of two expressions, without changing its type. More...
Expr | operator* (Expr a, Expr b)
| Return the product of two expressions, doing any necessary type coercion using Internal::match_types. More...
Expr | operator* (Expr a, int b)
| Multiply an expression and a constant integer. More...
Expr | operator* (int a, Expr b)
| Multiply a constant integer and an expression. More...
Expr & | operator*= (Expr &a, Expr b)
| Modify the first expression to be the product of two expressions, without changing its type. More...
Expr | operator/ (Expr a, Expr b)
| Return the ratio of two expressions, doing any necessary type coercion using Internal::match_types. More...
Expr & | operator/= (Expr &a, Expr b)
| Modify the first expression to be the ratio of two expressions, without changing its type. More...
Expr | operator/ (Expr a, int b)
| Divides an expression by a constant integer. More...
Expr | operator/ (int a, Expr b)
| Divides a constant integer by an expression. More...
Expr | operator% (Expr a, Expr b)
| Return the first argument reduced modulo the second, doing any necessary type coercion using Internal::match_types. More...
Expr | operator% (Expr a, int b)
| Mods an expression by a constant integer. More...
Expr | operator% (int a, Expr b)
| Mods a constant integer by an expression. More...
Expr | operator> (Expr a, Expr b)
| Return a boolean expression that tests whether the first argument is greater than the second, after doing any necessary type coercion using Internal::match_types. More...
Expr | operator> (Expr a, int b)
| Return a boolean expression that tests whether an expression is greater than a constant integer. More...
Expr | operator> (int a, Expr b)
| Return a boolean expression that tests whether a constant integer is greater than an expression. More...
Expr | operator< (Expr a, Expr b)
| Return a boolean expression that tests whether the first argument is less than the second, after doing any necessary type coercion using Internal::match_types. More...
Expr | operator< (Expr a, int b)
| Return a boolean expression that tests whether an expression is less than a constant integer. More...
Expr | operator< (int a, Expr b)
| Return a boolean expression that tests whether a constant integer is less than an expression. More...
Expr | operator<= (Expr a, Expr b)
| Return a boolean expression that tests whether the first argument is less than or equal to the second, after doing any necessary type coercion using Internal::match_types. More...
Expr | operator<= (Expr a, int b)
| Return a boolean expression that tests whether an expression is less than or equal to a constant integer. More...
Expr | operator<= (int a, Expr b)
| Return a boolean expression that tests whether a constant integer is less than or equal to an expression. More...
Expr | operator>= (Expr a, Expr b)
| Return a boolean expression that tests whether the first argument is greater than or equal to the second, after doing any necessary type coercion using Internal::match_types. More...
Expr | operator>= (const Expr &a, int b)
| Return a boolean expression that tests whether an expression is greater than or equal to a constant integer. More...
Expr | operator>= (int a, const Expr &b)
| Return a boolean expression that tests whether a constant integer is greater than or equal to an expression. More...
Expr | operator== (Expr a, Expr b)
| Return a boolean expression that tests whether the first argument is equal to the second, after doing any necessary type coercion using Internal::match_types. More...
Expr | operator== (Expr a, int b)
| Return a boolean expression that tests whether an expression is equal to a constant integer. More...
Expr | operator== (int a, Expr b)
| Return a boolean expression that tests whether a constant integer is equal to an expression. More...
Expr | operator!= (Expr a, Expr b)
| Return a boolean expression that tests whether the first argument is not equal to the second, after doing any necessary type coercion using Internal::match_types. More...
Expr | operator!= (Expr a, int b)
| Return a boolean expression that tests whether an expression is not equal to a constant integer. More...
Expr | operator!= (int a, Expr b)
| Return a boolean expression that tests whether a constant integer is not equal to an expression. More...
Expr | operator&& (Expr a, Expr b)
| Returns the logical and of the two arguments. More...
Expr | operator&& (Expr a, bool b)
| Logical and of an Expr and a bool. More...
Expr | operator&& (bool a, Expr b)
Expr | operator|| (Expr a, Expr b)
| Returns the logical or of the two arguments. More...
Expr | operator|| (Expr a, bool b)
| Logical or of an Expr and a bool. More...
Expr | operator|| (bool a, Expr b)
Expr | operator! (Expr a)
| Returns the logical not the argument. More...
Expr | max (Expr a, Expr b)
| Returns an expression representing the greater of the two arguments, after doing any necessary type coercion using Internal::match_types. More...
Expr | max (Expr a, int b)
| Returns an expression representing the greater of an expression and a constant integer. More...
Expr | max (int a, Expr b)
| Returns an expression representing the greater of a constant integer and an expression. More...
Expr | max (float a, Expr b)
Expr | max (Expr a, float b)
template<typename A , typename B , typename C , typename... Rest, std::enable_if_t< Internal::all_are_convertible< Expr, Rest... >::value > * = nullptr>
Expr | max (A &&a, B &&b, C &&c, Rest &&...rest)
| Returns an expression representing the greater of an expressions vector, after doing any necessary type coersion using Internal::match_types. More...
Expr | min (Expr a, Expr b)
Expr | min (Expr a, int b)
| Returns an expression representing the lesser of an expression and a constant integer. More...
Expr | min (int a, Expr b)
| Returns an expression representing the lesser of a constant integer and an expression. More...
Expr | min (float a, Expr b)
Expr | min (Expr a, float b)
template<typename A , typename B , typename C , typename... Rest, std::enable_if_t< Internal::all_are_convertible< Expr, Rest... >::value > * = nullptr>
Expr | min (A &&a, B &&b, C &&c, Rest &&...rest)
| Returns an expression representing the lesser of an expressions vector, after doing any necessary type coersion using Internal::match_types. More...
Expr | operator+ (Expr a, float b)
| Operators on floats treats those floats as Exprs. More...
Expr | operator+ (float a, Expr b)
Expr | operator- (Expr a, float b)
Expr | operator- (float a, Expr b)
Expr | operator* (Expr a, float b)
Expr | operator* (float a, Expr b)
Expr | operator/ (Expr a, float b)
Expr | operator/ (float a, Expr b)
Expr | operator% (Expr a, float b)
Expr | operator% (float a, Expr b)
Expr | operator> (Expr a, float b)
Expr | operator> (float a, Expr b)
Expr | operator< (Expr a, float b)
Expr | operator< (float a, Expr b)
Expr | operator>= (Expr a, float b)
Expr | operator>= (float a, Expr b)
Expr | operator<= (Expr a, float b)
Expr | operator<= (float a, Expr b)
Expr | operator== (Expr a, float b)
Expr | operator== (float a, Expr b)
Expr | operator!= (Expr a, float b)
Expr | operator!= (float a, Expr b)
Expr | clamp (Expr a, const Expr &min_val, const Expr &max_val)
| Clamps an expression to lie within the given bounds. More...
Expr | abs (Expr a)
| Returns the absolute value of a signed integer or floating-point expression. More...
Expr | absd (Expr a, Expr b)
| Return the absolute difference between two values. More...
Expr | select (Expr condition, Expr true_value, Expr false_value)
| Returns an expression similar to the ternary operator in C, except that it always evaluates all arguments. More...
template<typename... Args, std::enable_if_t< Internal::all_are_convertible< Expr, Args... >::value > * = nullptr>
Expr | select (Expr c0, Expr v0, Expr c1, Expr v1, Args &&...args)
| A multi-way variant of select similar to a switch statement in C, which can accept multiple conditions and values in pairs. More...
Tuple | select (const Tuple &condition, const Tuple &true_value, const Tuple &false_value)
| Equivalent of ternary select(), but taking/returning tuples. More...
Tuple | select (const Expr &condition, const Tuple &true_value, const Tuple &false_value)
template<typename... Args>
Tuple | select (const Tuple &c0, const Tuple &v0, const Tuple &c1, const Tuple &v1, Args &&...args)
| Equivalent of multiway select(), but taking/returning tuples. More...
template<typename... Args>
Tuple | select (const Expr &c0, const Tuple &v0, const Expr &c1, const Tuple &v1, Args &&...args)
Expr | select (const Expr &condition, const FuncRef &true_value, const FuncRef &false_value)
| select applied to FuncRefs (e.g. More...
template<typename... Args>
Expr | select (const Expr &c0, const FuncRef &v0, const Expr &c1, const FuncRef &v1, Args &&...args)
Expr | mux (const Expr &id, const std::initializer_list< Expr > &values)
| Oftentimes we want to pack a list of expressions with the same type into a channel dimension, e.g., img(x, y, c) = select(c == 0, 100, // Red c == 1, 50, // Green 25); // Blue This is tedious when the list is long. More...
Expr | mux (const Expr &id, const std::vector< Expr > &values)
Expr | mux (const Expr &id, const Tuple &values)
Expr | mux (const Expr &id, const std::initializer_list< FuncRef > &values)
Tuple | mux (const Expr &id, const std::initializer_list< Tuple > &values)
Tuple | mux (const Expr &id, const std::vector< Tuple > &values)
Expr | sin (Expr x)
| Return the sine of a floating-point expression. More...
Expr | asin (Expr x)
| Return the arcsine of a floating-point expression. More...
Expr | cos (Expr x)
| Return the cosine of a floating-point expression. More...
Expr | acos (Expr x)
| Return the arccosine of a floating-point expression. More...
Expr | tan (Expr x)
| Return the tangent of a floating-point expression. More...
Expr | atan (Expr x)
| Return the arctangent of a floating-point expression. More...
Expr | atan2 (Expr y, Expr x)
| Return the angle of a floating-point gradient. More...
Expr | sinh (Expr x)
| Return the hyperbolic sine of a floating-point expression. More...
Expr | asinh (Expr x)
| Return the hyperbolic arcsinhe of a floating-point expression. More...
Expr | cosh (Expr x)
| Return the hyperbolic cosine of a floating-point expression. More...
Expr | acosh (Expr x)
| Return the hyperbolic arccosine of a floating-point expression. More...
Expr | tanh (Expr x)
| Return the hyperbolic tangent of a floating-point expression. More...
Expr | atanh (Expr x)
| Return the hyperbolic arctangent of a floating-point expression. More...
Expr | sqrt (Expr x)
| Return the square root of a floating-point expression. More...
Expr | hypot (const Expr &x, const Expr &y)
| Return the square root of the sum of the squares of two floating-point expressions. More...
Expr | exp (Expr x)
| Return the exponential of a floating-point expression. More...
Expr | log (Expr x)
| Return the logarithm of a floating-point expression. More...
Expr | pow (Expr x, Expr y)
| Return one floating point expression raised to the power of another. More...
Expr | erf (const Expr &x)
| Evaluate the error function erf. More...
Expr | fast_sin (const Expr &x)
| Fast vectorizable approximation to some trigonometric functions for Float(32). More...
Expr | fast_cos (const Expr &x)
Expr | fast_log (const Expr &x)
| Fast approximate cleanly vectorizable log for Float(32). More...
Expr | fast_exp (const Expr &x)
| Fast approximate cleanly vectorizable exp for Float(32). More...
Expr | fast_pow (Expr x, Expr y)
| Fast approximate cleanly vectorizable pow for Float(32). More...
Expr | fast_inverse (Expr x)
| Fast approximate inverse for Float(32). More...
Expr | fast_inverse_sqrt (Expr x)
| Fast approximate inverse square root for Float(32). More...
Expr | floor (Expr x)
| Return the greatest whole number less than or equal to a floating-point expression. More...
Expr | ceil (Expr x)
| Return the least whole number greater than or equal to a floating-point expression. More...
Expr | round (Expr x)
| Return the whole number closest to a floating-point expression. More...
Expr | trunc (Expr x)
| Return the integer part of a floating-point expression. More...
Expr | is_nan (Expr x)
| Returns true if the argument is a Not a Number (NaN). More...
Expr | is_inf (Expr x)
| Returns true if the argument is Inf or -Inf. More...
Expr | is_finite (Expr x)
| Returns true if the argument is a finite value (ie, neither NaN nor Inf). More...
Expr | fract (const Expr &x)
| Return the fractional part of a floating-point expression. More...
Expr | reinterpret (Type t, Expr e)
| Reinterpret the bits of one value as another type. More...
template<typename T >
Expr | reinterpret (Expr e)
Expr | operator& (Expr x, Expr y)
| Return the bitwise and of two expressions (which need not have the same type). More...
Expr | operator& (Expr x, int y)
| Return the bitwise and of an expression and an integer. More...
Expr | operator& (int x, Expr y)
Expr | operator| (Expr x, Expr y)
| Return the bitwise or of two expressions (which need not have the same type). More...
Expr | operator| (Expr x, int y)
| Return the bitwise or of an expression and an integer. More...
Expr | operator| (int x, Expr y)
Expr | operator^ (Expr x, Expr y)
| Return the bitwise xor of two expressions (which need not have the same type). More...
Expr | operator^ (Expr x, int y)
| Return the bitwise xor of an expression and an integer. More...
Expr | operator^ (int x, Expr y)
Expr | operator~ (Expr x)
| Return the bitwise not of an expression. More...
Expr | operator<< (Expr x, Expr y)
| Shift the bits of an integer value left. More...
Expr | operator<< (Expr x, int y)
Expr | operator>> (Expr x, Expr y)
| Shift the bits of an integer value right. More...
Expr | operator>> (Expr x, int y)
Expr | lerp (Expr zero_val, Expr one_val, Expr weight)
| Linear interpolate between the two values according to a weight. More...
Expr | popcount (Expr x)
| Count the number of set bits in an expression. More...
Expr | count_leading_zeros (Expr x)
| Count the number of leading zero bits in an expression. More...
Expr | count_trailing_zeros (Expr x)
| Count the number of trailing zero bits in an expression. More...
Expr | div_round_to_zero (Expr x, Expr y)
| Divide two integers, rounding towards zero. More...
Expr | mod_round_to_zero (Expr x, Expr y)
| Compute the remainder of dividing two integers, when division is rounding toward zero. More...
Expr | random_float (Expr seed=Expr())
| Return a random variable representing a uniformly distributed float in the half-open interval [0.0f, 1.0f). More...
Expr | random_uint (Expr seed=Expr())
| Return a random variable representing a uniformly distributed unsigned 32-bit integer. More...
Expr | random_int (Expr seed=Expr())
| Return a random variable representing a uniformly distributed 32-bit integer. More...
Expr | print (const std::vector< Expr > &values)
| Create an Expr that prints out its value whenever it is evaluated. More...
template<typename... Args>
HALIDE_NO_USER_CODE_INLINE Expr | print (Expr a, Args &&...args)
Expr | print_when (Expr condition, const std::vector< Expr > &values)
| Create an Expr that prints whenever it is evaluated, provided that the condition is true. More...
template<typename... Args>
HALIDE_NO_USER_CODE_INLINE Expr | print_when (Expr condition, Expr a, Args &&...args)
Expr | require (Expr condition, const std::vector< Expr > &values)
| Create an Expr that that guarantees a precondition. More...
template<typename... Args>
HALIDE_NO_USER_CODE_INLINE Expr | require (Expr condition, Expr value, Args &&...args)
Expr | undef (Type t)
| Return an undef value of the given type. More...
template<typename T >
Expr | undef ()
template<typename... Args>
HALIDE_NO_USER_CODE_INLINE Expr | memoize_tag (Expr result, Args &&...args)
| Control the values used in the memoization cache key for memoize. More...
Expr | likely (Expr e)
| Expressions tagged with this intrinsic are considered to be part of the steady state of some loop with a nasty beginning and end (e.g. More...
Expr | likely_if_innermost (Expr e)
| Equivalent to likely, but only triggers a loop partitioning if found in an innermost loop. More...
template<typename T >
Expr | saturating_cast (Expr e)
| Cast an expression to the halide type corresponding to the C++ type T. More...
Expr | saturating_cast (Type t, Expr e)
| Cast an expression to a new type, clamping to the minimum and maximum values of the result type. More...
Expr | strict_float (const Expr &e)
| Makes a best effort attempt to preserve IEEE floating-point semantics in evaluating an expression. More...
Expr | unsafe_promise_clamped (const Expr &value, const Expr &min, const Expr &max)
| Create an Expr that that promises another Expr is clamped but do not generate code to check the assertion or modify the value. More...
Expr | scatter (const std::vector< Expr > &args)
| Scatter and gather are used for update definition which must store multiple values to distinct locations at the same time. More...
Expr | gather (const std::vector< Expr > &args)
template<typename... Args>
Expr | scatter (const Expr &e, Args &&...args)
template<typename... Args>
Expr | gather (const Expr &e, Args &&...args)
Expr | extract_bits (Type t, const Expr &e, const Expr &lsb)
| Extract a contiguous subsequence of the bits of 'e', starting at the bit index given by 'lsb', where zero is the least-significant bit, returning a value of type 't'. More...
template<typename T >
Expr | extract_bits (const Expr &e, const Expr &lsb)
Expr | concat_bits (const std::vector< Expr > &e)
| Given a number of Exprs of the same type, concatenate their bits producing a single Expr of the same type code of the input but with more bits. More...
Expr | widen_right_add (Expr a, Expr b)
| Below is a collection of intrinsics for fixed-point programming. More...
Expr | widen_right_mul (Expr a, Expr b)
| Compute a * widen(b). More...
Expr | widen_right_sub (Expr a, Expr b)
| Compute a - widen(b). More...
Expr | widening_add (Expr a, Expr b)
| Compute widen(a) + widen(b). More...
Expr | widening_mul (Expr a, Expr b)
| Compute widen(a) * widen(b). More...
Expr | widening_sub (Expr a, Expr b)
| Compute widen(a) - widen(b). More...
Expr | widening_shift_left (Expr a, Expr b)
| Compute widen(a) << b. More...
Expr | widening_shift_left (Expr a, int b)
Expr | widening_shift_right (Expr a, Expr b)
| Compute widen(a) >> b. More...
Expr | widening_shift_right (Expr a, int b)
Expr | rounding_shift_left (Expr a, Expr b)
| Compute saturating_narrow(widening_add(a, (1 >> min(b, 0)) / 2) << b). More...
Expr | rounding_shift_left (Expr a, int b)
Expr | rounding_shift_right (Expr a, Expr b)
| Compute saturating_narrow(widening_add(a, (1 << max(b, 0)) / 2) >> b). More...
Expr | rounding_shift_right (Expr a, int b)
Expr | saturating_add (Expr a, Expr b)
| Compute saturating_narrow(widen(a) + widen(b)) More...
Expr | saturating_sub (Expr a, Expr b)
| Compute saturating_narrow(widen(a) - widen(b)) More...
Expr | halving_add (Expr a, Expr b)
| Compute narrow((widen(a) + widen(b)) / 2) More...
Expr | rounding_halving_add (Expr a, Expr b)
| Compute narrow((widen(a) + widen(b) + 1) / 2) More...
Expr | halving_sub (Expr a, Expr b)
| Compute narrow((widen(a) - widen(b)) / 2) More...
Expr | mul_shift_right (Expr a, Expr b, Expr q)
| Compute saturating_narrow(shift_right(widening_mul(a, b), q)) More...
Expr | mul_shift_right (Expr a, Expr b, int q)
Expr | rounding_mul_shift_right (Expr a, Expr b, Expr q)
| Compute saturating_narrow(rounding_shift_right(widening_mul(a, b), q)) More...
Expr | rounding_mul_shift_right (Expr a, Expr b, int q)
Expr | target_arch_is (Target::Arch arch)
| Return a boolean Expr for the corresponding field of the Target being used during lowering; they can be useful in writing library code without having to plumb a Target through call sites, so that you can do things like. More...
Expr | target_os_is (Target::OS os)
Expr | target_has_feature (Target::Feature feat)
Expr | target_bits ()
| Return the bit width of the Target used during lowering; this can be useful in writing library code without having to plumb a Target through call sites, so that you can do things like. More...
Expr | target_natural_vector_size (Type t)
| Return the natural vector width for the given Type for the Target being used during lowering; this can be useful in writing library code without having to plumb a Target through call sites, so that you can do things like. More...
template<typename data_t >
Expr | target_natural_vector_size ()
std::ostream & | operator<< (std::ostream &stream, const Tuple &)
| Emit a tuple on an output stream (such as std::cout) in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const DeviceAPI &)
| Emit a halide device api type in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const MemoryType &)
| Emit a halide memory type in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const TailStrategy &)
| Emit a halide tail strategy in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const Partition &)
| Emit a halide loop partitioning policy in human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const LoopLevel &)
| Emit a halide LoopLevel in human-readable form. More...
Func | lambda (const Expr &e)
| Create a zero-dimensional halide function that returns the given expression. More...
Func | lambda (const Var &x, const Expr &e)
| Create a 1-D halide function in the first argument that returns the second argument. More...
Func | lambda (const Var &x, const Var &y, const Expr &e)
| Create a 2-D halide function in the first two arguments that returns the last argument. More...
Func | lambda (const Var &x, const Var &y, const Var &z, const Expr &e)
| Create a 3-D halide function in the first three arguments that returns the last argument. More...
Func | lambda (const Var &x, const Var &y, const Var &z, const Var &w, const Expr &e)
| Create a 4-D halide function in the first four arguments that returns the last argument. More...
Func | lambda (const Var &x, const Var &y, const Var &z, const Var &w, const Var &v, const Expr &e)
| Create a 5-D halide function in the first five arguments that returns the last argument. More...
std::unique_ptr< llvm::Module > | compile_module_to_llvm_module (const Module &module, llvm::LLVMContext &context)
| Generate an LLVM module. More...
std::unique_ptr< llvm::raw_fd_ostream > | make_raw_fd_ostream (const std::string &filename)
| Construct an llvm output stream for writing to files. More...
void | compile_llvm_module_to_object (llvm::Module &module, Internal::LLVMOStream &out)
| Compile an LLVM module to native targets (objects, native assembly). More...
void | compile_llvm_module_to_assembly (llvm::Module &module, Internal::LLVMOStream &out)
void | compile_llvm_module_to_llvm_bitcode (llvm::Module &module, Internal::LLVMOStream &out)
| Compile an LLVM module to LLVM targets (bitcode, LLVM assembly). More...
void | compile_llvm_module_to_llvm_assembly (llvm::Module &module, Internal::LLVMOStream &out)
void | create_static_library (const std::vector< std::string > &src_files, const Target &target, const std::string &dst_file, bool deterministic=true)
| Concatenate the list of src_files into dst_file, using the appropriate static library format for the given target (e.g., .a or .lib). More...
Module | link_modules (const std::string &name, const std::vector< Module > &modules)
| Link a set of modules together into one module. More...
void | compile_standalone_runtime (const std::string &object_filename, const Target &t)
| Create an object file containing the Halide runtime for a given target. More...
std::map< OutputFileType, std::string > | compile_standalone_runtime (const std::map< OutputFileType, std::string > &output_files, const Target &t)
| Create an object and/or static library file containing the Halide runtime for a given target. More...
void | compile_multitarget (const std::string &fn_name, const std::map< OutputFileType, std::string > &output_files, const std::vector< Target > &targets, const std::vector< std::string > &suffixes, const ModuleFactory &module_factory, const CompilerLoggerFactory &compiler_logger_factory=nullptr)
Expr | user_context_value ()
| Returns an Expr corresponding to the user context passed to the function (if any). More...
std::ostream & | operator<< (std::ostream &stream, const RVar &)
| Emit an RVar in a human-readable form. More...
std::ostream & | operator<< (std::ostream &stream, const RDom &)
| Emit an RDom in a human-readable form. More...
void | serialize_pipeline (const Pipeline &pipeline, std::vector< uint8_t > &data)
| Serialize a Halide pipeline into the given data buffer. More...
void | serialize_pipeline (const Pipeline &pipeline, std::vector< uint8_t > &data, std::map< std::string, Parameter > &params)
| Serialize a Halide pipeline into the given data buffer. More...
void | serialize_pipeline (const Pipeline &pipeline, const std::string &filename)
| Serialize a Halide pipeline into the given filename. More...
void | serialize_pipeline (const Pipeline &pipeline, const std::string &filename, std::map< std::string, Parameter > &params)
| Serialize a Halide pipeline into the given filename. More...
Target | get_host_target ()
| Return the target corresponding to the host machine. More...
Target | get_target_from_environment ()
| Return the target that Halide will use. More...
Target | get_jit_target_from_environment ()
| Return the target that Halide will use for jit-compilation. More...
Target::Feature | target_feature_for_device_api (DeviceAPI api)
| Get the Target feature corresponding to a DeviceAPI. More...
Type | Int (int bits, int lanes=1)
| Constructing a signed integer type. More...
Type | UInt (int bits, int lanes=1)
| Constructing an unsigned integer type. More...
Type | Float (int bits, int lanes=1)
| Construct a floating-point type. More...
Type | BFloat (int bits, int lanes=1)
| Construct a floating-point type in the bfloat format. More...
Type | Bool (int lanes=1)
| Construct a boolean type. More...
Type | Handle (int lanes=1, const halide_handle_cplusplus_type *handle_type=nullptr)
| Construct a handle type. More...
template<typename T >
Type | type_of ()
| Construct the halide equivalent of a C type. More...
std::string | type_to_c_type (Type type, bool include_space, bool c_plus_plus=true)
| Halide type to a C++ type. More...
void | load_plugin (const std::string &lib_name)
| Load a plugin in the form of a dynamic library (e.g. More...
void | set_compiler_stack_size (size_t)
| Set how much stack the compiler should use for compilation in bytes. More...
size_t | get_compiler_stack_size ()
| Return how much stack size the compiler should use for calls that go through run_with_large_stack below. More...
template<typename T >
T | pick_value_in_vector (FuzzedDataProvider &fdp, std::vector< T > &vec)

## Variables
const int | head1_channels = 8
const int | head1_w = 40
const int | head1_h = 7
const int | head2_channels = 24
const int | head2_w = 39
const int | conv1_channels = 32
constexpr int | AnyDims = Halide::Runtime::AnyDims
const DeviceAPI | all_device_apis []
| An array containing all the device apis. More...
constexpr size_t | default_compiler_stack_size = 32 * 1024 * 1024
| The default amount of stack used for lowering and codegen. More...

## Detailed Description

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.

Defines methods for manipulating and analyzing boolean expressions.

This file defines the LoopNest, which is our representation of a Halide schedule, and contains methods to generate candidates for scheduling as well as extract a featurization that can be used to cost each candidate.

## Typedef Documentation

## ◆ GeneratorParamsMap

using Halide::GeneratorParamsMap = typedef std::map<std::string, std::string>

Definition at line 22 of file AbstractGenerator.h.

## ◆ Region

typedef std::vector<Range> Halide::Region

A multi-dimensional box.

The outer product of the elements

Definition at line 350 of file Expr.h.

## ◆ ScheduleHandle

typedef Stage Halide::ScheduleHandle

Definition at line 485 of file Func.h.

## ◆ MetadataNameMap

using Halide::MetadataNameMap = typedef std::map<std::string, std::string>

Definition at line 138 of file Module.h.

## ◆ ModuleFactory

using Halide::ModuleFactory = typedef std::function<Module(const std::string &fn_name, const Target &target)>

Definition at line 242 of file Module.h.

## ◆ CompilerLoggerFactory

using Halide::CompilerLoggerFactory = typedef std::function<std::unique_ptr<Internal::CompilerLogger>(const std::string &fn_name, const Target &target)>

Definition at line 243 of file Module.h.

## ◆ AutoSchedulerFn

using Halide::AutoSchedulerFn = typedef std::function<void(const Pipeline &, const Target &, const AutoschedulerParams &, AutoSchedulerResults *outputs)>

Definition at line 103 of file Pipeline.h.

## Enumeration Type Documentation

## ◆ DeviceAPI

enum class Halide::DeviceAPI
| strong

An enum describing a type of device API.

Used by schedules, and in the For loop IR node.

Enumerator
None |
Host | Used to denote for loops that run on the same device as the containing code.
Default_GPU |
CUDA |
OpenCL |
Metal |
Hexagon |
HexagonDma |
D3D12Compute |
Vulkan |
WebGPU |

Definition at line 15 of file DeviceAPI.h.

## ◆ MemoryType

enum class Halide::MemoryType
| strong

An enum describing different address spaces to be used with Func::store_in.

Enumerator
Auto | Let Halide select a storage type automatically.
Heap | Heap/global memory. Allocated using halide_malloc, or halide_device_malloc
Stack | Stack memory. Allocated using alloca. Requires a constant size. Corresponds to per-thread local memory on the GPU. If all accesses are at constant coordinates, may be promoted into the register file at the discretion of the register allocator.
Register | Register memory. The allocation should be promoted into the register file. All stores must be at constant coordinates. May be spilled to the stack at the discretion of the register allocator.
GPUShared | Allocation is stored in GPU shared memory. Also known as "local" in OpenCL, and "threadgroup" in metal. Can be shared across GPU threads within the same block.
GPUTexture | Allocation is stored in GPU texture memory and accessed through hardware sampler.
LockedCache | Allocate Locked Cache Memory to act as local memory.
VTCM | Vector Tightly Coupled Memory. HVX (Hexagon) local memory available on v65+. This memory has higher performance and lower power. Ideal for intermediate buffers. Necessary for vgather-vscatter instructions on Hexagon
AMXTile | AMX Tile register for X86. Any data that would be used in an AMX matrix multiplication must first be loaded into an AMX tile register.

Definition at line 353 of file Expr.h.

## ◆ NameMangling

enum class Halide::NameMangling
| strong

An enum to specify calling convention for extern stages.

Enumerator
Default | Match whatever is specified in the Target.
C | No name mangling.
CPlusPlus | C++ name mangling.

Definition at line 26 of file Function.h.

## ◆ Partition

enum class Halide::Partition
| strong

Different ways to handle loops with a potentially optimizable boundary conditions.

Enumerator
Auto | Automatically let Halide decide on Loop Parititioning.
Never | Disallow loop partitioning.
Always | Force partitioning of the loop, even in the tail cases of outer partitioned loops. If Halide can't find a way to partition this loop, it will raise an error.

Definition at line 16 of file LoopPartitioningDirective.h.

## ◆ OutputFileType

enum class Halide::OutputFileType
| strong

Enums specifying various kinds of outputs that can be produced from a Halide Pipeline.

Enumerator
assembly |
bitcode |
c_header |
c_source |
compiler_log |
cpp_stub |
featurization |
function_info_header |
hlpipe |
llvm_assembly |
object |
python_extension |
pytorch_wrapper |
registration |
schedule |
static_library |
stmt |
conceptual_stmt |
stmt_html |
conceptual_stmt_html |
device_code |

Definition at line 26 of file Module.h.

## ◆ LinkageType

enum class Halide::LinkageType
| strong

Type of linkage a function in a lowered Halide module can have.

Also controls whether auxiliary functions and metadata are generated.

Enumerator
External | Visible externally.
ExternalPlusMetadata | Visible externally. Argument metadata and an argv wrapper are also generated.
ExternalPlusArgv | Visible externally. Argv wrapper is generated but not argument metadata.
Internal | Not visible externally, similar to 'static' linkage in C.

Definition at line 52 of file Module.h.

## ◆ StmtOutputFormat

enum Halide::StmtOutputFormat

Used to determine if the output printed to file should be as a normal string or as an HTML file which can be opened in a browerser and manipulated via JS and CSS.

Enumerator
Text |
HTML |

Definition at line 72 of file Pipeline.h.

## ◆ PrefetchBoundStrategy

enum class Halide::PrefetchBoundStrategy
| strong

Different ways to handle accesses outside the original extents in a prefetch.

Enumerator
Clamp | Clamp the prefetched exprs by intersecting the prefetched region with the original extents. This may make the exprs of the prefetched region more complicated.
GuardWithIf | Guard the prefetch with if-guards that ignores the prefetch if any of the prefetched region ever goes beyond the original extents (i.e. all or nothing).
NonFaulting | Leave the prefetched exprs as-is (no if-guards around the prefetch and no intersecting with the original extents). This makes the prefetch exprs simpler but this may cause prefetching of the region outside the original extents. This is good if prefetch won't fault when accessing region outside the original extents.

Definition at line 16 of file PrefetchDirective.h.

## ◆ TailStrategy

enum class Halide::TailStrategy
| strong

Different ways to handle a tail case in a split when the factor does not provably divide the extent.

Enumerator
RoundUp | Round up the extent to be a multiple of the split factor. Not legal for RVars, as it would change the meaning of the algorithm. Pros: generates the simplest, fastest code. Cons: if used on a stage that reads from the input or writes to the output, constrains the input or output size to be a multiple of the split factor.
GuardWithIf | Guard the inner loop with an if statement that prevents evaluation beyond the original extent. Always legal. The if statement is treated like a boundary condition, and factored out into a loop epilogue if possible. Pros: no redundant re-evaluation; does not constrain input our output sizes. Cons: increases code size due to separate tail-case handling; vectorization will scalarize in the tail case to handle the if statement.
Predicate | Guard the loads and stores in the loop with an if statement that prevents evaluation beyond the original extent. Always legal. The if statement is treated like a boundary condition, and factored out into a loop epilogue if possible. Pros: no redundant re-evaluation; does not constrain input or output sizes. Cons: increases code size due to separate tail-case handling.
PredicateLoads | Guard the loads in the loop with an if statement that prevents evaluation beyond the original extent. Only legal for innermost splits. Not legal for RVars, as it would change the meaning of the algorithm. The if statement is treated like a boundary condition, and factored out into a loop epilogue if possible. Pros: does not constrain input sizes, output size constraints are simpler than full predication. Cons: increases code size due to separate tail-case handling, constrains the output size to be a multiple of the split factor.
PredicateStores | Guard the stores in the loop with an if statement that prevents evaluation beyond the original extent. Only legal for innermost splits. Not legal for RVars, as it would change the meaning of the algorithm. The if statement is treated like a boundary condition, and factored out into a loop epilogue if possible. Pros: does not constrain output sizes, input size constraints are simpler than full predication. Cons: increases code size due to separate tail-case handling, constraints the input size to be a multiple of the split factor..
ShiftInwards | Prevent evaluation beyond the original extent by shifting the tail case inwards, re-evaluating some points near the end. Only legal for pure variables in pure definitions. If the inner loop is very simple, the tail case is treated like a boundary condition and factored out into an epilogue. This is a good trade-off between several factors. Like RoundUp, it supports vectorization well, because the inner loop is always a fixed size with no data-dependent branching. It increases code size slightly for inner loops due to the epilogue handling, but not for outer loops (e.g. loops over tiles). If used on a stage that reads from an input or writes to an output, this stategy only requires that the input/output extent be at least the split factor, instead of a multiple of the split factor as with RoundUp.
ShiftInwardsAndBlend | Equivalent to ShiftInwards, but protects values that would be re-evaluated by loading the memory location that would be stored to, modifying only the elements not contained within the overlap, and then storing the blended result. This tail strategy is useful when you want to use ShiftInwards to vectorize without a scalar tail, but are scheduling a stage where that isn't legal (e.g. an update definition). Because this is a read - modify - write, this tail strategy cannot be used on any dimension the stage is parallelized over as it would cause a race condition.
RoundUpAndBlend | Equivalent to RoundUp, but protected values that would be written beyond the end by loading the memory location that would be stored to, modifying only the elements within the region being computed, and then storing the blended result. This tail strategy is useful when vectorizing an update to some sub-region of a larger Func. As with ShiftInwardsAndBlend, it can't be combined with parallelism.
Auto | For pure definitions use ShiftInwards. For pure vars in update definitions use RoundUp. For RVars in update definitions use GuardWithIf.

Definition at line 33 of file Schedule.h.

## ◆ LoopAlignStrategy

enum class Halide::LoopAlignStrategy
| strong

Different ways to handle the case when the start/end of the loops of stages computed with (fused) are not aligned.

Enumerator
AlignStart | Shift the start of the fused loops to align.
AlignEnd | Shift the end of the fused loops to align.
NoAlign | compute_with will make no attempt to align the start/end of the fused loops.
Auto | By default, LoopAlignStrategy is set to NoAlign.

Definition at line 137 of file Schedule.h.

## Function Documentation

## ◆ make_default_cost_model() [1/2]

std::unique_ptr< DefaultCostModel > Halide::make_default_cost_model | ( | const std::string & | weights_in_dir = `""`,
|  | const std::string & | weights_out_dir = `""`,
|  | bool | randomize_weights = `false`
| ) |  |

## ◆ make_default_cost_model() [2/2]

std::unique_ptr< DefaultCostModel > Halide::make_default_cost_model | ( | Internal::Autoscheduler::Statistics & | stats,
|  | const std::string & | weights_in_dir = `""`,
|  | const std::string & | weights_out_dir = `""`,
|  | bool | randomize_weights = `false`
| ) |  |

## ◆ codegen_llvm()

std::unique_ptr< llvm::Module > Halide::codegen_llvm | ( | const Module & | module,
|  | llvm::LLVMContext & | context
| ) |  |

Given a Halide module, generate an llvm::Module.

## ◆ cast() [1/3]

Internal::ConstantInterval Halide::cast | ( | Type | t,
|  | const Internal::ConstantInterval & | a
| ) |  |

Cast operators for ConstantIntervals.

These ones have to live out in Halide::, to avoid C++ name lookup confusion with the Halide::cast variants that take Exprs.

Examples
  tutorial/lesson_14_types.cpp.

Referenced by Halide::ConciseCasts::bf16(), cast(), Halide::NamesInterface::cast(), Halide::ConciseCasts::f16(), Halide::ConciseCasts::f32(), Halide::ConciseCasts::f64(), Halide::ConciseCasts::i16(), Halide::ConciseCasts::i32(), Halide::ConciseCasts::i64(), Halide::ConciseCasts::i8(), cmdline::detail::lexical_cast(), Halide::ConciseCasts::u16(), Halide::ConciseCasts::u32(), Halide::ConciseCasts::u64(), and Halide::ConciseCasts::u8().

## ◆ saturating_cast() [1/3]

Internal::ConstantInterval Halide::saturating_cast | ( | Type | t,
|  | const Internal::ConstantInterval & | a
| ) |  |

Referenced by Halide::ConciseCasts::i16_sat(), Halide::ConciseCasts::i32_sat(), Halide::ConciseCasts::i64_sat(), Halide::ConciseCasts::i8_sat(), saturating_cast(), Halide::ConciseCasts::u16_sat(), Halide::ConciseCasts::u32_sat(), Halide::ConciseCasts::u64_sat(), and Halide::ConciseCasts::u8_sat().

## ◆ operator<<() [1/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const Expr & |
| ) |  |

Emit an expression on an output stream (such as std::cout) in human-readable form.

## ◆ operator<<() [2/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const Type & |
| ) |  |

Emit a halide type on an output stream (such as std::cout) in human-readable form.

## ◆ operator<<() [3/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const Module & |
| ) |  |

Emit a halide Module on an output stream (such as std::cout) in human-readable form.

## ◆ operator<<() [4/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const Target & |
| ) |  |

Emit a halide Target in a human readable form.

References Internal.

## ◆ propagate_adjoints() [1/3]

Derivative Halide::propagate_adjoints | ( | const Func & | output,
|  | const Func & | adjoint,
|  | const Region & | output_bounds
| ) |  |

Given a Func and a corresponding adjoint, (back)propagate the adjoint to all dependent Funcs, buffers, and parameters.

The bounds of output and adjoint need to be specified with pair {min, extent} For each Func the output depends on, and for the pure definition and each update of that Func, it generates a derivative Func stored in the Derivative.

## ◆ propagate_adjoints() [2/3]

Derivative Halide::propagate_adjoints | ( | const Func & | output,
|  | const Buffer< float > & | adjoint
| ) |  |

Given a Func and a corresponding adjoint buffer, (back)propagate the adjoint to all dependent Funcs, buffers, and parameters.

For each Func the output depends on, and for the pure definition and each update of that Func, it generates a derivative Func stored in the Derivative.

## ◆ propagate_adjoints() [3/3]

Derivative Halide::propagate_adjoints | ( | const Func & | output | ) |

Given a scalar Func with size 1, (back)propagate the gradient to all dependent Funcs, buffers, and parameters.

For each Func the output depends on, and for the pure definition and each update of that Func, it generates a derivative Func stored in the Derivative.

## ◆ deserialize_pipeline() [1/3]

Pipeline Halide::deserialize_pipeline | ( | const std::string & | filename,
|  | const std::map< std::string, Parameter > & | user_params
| ) |  |

Deserialize a Halide pipeline from a file.

Parameters

  filename | The location of the file to deserialize. Must use .hlpipe extension.
  user_params | Map of named input/output parameters to bind with the resulting pipeline (used to avoid deserializing specific objects and enable the use of externally defined ones instead).

Returns
  Returns a newly constructed deserialized Pipeline object/

## ◆ deserialize_pipeline() [2/3]

Pipeline Halide::deserialize_pipeline | ( | std::istream & | in,
|  | const std::map< std::string, Parameter > & | user_params
| ) |  |

Deserialize a Halide pipeline from an input stream.

Parameters

  in | The input stream to read from containing a serialized Halide pipeline
  user_params | Map of named input/output parameters to bind with the resulting pipeline (used to avoid deserializing specific objects and enable the use of externally defined ones instead).

Returns
  Returns a newly constructed deserialized Pipeline object/

## ◆ deserialize_pipeline() [3/3]

Pipeline Halide::deserialize_pipeline | ( | const std::vector< uint8_t > & | data,
|  | const std::map< std::string, Parameter > & | user_params
| ) |  |

Deserialize a Halide pipeline from a byte buffer containing a serialized pipeline in binary format.

Parameters

  data | The data buffer containing a serialized Halide pipeline
  user_params | Map of named input/output parameters to bind with the resulting pipeline (used to avoid deserializing specific objects and enable the use of externally defined ones instead).

Returns
  Returns a newly constructed deserialized Pipeline object/

## ◆ deserialize_parameters() [1/3]

std::map< std::string, Parameter > Halide::deserialize_parameters | ( | const std::string & | filename | ) |

Deserialize the external parameters for the Halide pipeline from a file.

This method allows a minimal deserialization of just the external pipeline parameters, so they can be remapped and overridden with user parameters prior to deserializing the pipeline definition.

Parameters

  filename | The location of the file to deserialize. Must use .hlpipe extension.

Returns
  Returns a map containing the names and description of external parameters referenced in the pipeline

## ◆ deserialize_parameters() [2/3]

std::map< std::string, Parameter > Halide::deserialize_parameters | ( | std::istream & | in | ) |

Deserialize the external parameters for the Halide pipeline from input stream.

This method allows a minimal deserialization of just the external pipeline parameters, so they can be remapped and overridden with user parameters prior to deserializing the pipeline definition.

Parameters

  in | The input stream to read from containing a serialized Halide pipeline

Returns
  Returns a map containing the names and description of external parameters referenced in the pipeline

## ◆ deserialize_parameters() [3/3]

std::map< std::string, Parameter > Halide::deserialize_parameters | ( | const std::vector< uint8_t > & | data | ) |

Deserialize the external parameters for the Halide pipeline from a byte buffer containing a serialized pipeline in binary format.

This method allows a minimal deserialization of just the external pipeline parameters, so they can be remapped and overridden with user parameters prior to deserializing the pipeline definition.

Parameters

  data | The data buffer containing a serialized Halide pipeline

Returns
  Returns a map containing the names and description of external parameters referenced in the pipeline

## ◆ get_device_interface_for_device_api()

const halide_device_interface_t * Halide::get_device_interface_for_device_api | ( | DeviceAPI | d,
|  | const Target & | t = `get_jit_target_from_environment()`,
|  | const char * | error_site = `nullptr`
| ) |  |

Gets the appropriate halide_device_interface_t * for a DeviceAPI.

If error_site is non-null, e.g. the name of the routine calling get_device_interface_for_device_api, a user_error is reported if the requested device API is not enabled in or supported by the target, Halide has been compiled without this device API, or the device API is None or Host or a bad value. The error_site argument is printed in the error message. If error_site is null, this routine returns nullptr instead of calling user_error.

Referenced by Halide::Buffer< T, Dims >::copy_to_device(), Halide::Buffer< T, Dims >::device_malloc(), and Halide::Buffer< T, Dims >::device_wrap_native().

## ◆ get_default_device_api_for_target()

DeviceAPI Halide::get_default_device_api_for_target | ( | const Target & | t | ) |

Get the specific DeviceAPI that Halide would select when presented with DeviceAPI::Default_GPU for a given target.

If no suitable api is enabled in the target, returns DeviceAPI::Host.

## ◆ host_supports_target_device()

bool Halide::host_supports_target_device | ( | const Target & | t | ) |

This attempts to sniff whether a given Target (and its implied DeviceAPI) is usable on the current host.

If it appears to be usable, return true; if not, return false. Note that a return value of true does not guarantee that future usage of that device will succeed; it is intended mainly as a simple diagnostic to allow early-exit when a desired device is definitely not usable. Also note that this call is NOT threadsafe, as it temporarily redirect various global error-handling hooks in Halide.

Examples
  tutorial/lesson_12_using_the_gpu.cpp.

References Internal.

## ◆ exceptions_enabled()

bool Halide::exceptions_enabled | ( |  | ) |

Query whether Halide was compiled with exceptions.

## ◆ set_custom_compile_time_error_reporter()

void Halide::set_custom_compile_time_error_reporter | ( | CompileTimeErrorReporter * | error_reporter | ) |

The default error reporter logs to stderr, then throws an exception (if HALIDE_WITH_EXCEPTIONS) or calls abort (if not).

This allows customization of that behavior if a more gentle response to error reporting is desired. Note that error_reporter is expected to remain valid across all Halide usage; it is up to the caller to ensure that this is the case (and to do any cleanup necessary).

References Internal.

## ◆ fast_integer_divide()

Expr Halide::fast_integer_divide | ( | const Expr & | numerator,
|  | const Expr & | denominator
| ) |  |

Integer division by small values can be done exactly as multiplies and shifts.

This function does integer division for numerators of various integer types (8, 16, 32 bit signed and unsigned) numerators and uint8 denominators. The type of the result is the type of the numerator. The unsigned version is faster than the signed version, so cast the numerator to an unsigned int if you know it's positive.

If your divisor is compile-time constant, Halide performs a slightly better optimization automatically, so there's no need to use this function (but it won't hurt).

This function vectorizes well on arm, and well on x86 for 16 and 8 bit vectors. For 32-bit vectors on x86 you're better off using native integer division.

Also, this routine treats division by zero as division by

1. I.e. it interprets the uint8 divisor as a number from 1 to 256 inclusive.

## ◆ fast_integer_divide_round_to_zero()

Expr Halide::fast_integer_divide_round_to_zero | ( | const Expr & | numerator,
|  | const Expr & | denominator
| ) |  |

A variant of the above which rounds towards zero instead of rounding towards negative infinity.

## ◆ fast_integer_modulo()

Expr Halide::fast_integer_modulo | ( | const Expr & | numerator,
|  | const Expr & | denominator
| ) |  |

Use the fast integer division tables to implement a modulo operation via the Euclidean identity: ab = a - (a/b)*b.

## ◆ min() [1/9]

Expr Halide::min | ( | const FuncRef & | a,
|  | const FuncRef & | b
| ) |  |
| inline

Explicit overloads of min and max for FuncRef.

These exist to disambiguate calls to min on FuncRefs when a user has pulled both Halide::min and std::min into their namespace.

Examples
  tutorial/lesson_02_input_image.cpp.

Definition at line 603 of file Func.h.

References min().

Referenced by Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Dimension::begin(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::contains(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_interleaved(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::copy_to_planar(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::crop(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::cropped(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Dimension::end(), Halide::Runtime::Internal::make_buffer_copy(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::Dimension::max(), min(), Halide::Param< T >::Param(), Halide::RDom::RDom(), Halide::Runtime::Internal::PointerTable::replace(), Halide::Runtime::Internal::BlockStorage::replace(), Halide::Param< T >::set_min_value(), Halide::Param< T >::set_range(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::slice(), and Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::sliced().

## ◆ max() [1/9]

Expr Halide::max | ( | const FuncRef & | a,
|  | const FuncRef & | b
| ) |  |
| inline

Definition at line 606 of file Func.h.

References max().

Referenced by Halide::Runtime::Internal::BlockAllocator::conform(), Halide::Runtime::Internal::conform_alignment(), Halide::Runtime::Buffer< T, Dims, InClassDimStorage >::contains(), Halide::Runtime::Internal::LinkedList::initialize(), Halide::Runtime::Internal::LinkedList::LinkedList(), max(), Halide::Param< T >::Param(), Halide::Runtime::Internal::PointerTable::replace(), Halide::Runtime::Internal::BlockStorage::replace(), Halide::Runtime::Internal::BlockStorage::reserve(), Halide::Runtime::Internal::PointerTable::reserve(), Halide::Runtime::Internal::BlockStorage::resize(), Halide::Runtime::Internal::PointerTable::resize(), Halide::Param< T >::set_max_value(), and Halide::Param< T >::set_range().

## ◆ evaluate() [1/4]

template<typename T >

HALIDE_NO_USER_CODE_INLINE T Halide::evaluate | ( | JITUserContext * | ctx,
|  | const Expr & | e
| ) |  |

JIT-Compile and run enough code to evaluate a Halide expression.

This can be thought of as a scalar version of Func::realize

Definition at line 2651 of file Func.h.

References Halide::Func::realize(), Halide::Expr::type(), and user_assert.

Referenced by evaluate().

## ◆ evaluate() [2/4]

template<typename T >

HALIDE_NO_USER_CODE_INLINE T Halide::evaluate | ( | const Expr & | e | ) |

evaluate with a default user context

Definition at line 2664 of file Func.h.

## ◆ evaluate() [3/4]

template<typename First , typename... Rest>

HALIDE_NO_USER_CODE_INLINE void Halide::evaluate | ( | JITUserContext * | ctx,
|  | Tuple | t,
|  | First | first,
|  | Rest &&... | rest
| ) |  |

JIT-compile and run enough code to evaluate a Halide Tuple.

Definition at line 2670 of file Func.h.

References Halide::Internal::assign_results(), Halide::Internal::check_types(), and Halide::Func::realize().

## ◆ evaluate() [4/4]

template<typename First , typename... Rest>

HALIDE_NO_USER_CODE_INLINE void Halide::evaluate | ( | Tuple | t,
|  | First | first,
|  | Rest &&... | rest
| ) |  |

JIT-compile and run enough code to evaluate a Halide Tuple.

Definition at line 2681 of file Func.h.

References evaluate().

## ◆ evaluate_may_gpu() [1/2]

template<typename T >

HALIDE_NO_USER_CODE_INLINE T Halide::evaluate_may_gpu | ( | const Expr & | e | ) |

JIT-Compile and run enough code to evaluate a Halide expression.

This can be thought of as a scalar version of Func::realize. Can use GPU if jit target from environment specifies one.

Definition at line 2705 of file Func.h.

References Halide::Func::realize(), Halide::Internal::schedule_scalar(), Halide::Expr::type(), and user_assert.

## ◆ evaluate_may_gpu() [2/2]

template<typename First , typename... Rest>

HALIDE_NO_USER_CODE_INLINE void Halide::evaluate_may_gpu | ( | Tuple | t,
|  | First | first,
|  | Rest &&... | rest
| ) |  |

JIT-compile and run enough code to evaluate a Halide Tuple.

Can use GPU if jit target from environment specifies one.

Definition at line 2721 of file Func.h.

References Halide::Internal::assign_results(), Halide::Internal::check_types(), Halide::Func::realize(), and Halide::Internal::schedule_scalar().

## ◆ operator+() [1/7]

template<typename Other , typename T >

auto Halide::operator+ | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a + (T)b)

Addition between GeneratorParam<T> and any type that supports operator+ with T.

Returns type of underlying operator+.

Definition at line 1014 of file Generator.h.

## ◆ operator+() [2/7]

template<typename Other , typename T >

auto Halide::operator+ | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a + b)

Definition at line 1018 of file Generator.h.

## ◆ operator-() [1/8]

template<typename Other , typename T >

auto Halide::operator- | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a - (T)b)

Subtraction between GeneratorParam<T> and any type that supports operator- with T.

Returns type of underlying operator-.

Definition at line 1027 of file Generator.h.

## ◆ operator-() [2/8]

template<typename Other , typename T >

auto Halide::operator- | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a - b)

Definition at line 1031 of file Generator.h.

## ◆ operator*() [1/7]

template<typename Other , typename T >

auto Halide::operator* | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a * (T)b)

Multiplication between GeneratorParam<T> and any type that supports operator* with T.

Returns type of underlying operator*.

Definition at line 1040 of file Generator.h.

## ◆ operator*() [2/7]

template<typename Other , typename T >

auto Halide::operator* | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a * b)

Definition at line 1044 of file Generator.h.

## ◆ operator/() [1/7]

template<typename Other , typename T >

auto Halide::operator/ | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a / (T)b)

Division between GeneratorParam<T> and any type that supports operator/ with T.

Returns type of underlying operator/.

Definition at line 1053 of file Generator.h.

## ◆ operator/() [2/7]

template<typename Other , typename T >

auto Halide::operator/ | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a / b)

Definition at line 1057 of file Generator.h.

## ◆ operator%() [1/7]

template<typename Other , typename T >

auto Halide::operator% | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a % (T)b)

Modulo between GeneratorParam<T> and any type that supports operator% with T.

Returns type of underlying operator%.

Definition at line 1066 of file Generator.h.

## ◆ operator%() [2/7]

template<typename Other , typename T >

auto Halide::operator% | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a % b)

Definition at line 1070 of file Generator.h.

## ◆ operator>() [1/7]

template<typename Other , typename T >

auto Halide::operator> | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a > (T)b)

Greater than comparison between GeneratorParam<T> and any type that supports operator> with T.

Returns type of underlying operator>.

Definition at line 1079 of file Generator.h.

## ◆ operator>() [2/7]

template<typename Other , typename T >

auto Halide::operator> | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a > b)

Definition at line 1083 of file Generator.h.

## ◆ operator<() [1/7]

template<typename Other , typename T >

auto Halide::operator< | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a < (T)b)

Less than comparison between GeneratorParam<T> and any type that supports operator< with T.

Returns type of underlying operator<.

Definition at line 1092 of file Generator.h.

## ◆ operator<() [2/7]

template<typename Other , typename T >

auto Halide::operator< | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a < b)

Definition at line 1096 of file Generator.h.

## ◆ operator>=() [1/7]

template<typename Other , typename T >

auto Halide::operator>= | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a >= (T)b)

Greater than or equal comparison between GeneratorParam<T> and any type that supports operator>= with T.

Returns type of underlying operator>=.

Definition at line 1105 of file Generator.h.

## ◆ operator>=() [2/7]

template<typename Other , typename T >

auto Halide::operator>= | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a >= b)

Definition at line 1109 of file Generator.h.

## ◆ operator<=() [1/7]

template<typename Other , typename T >

auto Halide::operator<= | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a <= (T)b)

Less than or equal comparison between GeneratorParam<T> and any type that supports operator<= with T.

Returns type of underlying operator<=.

Definition at line 1118 of file Generator.h.

## ◆ operator<=() [2/7]

template<typename Other , typename T >

auto Halide::operator<= | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a <= b)

Definition at line 1122 of file Generator.h.

## ◆ operator==() [1/7]

template<typename Other , typename T >

auto Halide::operator== | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a == (T)b)

Equality comparison between GeneratorParam<T> and any type that supports operator== with T.

Returns type of underlying operator==.

Definition at line 1131 of file Generator.h.

## ◆ operator==() [2/7]

template<typename Other , typename T >

auto Halide::operator== | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a == b)

Definition at line 1135 of file Generator.h.

## ◆ operator!=() [1/7]

template<typename Other , typename T >

auto Halide::operator!= | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a != (T)b)

Inequality comparison between between GeneratorParam<T> and any type that supports operator!= with T.

Returns type of underlying operator!=.

Definition at line 1144 of file Generator.h.

## ◆ operator!=() [2/7]

template<typename Other , typename T >

auto Halide::operator!= | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a != b)

Definition at line 1148 of file Generator.h.

## ◆ operator&&() [1/6]

template<typename Other , typename T >

auto Halide::operator&& | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a && (T)b)

Logical and between between GeneratorParam<T> and any type that supports operator&& with T.

Returns type of underlying operator&&.

Definition at line 1157 of file Generator.h.

## ◆ operator&&() [2/6]

template<typename Other , typename T >

auto Halide::operator&& | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a && b)

Definition at line 1161 of file Generator.h.

## ◆ operator&&() [3/6]

template<typename T >

auto Halide::operator&& | ( | const GeneratorParam< T > & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype((T)a && (T)b)

Definition at line 1165 of file Generator.h.

## ◆ operator||() [1/6]

template<typename Other , typename T >

auto Halide::operator|| | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(a || (T)b)

Logical or between between GeneratorParam<T> and any type that supports operator|| with T.

Returns type of underlying operator||.

Definition at line 1174 of file Generator.h.

## ◆ operator||() [2/6]

template<typename Other , typename T >

auto Halide::operator|| | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype((T)a || b)

Definition at line 1178 of file Generator.h.

## ◆ operator||() [3/6]

template<typename T >

auto Halide::operator|| | ( | const GeneratorParam< T > & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype((T)a || (T)b)

Definition at line 1182 of file Generator.h.

## ◆ min() [2/9]

template<typename Other , typename T >

auto Halide::min | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(Internal::GeneratorMinMax::min_forward(a, b))

Compute minimum between GeneratorParam<T> and any type that supports min with T.

Will automatically import std::min. Returns type of underlying min call.

Definition at line 1222 of file Generator.h.

References Halide::Internal::GeneratorMinMax::min_forward().

## ◆ min() [3/9]

template<typename Other , typename T >

auto Halide::min | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype(Internal::GeneratorMinMax::min_forward(a, b))

Definition at line 1226 of file Generator.h.

References Halide::Internal::GeneratorMinMax::min_forward().

## ◆ max() [2/9]

template<typename Other , typename T >

auto Halide::max | ( | const Other & | a,
|  | const GeneratorParam< T > & | b
| ) |  | -> decltype(Internal::GeneratorMinMax::max_forward(a, b))

Compute the maximum value between GeneratorParam<T> and any type that supports max with T.

Will automatically import std::max. Returns type of underlying max call.

Definition at line 1235 of file Generator.h.

References Halide::Internal::GeneratorMinMax::max_forward().

## ◆ max() [3/9]

template<typename Other , typename T >

auto Halide::max | ( | const GeneratorParam< T > & | a,
|  | const Other & | b
| ) |  | -> decltype(Internal::GeneratorMinMax::max_forward(a, b))

Definition at line 1239 of file Generator.h.

References Halide::Internal::GeneratorMinMax::max_forward().

## ◆ operator!() [1/2]

template<typename T >

auto Halide::operator! | ( | const GeneratorParam< T > & | a | ) | -> decltype(!(T)a)

Not operator for GeneratorParam.

Definition at line 1246 of file Generator.h.

## ◆ create_callable_from_generator() [1/2]

Callable Halide::create_callable_from_generator | ( | const GeneratorContext & | context,
|  | const std::string & | name,
|  | const GeneratorParamsMap & | generator_params = `{}`
| ) |  |

Create a Generator from the currently-registered Generators, use it to create a Callable.

Any GeneratorParams specified will be applied to the Generator before compilation. If the name isn't registered, assert-fail.

## ◆ create_callable_from_generator() [2/2]

Callable Halide::create_callable_from_generator | ( | const Target & | target,
|  | const std::string & | name,
|  | const GeneratorParamsMap & | generator_params = `{}`
| ) |  |

## ◆ sum() [1/4]

Expr Halide::sum | ( | Expr | ,
|  | const std::string & | s = `"sum"`
| ) |  |

An inline reduction.

This is suitable for convolution-type operations - the reduction will be computed in the innermost loop that it is used in. The argument may contain free or implicit variables, and must refer to some reduction domain. The free variables are still free in the return value, but the reduction domain is captured - the result expression does not refer to a reduction domain and can be used in a pure function definition.

An example using sum :

Func f, g;
Var x;
RDom r(0, 10);
f(x) = x*x;
g(x) = sum(f(x + r));
Halide::Func
A halide function.
Definition: Func.h:706
Halide::RDom
A multi-dimensional domain over which to iterate.
Definition: RDom.h:193
Halide::Var
A Halide variable, to be used when defining functions.
Definition: Var.h:19
Halide::sum
Expr sum(Expr, const std::string &s="sum")
An inline reduction.

Here g computes some blur of x, but g is still a pure function. The sum is being computed by an anonymous reduction function that is scheduled innermost within g.

Examples
  tutorial/lesson_09_update_definitions.cpp.

Referenced by do_cost_model_schedule().

## ◆ saturating_sum() [1/4]

Expr Halide::saturating_sum | ( | Expr | ,
|  | const std::string & | s = `"saturating_sum"`
| ) |  |

## ◆ product() [1/4]

Expr Halide::product | ( | Expr | ,
|  | const std::string & | s = `"product"`
| ) |  |

## ◆ maximum() [1/4]

Expr Halide::maximum | ( | Expr | ,
|  | const std::string & | s = `"maximum"`
| ) |  |

Examples
  tutorial/lesson_09_update_definitions.cpp.

Referenced by Halide::SimdOpCheckTest::check_one().

## ◆ minimum() [1/4]

Expr Halide::minimum | ( | Expr | ,
|  | const std::string & | s = `"minimum"`
| ) |  |

Examples
  tutorial/lesson_09_update_definitions.cpp.

## ◆ sum() [2/4]

Expr Halide::sum | ( | const RDom & | ,
|  | Expr | ,
|  | const std::string & | s = `"sum"`
| ) |  |

Variants of the inline reduction in which the RDom is stated explicitly.

The expression can refer to multiple RDoms, and only the inner one is captured by the reduction. This allows you to write expressions like:

RDom r1(0, 10), r2(0, 10), r3(0, 10);
Expr e = minimum(r1, product(r2, sum(r3, r1 + r2 + r3)));
Halide::product
Expr product(Expr, const std::string &s="product")
Halide::minimum
Expr minimum(Expr, const std::string &s="minimum")
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:258

## ◆ saturating_sum() [2/4]

Expr Halide::saturating_sum | ( | const RDom & | r,
|  | Expr | e,
|  | const std::string & | s = `"saturating_sum"`
| ) |  |

## ◆ product() [2/4]

Expr Halide::product | ( | const RDom & | ,
|  | Expr | ,
|  | const std::string & | s = `"product"`
| ) |  |

## ◆ maximum() [2/4]

Expr Halide::maximum | ( | const RDom & | ,
|  | Expr | ,
|  | const std::string & | s = `"maximum"`
| ) |  |

## ◆ minimum() [2/4]

Expr Halide::minimum | ( | const RDom & | ,
|  | Expr | ,
|  | const std::string & | s = `"minimum"`
| ) |  |

## ◆ argmax() [1/4]

Tuple Halide::argmax | ( | Expr | ,
|  | const std::string & | s = `"argmax"`
| ) |  |

Returns an Expr or Tuple representing the coordinates of the point in the RDom which minimizes or maximizes the expression.

The expression must refer to some RDom. Also returns the extreme value of the expression as the last element of the tuple.

## ◆ argmin() [1/4]

Tuple Halide::argmin | ( | Expr | ,
|  | const std::string & | s = `"argmin"`
| ) |  |

Examples
  tutorial/lesson_13_tuples.cpp.

## ◆ argmax() [2/4]

Tuple Halide::argmax | ( | const RDom & | ,
|  | Expr | ,
|  | const std::string & | s = `"argmax"`
| ) |  |

## ◆ argmin() [2/4]

Tuple Halide::argmin | ( | const RDom & | ,
|  | Expr | ,
|  | const std::string & | s = `"argmin"`
| ) |  |

## ◆ sum() [3/4]

Expr Halide::sum | ( | Expr | ,
|  | const Func & |
| ) |  |

Inline reductions create an anonymous helper Func to do the work.

The variants below instead take a named Func object to use, so that it is no longer anonymous and can be scheduled (e.g. unrolled across the reduction domain). The Func passed must not have any existing definition.

## ◆ saturating_sum() [3/4]

Expr Halide::saturating_sum | ( | Expr | ,
|  | const Func & |
| ) |  |

## ◆ product() [3/4]

Expr Halide::product | ( | Expr | ,
|  | const Func & |
| ) |  |

## ◆ maximum() [3/4]

Expr Halide::maximum | ( | Expr | ,
|  | const Func & |
| ) |  |

## ◆ minimum() [3/4]

Expr Halide::minimum | ( | Expr | ,
|  | const Func & |
| ) |  |

## ◆ sum() [4/4]

Expr Halide::sum | ( | const RDom & | ,
|  | Expr | ,
|  | const Func & |
| ) |  |

## ◆ saturating_sum() [4/4]

Expr Halide::saturating_sum | ( | const RDom & | r,
|  | Expr | e,
|  | const Func & |
| ) |  |

## ◆ product() [4/4]

Expr Halide::product | ( | const RDom & | ,
|  | Expr | ,
|  | const Func & |
| ) |  |

## ◆ maximum() [4/4]

Expr Halide::maximum | ( | const RDom & | ,
|  | Expr | ,
|  | const Func & |
| ) |  |

## ◆ minimum() [4/4]

Expr Halide::minimum | ( | const RDom & | ,
|  | Expr | ,
|  | const Func & |
| ) |  |

## ◆ argmax() [3/4]

Tuple Halide::argmax | ( | Expr | ,
|  | const Func & |
| ) |  |

## ◆ argmin() [3/4]

Tuple Halide::argmin | ( | Expr | ,
|  | const Func & |
| ) |  |

## ◆ argmax() [4/4]

Tuple Halide::argmax | ( | const RDom & | ,
|  | Expr | ,
|  | const Func & |
| ) |  |

## ◆ argmin() [4/4]

Tuple Halide::argmin | ( | const RDom & | ,
|  | Expr | ,
|  | const Func & |
| ) |  |

## ◆ cast() [2/3]

template<typename T >

Expr Halide::cast | ( | Expr | a | ) |
| inline

Cast an expression to the halide type corresponding to the C++ type T.

Definition at line 385 of file IROperator.h.

References cast().

## ◆ cast() [3/3]

Expr Halide::cast | ( | Type | t,
|  | Expr | a
| ) |  |

Cast an expression to a new type.

## ◆ operator+() [3/7]

Expr Halide::operator+ | ( | Expr | a,
|  | Expr | b
| ) |  |

Return the sum of two expressions, doing any necessary type coercion using Internal::match_types.

## ◆ operator+() [4/7]

Expr Halide::operator+ | ( | Expr | a,
|  | int | b
| ) |  |

Add an expression and a constant integer.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator+() [5/7]

Expr Halide::operator+ | ( | int | a,
|  | Expr | b
| ) |  |

Add a constant integer and an expression.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator+=()

Expr & Halide::operator+= | ( | Expr & | a,
|  | Expr | b
| ) |  |

Modify the first expression to be the sum of two expressions, without changing its type.

This casts the second argument to match the type of the first.

## ◆ operator-() [3/8]

Expr Halide::operator- | ( | Expr | a,
|  | Expr | b
| ) |  |

Return the difference of two expressions, doing any necessary type coercion using Internal::match_types.

## ◆ operator-() [4/8]

Expr Halide::operator- | ( | Expr | a,
|  | int | b
| ) |  |

Subtracts a constant integer from an expression.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator-() [5/8]

Expr Halide::operator- | ( | int | a,
|  | Expr | b
| ) |  |

Subtracts an expression from a constant integer.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator-() [6/8]

Expr Halide::operator- | ( | Expr | a | ) |

Return the negative of the argument.

Does no type casting, so more formally: return that number which when added to the original, yields zero of the same type. For unsigned integers the negative is still an unsigned integer. E.g. in UInt(8), the negative of 56 is 200, because 56 + 200 == 0

## ◆ operator-=()

Expr & Halide::operator-= | ( | Expr & | a,
|  | Expr | b
| ) |  |

Modify the first expression to be the difference of two expressions, without changing its type.

This casts the second argument to match the type of the first.

## ◆ operator*() [3/7]

Expr Halide::operator* | ( | Expr | a,
|  | Expr | b
| ) |  |

Return the product of two expressions, doing any necessary type coercion using Internal::match_types.

## ◆ operator*() [4/7]

Expr Halide::operator* | ( | Expr | a,
|  | int | b
| ) |  |

Multiply an expression and a constant integer.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator*() [5/7]

Expr Halide::operator* | ( | int | a,
|  | Expr | b
| ) |  |

Multiply a constant integer and an expression.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator*=()

Expr & Halide::operator*= | ( | Expr & | a,
|  | Expr | b
| ) |  |

Modify the first expression to be the product of two expressions, without changing its type.

This casts the second argument to match the type of the first.

## ◆ operator/() [3/7]

Expr Halide::operator/ | ( | Expr | a,
|  | Expr | b
| ) |  |

Return the ratio of two expressions, doing any necessary type coercion using Internal::match_types.

Note that integer division in Halide is not the same as integer division in C-like languages in two ways.

First, signed integer division in Halide rounds according to the sign of the denominator. This means towards minus infinity for positive denominators, and towards positive infinity for negative denominators. This is unlike C, which rounds towards zero. This decision ensures that upsampling expressions like f(x/2, y/2) don't have funny discontinuities when x and y cross zero.

Second, division by zero returns zero instead of faulting. For types where overflow is defined behavior, division of the largest negative signed integer by -1 returns the larged negative signed integer for the type (i.e. it wraps). This ensures that a division operation can never have a side-effect, which is helpful in Halide because scheduling directives can expand the domain of computation of a Func, potentially introducing new zero-division.

## ◆ operator/=()

Expr & Halide::operator/= | ( | Expr & | a,
|  | Expr | b
| ) |  |

Modify the first expression to be the ratio of two expressions, without changing its type.

This casts the second argument to match the type of the first. Note that signed integer division in Halide rounds towards minus infinity, unlike C, which rounds towards zero.

## ◆ operator/() [4/7]

Expr Halide::operator/ | ( | Expr | a,
|  | int | b
| ) |  |

Divides an expression by a constant integer.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator/() [5/7]

Expr Halide::operator/ | ( | int | a,
|  | Expr | b
| ) |  |

Divides a constant integer by an expression.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator%() [3/7]

Expr Halide::operator% | ( | Expr | a,
|  | Expr | b
| ) |  |

Return the first argument reduced modulo the second, doing any necessary type coercion using Internal::match_types.

There are two key differences between C-like languages and Halide for the modulo operation, which complement the way division works.

First, the result is never negative, so x % 2 is always zero or one, unlike in C-like languages. x % -2 is equivalent, and is also always zero or one. Second, mod by zero evaluates to zero (unlike in C, where it faults). This makes modulo, like division, a side-effect-free operation.

## ◆ operator%() [4/7]

Expr Halide::operator% | ( | Expr | a,
|  | int | b
| ) |  |

Mods an expression by a constant integer.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator%() [5/7]

Expr Halide::operator% | ( | int | a,
|  | Expr | b
| ) |  |

Mods a constant integer by an expression.

Coerces the type of the integer to match the type of the expression. Errors if the integer cannot be represented in the type of the expression.

## ◆ operator>() [3/7]

Expr Halide::operator> | ( | Expr | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether the first argument is greater than the second, after doing any necessary type coercion using Internal::match_types.

## ◆ operator>() [4/7]

Expr Halide::operator> | ( | Expr | a,
|  | int | b
| ) |  |

Return a boolean expression that tests whether an expression is greater than a constant integer.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator>() [5/7]

Expr Halide::operator> | ( | int | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether a constant integer is greater than an expression.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator<() [3/7]

Expr Halide::operator< | ( | Expr | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether the first argument is less than the second, after doing any necessary type coercion using Internal::match_types.

## ◆ operator<() [4/7]

Expr Halide::operator< | ( | Expr | a,
|  | int | b
| ) |  |

Return a boolean expression that tests whether an expression is less than a constant integer.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator<() [5/7]

Expr Halide::operator< | ( | int | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether a constant integer is less than an expression.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator<=() [3/7]

Expr Halide::operator<= | ( | Expr | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether the first argument is less than or equal to the second, after doing any necessary type coercion using Internal::match_types.

## ◆ operator<=() [4/7]

Expr Halide::operator<= | ( | Expr | a,
|  | int | b
| ) |  |

Return a boolean expression that tests whether an expression is less than or equal to a constant integer.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator<=() [5/7]

Expr Halide::operator<= | ( | int | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether a constant integer is less than or equal to an expression.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator>=() [3/7]

Expr Halide::operator>= | ( | Expr | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether the first argument is greater than or equal to the second, after doing any necessary type coercion using Internal::match_types.

## ◆ operator>=() [4/7]

Expr Halide::operator>= | ( | const Expr & | a,
|  | int | b
| ) |  |

Return a boolean expression that tests whether an expression is greater than or equal to a constant integer.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator>=() [5/7]

Expr Halide::operator>= | ( | int | a,
|  | const Expr & | b
| ) |  |

Return a boolean expression that tests whether a constant integer is greater than or equal to an expression.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator==() [3/7]

Expr Halide::operator== | ( | Expr | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether the first argument is equal to the second, after doing any necessary type coercion using Internal::match_types.

## ◆ operator==() [4/7]

Expr Halide::operator== | ( | Expr | a,
|  | int | b
| ) |  |

Return a boolean expression that tests whether an expression is equal to a constant integer.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator==() [5/7]

Expr Halide::operator== | ( | int | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether a constant integer is equal to an expression.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator!=() [3/7]

Expr Halide::operator!= | ( | Expr | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether the first argument is not equal to the second, after doing any necessary type coercion using Internal::match_types.

## ◆ operator!=() [4/7]

Expr Halide::operator!= | ( | Expr | a,
|  | int | b
| ) |  |

Return a boolean expression that tests whether an expression is not equal to a constant integer.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator!=() [5/7]

Expr Halide::operator!= | ( | int | a,
|  | Expr | b
| ) |  |

Return a boolean expression that tests whether a constant integer is not equal to an expression.

Coerces the integer to the type of the expression. Errors if the integer is not representable in that type.

## ◆ operator&&() [4/6]

Expr Halide::operator&& | ( | Expr | a,
|  | Expr | b
| ) |  |

Returns the logical and of the two arguments.

## ◆ operator&&() [5/6]

Expr Halide::operator&& | ( | Expr | a,
|  | bool | b
| ) |  |

Logical and of an Expr and a bool.

Either returns the Expr or an Expr representing false, depending on the bool.

## ◆ operator&&() [6/6]

Expr Halide::operator&& | ( | bool | a,
|  | Expr | b
| ) |  |

## ◆ operator||() [4/6]

Expr Halide::operator|| | ( | Expr | a,
|  | Expr | b
| ) |  |

Returns the logical or of the two arguments.

## ◆ operator||() [5/6]

Expr Halide::operator|| | ( | Expr | a,
|  | bool | b
| ) |  |

Logical or of an Expr and a bool.

Either returns the Expr or an Expr representing true, depending on the bool.

## ◆ operator||() [6/6]

Expr Halide::operator|| | ( | bool | a,
|  | Expr | b
| ) |  |

## ◆ operator!() [2/2]

Expr Halide::operator! | ( | Expr | a | ) |

Returns the logical not the argument.

## ◆ max() [4/9]

Expr Halide::max | ( | Expr | a,
|  | Expr | b
| ) |  |

Returns an expression representing the greater of the two arguments, after doing any necessary type coercion using Internal::match_types.

Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4).

## ◆ max() [5/9]

Expr Halide::max | ( | Expr | a,
|  | int | b
| ) |  |

Returns an expression representing the greater of an expression and a constant integer.

The integer is coerced to the type of the expression. Errors if the integer is not representable as that type. Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4).

## ◆ max() [6/9]

Expr Halide::max | ( | int | a,
|  | Expr | b
| ) |  |

Returns an expression representing the greater of a constant integer and an expression.

The integer is coerced to the type of the expression. Errors if the integer is not representable as that type. Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4).

## ◆ max() [7/9]

Expr Halide::max | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 663 of file IROperator.h.

References max().

## ◆ max() [8/9]

Expr Halide::max | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 666 of file IROperator.h.

References max().

## ◆ max() [9/9]

template<typename A , typename B , typename C , typename... Rest, std::enable_if_t< Internal::all_are_convertible< Expr, Rest... >::value > * = nullptr>

Expr Halide::max | ( | A && | a,
|  | B && | b,
|  | C && | c,
|  | Rest &&... | rest
| ) |  |
| inline

Returns an expression representing the greater of an expressions vector, after doing any necessary type coersion using Internal::match_types.

Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4). The expressions are folded from right ie. max(.., max(.., ..)). The arguments can be any mix of types but must all be convertible to Expr.

Definition at line 678 of file IROperator.h.

References max().

## ◆ min() [4/9]

Expr Halide::min | ( | Expr | a,
|  | Expr | b
| ) |  |

## ◆ min() [5/9]

Expr Halide::min | ( | Expr | a,
|  | int | b
| ) |  |

Returns an expression representing the lesser of an expression and a constant integer.

The integer is coerced to the type of the expression. Errors if the integer is not representable as that type. Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4).

## ◆ min() [6/9]

Expr Halide::min | ( | int | a,
|  | Expr | b
| ) |  |

Returns an expression representing the lesser of a constant integer and an expression.

The integer is coerced to the type of the expression. Errors if the integer is not representable as that type. Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4).

## ◆ min() [7/9]

Expr Halide::min | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 698 of file IROperator.h.

References min().

## ◆ min() [8/9]

Expr Halide::min | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 701 of file IROperator.h.

References min().

## ◆ min() [9/9]

template<typename A , typename B , typename C , typename... Rest, std::enable_if_t< Internal::all_are_convertible< Expr, Rest... >::value > * = nullptr>

Expr Halide::min | ( | A && | a,
|  | B && | b,
|  | C && | c,
|  | Rest &&... | rest
| ) |  |
| inline

Returns an expression representing the lesser of an expressions vector, after doing any necessary type coersion using Internal::match_types.

Vectorizes cleanly on most platforms (with the exception of integer types on x86 without SSE4). The expressions are folded from right ie. min(.., min(.., ..)). The arguments can be any mix of types but must all be convertible to Expr.

Definition at line 713 of file IROperator.h.

References min().

## ◆ operator+() [6/7]

Expr Halide::operator+ | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Operators on floats treats those floats as Exprs.

Making these explicit prevents implicit float->int casts that might otherwise occur.

Definition at line 721 of file IROperator.h.

## ◆ operator+() [7/7]

Expr Halide::operator+ | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 724 of file IROperator.h.

## ◆ operator-() [7/8]

Expr Halide::operator- | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 727 of file IROperator.h.

## ◆ operator-() [8/8]

Expr Halide::operator- | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 730 of file IROperator.h.

## ◆ operator*() [6/7]

Expr Halide::operator* | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 733 of file IROperator.h.

## ◆ operator*() [7/7]

Expr Halide::operator* | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 736 of file IROperator.h.

## ◆ operator/() [6/7]

Expr Halide::operator/ | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 739 of file IROperator.h.

## ◆ operator/() [7/7]

Expr Halide::operator/ | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 742 of file IROperator.h.

## ◆ operator%() [6/7]

Expr Halide::operator% | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 745 of file IROperator.h.

## ◆ operator%() [7/7]

Expr Halide::operator% | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 748 of file IROperator.h.

## ◆ operator>() [6/7]

Expr Halide::operator> | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 751 of file IROperator.h.

## ◆ operator>() [7/7]

Expr Halide::operator> | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 754 of file IROperator.h.

## ◆ operator<() [6/7]

Expr Halide::operator< | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 757 of file IROperator.h.

## ◆ operator<() [7/7]

Expr Halide::operator< | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 760 of file IROperator.h.

## ◆ operator>=() [6/7]

Expr Halide::operator>= | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 763 of file IROperator.h.

## ◆ operator>=() [7/7]

Expr Halide::operator>= | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 766 of file IROperator.h.

## ◆ operator<=() [6/7]

Expr Halide::operator<= | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 769 of file IROperator.h.

## ◆ operator<=() [7/7]

Expr Halide::operator<= | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 772 of file IROperator.h.

## ◆ operator==() [6/7]

Expr Halide::operator== | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 775 of file IROperator.h.

## ◆ operator==() [7/7]

Expr Halide::operator== | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 778 of file IROperator.h.

## ◆ operator!=() [6/7]

Expr Halide::operator!= | ( | Expr | a,
|  | float | b
| ) |  |
| inline

Definition at line 781 of file IROperator.h.

## ◆ operator!=() [7/7]

Expr Halide::operator!= | ( | float | a,
|  | Expr | b
| ) |  |
| inline

Definition at line 784 of file IROperator.h.

## ◆ clamp()

Expr Halide::clamp | ( | Expr | a,
|  | const Expr & | min_val,
|  | const Expr & | max_val
| ) |  |

Clamps an expression to lie within the given bounds.

The bounds are type-cast to match the expression. Vectorizes as well as min/max.

Examples
  tutorial/lesson_07_multi_stage_pipelines.cpp, tutorial/lesson_09_update_definitions.cpp, and tutorial/lesson_12_using_the_gpu.cpp.

## ◆ abs()

Expr Halide::abs | ( | Expr | a | ) |

Returns the absolute value of a signed integer or floating-point expression.

Vectorizes cleanly. Unlike in C, abs of a signed integer returns an unsigned integer of the same bit width. This means that abs of the most negative integer doesn't overflow.

## ◆ absd()

Expr Halide::absd | ( | Expr | a,
|  | Expr | b
| ) |  |

Return the absolute difference between two values.

Vectorizes cleanly. Returns an unsigned value of the same bit width. There are various ways to write this yourself, but they contain numerous gotchas and don't always compile to good code, so use this instead.

Referenced by Halide::SimdOpCheckTest::check_one().

## ◆ select() [1/8]

Expr Halide::select | ( | Expr | condition,
|  | Expr | true_value,
|  | Expr | false_value
| ) |  |

Returns an expression similar to the ternary operator in C, except that it always evaluates all arguments.

If the first argument is true, then return the second, else return the third. Typically vectorizes cleanly, but benefits from SSE41 or newer on x86.

Referenced by select().

## ◆ select() [2/8]

template<typename... Args, std::enable_if_t< Internal::all_are_convertible< Expr, Args... >::value > * = nullptr>

Expr Halide::select | ( | Expr | c0,
|  | Expr | v0,
|  | Expr | c1,
|  | Expr | v1,
|  | Args &&... | args
| ) |  |
| inline

A multi-way variant of select similar to a switch statement in C, which can accept multiple conditions and values in pairs.

Evaluates to the first value for which the condition is true. Returns the final value if all conditions are false.

Definition at line 818 of file IROperator.h.

References select().

## ◆ select() [3/8]

Tuple Halide::select | ( | const Tuple & | condition,
|  | const Tuple & | true_value,
|  | const Tuple & | false_value
| ) |  |

Equivalent of ternary select(), but taking/returning tuples.

If the condition is a Tuple, it must match the size of the true and false Tuples.

## ◆ select() [4/8]

Tuple Halide::select | ( | const Expr & | condition,
|  | const Tuple & | true_value,
|  | const Tuple & | false_value
| ) |  |

## ◆ select() [5/8]

template<typename... Args>

Tuple Halide::select | ( | const Tuple & | c0,
|  | const Tuple & | v0,
|  | const Tuple & | c1,
|  | const Tuple & | v1,
|  | Args &&... | args
| ) |  |
| inline

Equivalent of multiway select(), but taking/returning tuples.

If the condition is a Tuple, it must match the size of the true and false Tuples.

Definition at line 833 of file IROperator.h.

References select().

## ◆ select() [6/8]

template<typename... Args>

Tuple Halide::select | ( | const Expr & | c0,
|  | const Tuple & | v0,
|  | const Expr & | c1,
|  | const Tuple & | v1,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 837 of file IROperator.h.

References select().

## ◆ select() [7/8]

Expr Halide::select | ( | const Expr & | condition,
|  | const FuncRef & | true_value,
|  | const FuncRef & | false_value
| ) |  |

select applied to FuncRefs (e.g.

select(x < 100, f(x), g(x))) is assumed to return an Expr. A runtime error is produced if this is applied to tuple-valued Funcs. In that case you should explicitly cast the second and third args to Tuple to remove the ambiguity.

## ◆ select() [8/8]

template<typename... Args>

Expr Halide::select | ( | const Expr & | c0,
|  | const FuncRef & | v0,
|  | const Expr & | c1,
|  | const FuncRef & | v1,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 849 of file IROperator.h.

References select().

## ◆ mux() [1/6]

Expr Halide::mux | ( | const Expr & | id,
|  | const std::initializer_list< Expr > & | values
| ) |  |

Oftentimes we want to pack a list of expressions with the same type into a channel dimension, e.g., img(x, y, c) = select(c == 0, 100, // Red c == 1, 50, // Green 25); // Blue This is tedious when the list is long.

The following function provide convinent syntax that allow one to write: img(x, y, c) = mux(c, {100, 50, 25});

As with the select equivalent, if the first argument (the index) is out of range, the expression evaluates to the last value.

## ◆ mux() [2/6]

Expr Halide::mux | ( | const Expr & | id,
|  | const std::vector< Expr > & | values
| ) |  |

## ◆ mux() [3/6]

Expr Halide::mux | ( | const Expr & | id,
|  | const Tuple & | values
| ) |  |

## ◆ mux() [4/6]

Expr Halide::mux | ( | const Expr & | id,
|  | const std::initializer_list< FuncRef > & | values
| ) |  |

## ◆ mux() [5/6]

Tuple Halide::mux | ( | const Expr & | id,
|  | const std::initializer_list< Tuple > & | values
| ) |  |

## ◆ mux() [6/6]

Tuple Halide::mux | ( | const Expr & | id,
|  | const std::vector< Tuple > & | values
| ) |  |

## ◆ sin()

Expr Halide::sin | ( | Expr | x | ) |

Return the sine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

Examples
  tutorial/lesson_04_debugging_2.cpp, tutorial/lesson_08_scheduling_2.cpp, tutorial/lesson_13_tuples.cpp, and tutorial/lesson_14_types.cpp.

## ◆ asin()

Expr Halide::asin | ( | Expr | x | ) |

Return the arcsine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ cos()

Expr Halide::cos | ( | Expr | x | ) |

Return the cosine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

Examples
  tutorial/lesson_04_debugging_2.cpp, and tutorial/lesson_13_tuples.cpp.

## ◆ acos()

Expr Halide::acos | ( | Expr | x | ) |

Return the arccosine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ tan()

Expr Halide::tan | ( | Expr | x | ) |

Return the tangent of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ atan()

Expr Halide::atan | ( | Expr | x | ) |

Return the arctangent of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ atan2()

Expr Halide::atan2 | ( | Expr | y,
|  | Expr | x
| ) |  |

Return the angle of a floating-point gradient.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ sinh()

Expr Halide::sinh | ( | Expr | x | ) |

Return the hyperbolic sine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ asinh()

Expr Halide::asinh | ( | Expr | x | ) |

Return the hyperbolic arcsinhe of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ cosh()

Expr Halide::cosh | ( | Expr | x | ) |

Return the hyperbolic cosine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ acosh()

Expr Halide::acosh | ( | Expr | x | ) |

Return the hyperbolic arccosine of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ tanh()

Expr Halide::tanh | ( | Expr | x | ) |

Return the hyperbolic tangent of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ atanh()

Expr Halide::atanh | ( | Expr | x | ) |

Return the hyperbolic arctangent of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Does not vectorize well.

## ◆ sqrt()

Expr Halide::sqrt | ( | Expr | x | ) |

Return the square root of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). Typically vectorizes cleanly.

## ◆ hypot()

Expr Halide::hypot | ( | const Expr & | x,
|  | const Expr & | y
| ) |  |

Return the square root of the sum of the squares of two floating-point expressions.

If the argument is not floating-point, it is cast to Float(32). Vectorizes cleanly.

## ◆ exp()

Expr Halide::exp | ( | Expr | x | ) |

Return the exponential of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). For Float(64) arguments, this calls the system exp function, and does not vectorize well. For Float(32) arguments, this function is vectorizable, does the right thing for extremely small or extremely large inputs, and is accurate up to the last bit of the mantissa. Vectorizes cleanly.

## ◆ log()

Expr Halide::log | ( | Expr | x | ) |

Return the logarithm of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). For Float(64) arguments, this calls the system log function, and does not vectorize well. For Float(32) arguments, this function is vectorizable, does the right thing for inputs <= 0 (returns -inf or nan), and is accurate up to the last bit of the mantissa. Vectorizes cleanly.

## ◆ pow()

Expr Halide::pow | ( | Expr | x,
|  | Expr | y
| ) |  |

Return one floating point expression raised to the power of another.

The type of the result is given by the type of the first argument. If the first argument is not a floating-point type, it is cast to Float(32). For Float(32), cleanly vectorizable, and accurate up to the last few bits of the mantissa. Gets worse when approaching overflow. Vectorizes cleanly.

Examples
  tutorial/lesson_12_using_the_gpu.cpp.

## ◆ erf()

Expr Halide::erf | ( | const Expr & | x | ) |

Evaluate the error function erf.

Only available for Float(32). Accurate up to the last three bits of the mantissa. Vectorizes cleanly.

## ◆ fast_sin()

Expr Halide::fast_sin | ( | const Expr & | x | ) |

Fast vectorizable approximation to some trigonometric functions for Float(32).

Absolute approximation error is less than 1e-5. Slow on x86 if you don't have at least sse 4.1.

## ◆ fast_cos()

Expr Halide::fast_cos | ( | const Expr & | x | ) |

## ◆ fast_log()

Expr Halide::fast_log | ( | const Expr & | x | ) |

Fast approximate cleanly vectorizable log for Float(32).

Returns nonsense for x <= 0.0f. Accurate up to the last 5 bits of the mantissa. Vectorizes cleanly. Slow on x86 if you don't have at least sse 4.1.

## ◆ fast_exp()

Expr Halide::fast_exp | ( | const Expr & | x | ) |

Fast approximate cleanly vectorizable exp for Float(32).

Returns nonsense for inputs that would overflow or underflow. Typically accurate up to the last 5 bits of the mantissa. Gets worse when approaching overflow. Vectorizes cleanly. Slow on x86 if you don't have at least sse 4.1.

## ◆ fast_pow()

Expr Halide::fast_pow | ( | Expr | x,
|  | Expr | y
| ) |  |

Fast approximate cleanly vectorizable pow for Float(32).

Returns nonsense for x < 0.0f. Accurate up to the last 5 bits of the mantissa for typical exponents. Gets worse when approaching overflow. Vectorizes cleanly. Slow on x86 if you don't have at least sse 4.1.

## ◆ fast_inverse()

Expr Halide::fast_inverse | ( | Expr | x | ) |

Fast approximate inverse for Float(32).

Corresponds to the rcpps instruction on x86, and the vrecpe instruction on ARM. Vectorizes cleanly. Note that this can produce slightly different results across different implementations of the same architecture (e.g. AMD vs Intel), even when strict_float is enabled.

## ◆ fast_inverse_sqrt()

Expr Halide::fast_inverse_sqrt | ( | Expr | x | ) |

Fast approximate inverse square root for Float(32).

Corresponds to the rsqrtps instruction on x86, and the vrsqrte instruction on ARM. Vectorizes cleanly. Note that this can produce slightly different results across different implementations of the same architecture (e.g. AMD vs Intel), even when strict_float is enabled.

## ◆ floor()

Expr Halide::floor | ( | Expr | x | ) |

Return the greatest whole number less than or equal to a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). The return value is still in floating point, despite being a whole number. Vectorizes cleanly.

Referenced by Halide::Internal::mod_imp< double >().

## ◆ ceil()

Expr Halide::ceil | ( | Expr | x | ) |

Return the least whole number greater than or equal to a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). The return value is still in floating point, despite being a whole number. Vectorizes cleanly.

Referenced by Halide::Internal::Autoscheduler::LocalAccessAccumulator::add_access_info(), and Halide::Internal::next_power_of_two().

## ◆ round()

Expr Halide::round | ( | Expr | x | ) |

Return the whole number closest to a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). The return value is still in floating point, despite being a whole number. On ties, we round towards the nearest even integer. Note that this is not the same as std::round in C, which rounds away from zero. On platforms without a native instruction for this, it is emulated, and may be more expensive than cast<int>(x + 0.5f) or similar.

## ◆ trunc()

Expr Halide::trunc | ( | Expr | x | ) |

Return the integer part of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). The return value is still in floating point, despite being a whole number. Vectorizes cleanly.

## ◆ is_nan()

Expr Halide::is_nan | ( | Expr | x | ) |

Returns true if the argument is a Not a Number (NaN).

Requires a floating point argument. Vectorizes cleanly. Note that the Expr passed in will be evaluated in strict_float mode, regardless of whether strict_float mode is enabled in the current Target.

## ◆ is_inf()

Expr Halide::is_inf | ( | Expr | x | ) |

Returns true if the argument is Inf or -Inf.

Requires a floating point argument. Vectorizes cleanly. Note that the Expr passed in will be evaluated in strict_float mode, regardless of whether strict_float mode is enabled in the current Target.

## ◆ is_finite()

Expr Halide::is_finite | ( | Expr | x | ) |

Returns true if the argument is a finite value (ie, neither NaN nor Inf).

Requires a floating point argument. Vectorizes cleanly. Note that the Expr passed in will be evaluated in strict_float mode, regardless of whether strict_float mode is enabled in the current Target.

## ◆ fract()

Expr Halide::fract | ( | const Expr & | x | ) |

Return the fractional part of a floating-point expression.

If the argument is not floating-point, it is cast to Float(32). The return value has the same sign as the original expression. Vectorizes cleanly.

## ◆ reinterpret() [1/2]

Expr Halide::reinterpret | ( | Type | t,
|  | Expr | e
| ) |  |

Reinterpret the bits of one value as another type.

Referenced by reinterpret(), and Halide::Internal::GeneratorInput_Scalar< T >::set_estimate().

## ◆ reinterpret() [2/2]

template<typename T >

Expr Halide::reinterpret | ( | Expr | e | ) |

Definition at line 1076 of file IROperator.h.

References reinterpret().

## ◆ operator&() [1/3]

Expr Halide::operator& | ( | Expr | x,
|  | Expr | y
| ) |  |

Return the bitwise and of two expressions (which need not have the same type).

The result type is the wider of the two expressions. Only integral types are allowed and both expressions must be signed or both must be unsigned.

## ◆ operator&() [2/3]

Expr Halide::operator& | ( | Expr | x,
|  | int | y
| ) |  |

Return the bitwise and of an expression and an integer.

The type of the result is the type of the expression argument.

## ◆ operator&() [3/3]

Expr Halide::operator& | ( | int | x,
|  | Expr | y
| ) |  |

## ◆ operator|() [1/3]

Expr Halide::operator| | ( | Expr | x,
|  | Expr | y
| ) |  |

Return the bitwise or of two expressions (which need not have the same type).

The result type is the wider of the two expressions. Only integral types are allowed and both expressions must be signed or both must be unsigned.

## ◆ operator|() [2/3]

Expr Halide::operator| | ( | Expr | x,
|  | int | y
| ) |  |

Return the bitwise or of an expression and an integer.

The type of the result is the type of the expression argument.

## ◆ operator|() [3/3]

Expr Halide::operator| | ( | int | x,
|  | Expr | y
| ) |  |

## ◆ operator^() [1/3]

Expr Halide::operator^ | ( | Expr | x,
|  | Expr | y
| ) |  |

Return the bitwise xor of two expressions (which need not have the same type).

The result type is the wider of the two expressions. Only integral types are allowed and both expressions must be signed or both must be unsigned.

## ◆ operator^() [2/3]

Expr Halide::operator^ | ( | Expr | x,
|  | int | y
| ) |  |

Return the bitwise xor of an expression and an integer.

The type of the result is the type of the expression argument.

## ◆ operator^() [3/3]

Expr Halide::operator^ | ( | int | x,
|  | Expr | y
| ) |  |

## ◆ operator~()

Expr Halide::operator~ | ( | Expr | x | ) |

Return the bitwise not of an expression.

## ◆ operator<<() [5/14]

Expr Halide::operator<< | ( | Expr | x,
|  | Expr | y
| ) |  |

Shift the bits of an integer value left.

This is actually less efficient than multiplying by 2^n, because Halide's optimization passes understand multiplication, and will compile it to shifting. This operator is only for if you really really need bit shifting (e.g. because the exponent is a run-time parameter). The type of the result is equal to the type of the first argument. Both arguments must have integer type.

## ◆ operator<<() [6/14]

Expr Halide::operator<< | ( | Expr | x,
|  | int | y
| ) |  |

## ◆ operator>>() [1/2]

Expr Halide::operator>> | ( | Expr | x,
|  | Expr | y
| ) |  |

Shift the bits of an integer value right.

Does sign extension for signed integers. This is less efficient than dividing by a power of two. Halide's definition of division (always round to negative infinity) means that all divisions by powers of two get compiled to bit-shifting, and Halide's optimization routines understand division and can work with it. The type of the result is equal to the type of the first argument. Both arguments must have integer type.

## ◆ operator>>() [2/2]

Expr Halide::operator>> | ( | Expr | x,
|  | int | y
| ) |  |

## ◆ lerp()

Expr Halide::lerp | ( | Expr | zero_val,
|  | Expr | one_val,
|  | Expr | weight
| ) |  |

Linear interpolate between the two values according to a weight.

Parameters

  zero_val | The result when weight is 0
  one_val | The result when weight is 1
  weight | The interpolation amount

Both zero_val and one_val must have the same type. All types are supported, including bool.

The weight is treated as its own type and must be float or an unsigned integer type. It is scaled to the bit-size of the type of x and y if they are integer, or converted to float if they are float. Integer weights are converted to float via division by the full-range value of the weight's type. Floating-point weights used to interpolate between integer values must be between 0.0f and 1.0f, and an error may be signaled if it is not provably so. (clamp operators can be added to provide proof. Currently an error is only signalled for constant weights.)

For integer linear interpolation, out of range values cannot be represented. In particular, weights that are conceptually less than 0 or greater than 1.0 are not representable. As such the result is always between x and y (inclusive of course). For lerp with floating-point values and floating-point weight, the full range of a float is valid, however underflow and overflow can still occur.

Ordering is not required between zero_val and one_val: lerp(42, 69, .5f) == lerp(69, 42, .5f) == 56

Results for integer types are for exactly rounded arithmetic. As such, there are cases where 16-bit and float differ because 32-bit floating-point (float) does not have enough precision to produce the exact result. (Likely true for 32-bit integer vs. double-precision floating-point as well.)

At present, double precision and 64-bit integers are not supported.

Generally, lerp will vectorize as if it were an operation on a type twice the bit size of the inferred type for x and y.

Some examples:

// Since Halide does not have direct type delcarations, casts
// below are used to indicate the types of the parameters.
// Such casts not required or expected in actual code where types
// are inferred.
lerp(cast<float>(x), cast<float>(y), cast<float>(w)) ->
x * (1.0f - w) + y * w
lerp(cast<uint8_t>(x), cast<uint8_t>(y), cast<uint8_t>(w)) ->
cast<uint8_t>(cast<uint8_t>(x) * (1.0f - cast<uint8_t>(w) / 255.0f) +
cast<uint8_t>(y) * cast<uint8_t>(w) / 255.0f + .5f)
// Note addition in Halide promoted uint8_t + int8_t to int16_t already,
// the outer cast is added for clarity.
lerp(cast<uint8_t>(x), cast<int8_t>(y), cast<uint8_t>(w)) ->
cast<int16_t>(cast<uint8_t>(x) * (1.0f - cast<uint8_t>(w) / 255.0f) +
cast<int8_t>(y) * cast<uint8_t>(w) / 255.0f + .5f)
lerp(cast<int8_t>(x), cast<int8_t>(y), cast<float>(w)) ->
cast<int8_t>(cast<int8_t>(x) * (1.0f - cast<float>(w)) +
cast<int8_t>(y) * cast<uint8_t>(w))
Halide::lerp
Expr lerp(Expr zero_val, Expr one_val, Expr weight)
Linear interpolate between the two values according to a weight.

## ◆ popcount()

Expr Halide::popcount | ( | Expr | x | ) |

Count the number of set bits in an expression.

## ◆ count_leading_zeros()

Expr Halide::count_leading_zeros | ( | Expr | x | ) |

Count the number of leading zero bits in an expression.

If the expression is zero, the result is the number of bits in the type.

## ◆ count_trailing_zeros()

Expr Halide::count_trailing_zeros | ( | Expr | x | ) |

Count the number of trailing zero bits in an expression.

If the expression is zero, the result is the number of bits in the type.

## ◆ div_round_to_zero()

Expr Halide::div_round_to_zero | ( | Expr | x,
|  | Expr | y
| ) |  |

Divide two integers, rounding towards zero.

This is the typical behavior of most hardware architectures, which differs from Halide's division operator, which is Euclidean (rounds towards -infinity). Will throw a runtime error if y is zero, or if y is -1 and x is the minimum signed integer.

## ◆ mod_round_to_zero()

Expr Halide::mod_round_to_zero | ( | Expr | x,
|  | Expr | y
| ) |  |

Compute the remainder of dividing two integers, when division is rounding toward zero.

This is the typical behavior of most hardware architectures, which differs from Halide's mod operator, which is Euclidean (produces the remainder when division rounds towards -infinity). Will throw a runtime error if y is zero.

## ◆ random_float()

Expr Halide::random_float | ( | Expr | seed = `Expr()` | ) |

Return a random variable representing a uniformly distributed float in the half-open interval [0.0f, 1.0f).

For random numbers of other types, use lerp with a random float as the last parameter.

Optionally takes a seed.

Note that:

Expr x = random_float();
Expr y = x + x;
Halide::random_float
Expr random_float(Expr seed=Expr())
Return a random variable representing a uniformly distributed float in the half-open interval [0....

is very different to

Expr y = random_float() + random_float();

The first doubles a random variable, and the second adds two independent random variables.

A given random variable takes on a unique value that depends deterministically on the pure variables of the function they belong to, the identity of the function itself, and which definition of the function it is used in. They are, however, shared across tuple elements.

This function vectorizes cleanly.

## ◆ random_uint()

Expr Halide::random_uint | ( | Expr | seed = `Expr()` | ) |

Return a random variable representing a uniformly distributed unsigned 32-bit integer.

See random_float. Vectorizes cleanly.

## ◆ random_int()

Expr Halide::random_int | ( | Expr | seed = `Expr()` | ) |

Return a random variable representing a uniformly distributed 32-bit integer.

See random_float. Vectorizes cleanly.

## ◆ print() [1/2]

Expr Halide::print | ( | const std::vector< Expr > & | values | ) |

Create an Expr that prints out its value whenever it is evaluated.

It also prints out everything else in the arguments list, separated by spaces. This can include string literals.

Examples
  tutorial/lesson_04_debugging_2.cpp.

Referenced by print().

## ◆ print() [2/2]

template<typename... Args>

HALIDE_NO_USER_CODE_INLINE Expr Halide::print | ( | Expr | a,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 1286 of file IROperator.h.

References Halide::Internal::collect_print_args(), and print().

## ◆ print_when() [1/2]

Expr Halide::print_when | ( | Expr | condition,
|  | const std::vector< Expr > & | values
| ) |  |

Create an Expr that prints whenever it is evaluated, provided that the condition is true.

Examples
  tutorial/lesson_04_debugging_2.cpp.

Referenced by print_when().

## ◆ print_when() [2/2]

template<typename... Args>

HALIDE_NO_USER_CODE_INLINE Expr Halide::print_when | ( | Expr | condition,
|  | Expr | a,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 1299 of file IROperator.h.

References Halide::Internal::collect_print_args(), and print_when().

## ◆ require() [1/2]

Expr Halide::require | ( | Expr | condition,
|  | const std::vector< Expr > & | values
| ) |  |

Create an Expr that that guarantees a precondition.

If 'condition' is true, the return value is equal to the first Expr. If 'condition' is false, halide_error() is called, and the return value is arbitrary. Any additional arguments after the first Expr are stringified and passed as a user-facing message to halide_error(), similar to print().

Note that this essentially always inserts a runtime check into the generated code (except when the condition can be proven at compile time); as such, it should be avoided inside inner loops, except for debugging or testing purposes. Note also that it does not vectorize cleanly (vector values will be scalarized for the check).

However, using this to make assertions about (say) input values can be useful, both in terms of correctness and (potentially) in terms of code generation, e.g.

Param<int> p;
Expr y = require(p > 0, p);
Halide::Param
A scalar parameter to a halide pipeline.
Definition: Param.h:22
Halide::require
Expr require(Expr condition, const std::vector< Expr > &values)
Create an Expr that that guarantees a precondition.

will allow the optimizer to assume positive, nonzero values for y.

Referenced by require().

## ◆ require() [2/2]

template<typename... Args>

HALIDE_NO_USER_CODE_INLINE Expr Halide::require | ( | Expr | condition,
|  | Expr | value,
|  | Args &&... | args
| ) |  |
| inline

Definition at line 1332 of file IROperator.h.

References Halide::Internal::collect_print_args(), and require().

## ◆ undef() [1/2]

Expr Halide::undef | ( | Type | t | ) |

Return an undef value of the given type.

Halide skips stores that depend on undef values, so you can use this to mean "do not modify this memory location". This is an escape hatch that can be used for several things:

You can define a reduction with no pure step, by setting the pure step to undef. Do this only if you're confident that the update steps are sufficient to correctly fill in the domain.

For a tuple-valued reduction, you can write an update step that only updates some tuple elements.

You can define single-stage pipeline that only has update steps, and depends on the values already in the output buffer.

Use this feature with great caution, as you can use it to load from uninitialized memory.

Referenced by undef().

## ◆ undef() [2/2]

template<typename T >

Expr Halide::undef | ( |  | ) |
| inline

Definition at line 1360 of file IROperator.h.

References undef().

## ◆ memoize_tag()

template<typename... Args>

HALIDE_NO_USER_CODE_INLINE Expr Halide::memoize_tag | ( | Expr | result,
|  | Args &&... | args
| ) |  |
| inline

Control the values used in the memoization cache key for memoize.

Normally parameters and other external dependencies are automatically inferred and added to the cache key. The memoize_tag operator allows computing one expression and using either the computed value, or one or more other expressions in the cache key instead of the parameter dependencies of the computation. The single argument version is completely safe in that the cache key will use the actual computed value – it is difficult or imposible to produce erroneous caching this way. The more-than-one argument version allows generating cache keys that do not uniquely identify the computation and thus can result in caching errors.

A potential use for the single argument version is to handle a floating-point parameter that is quantized to a small integer. Mutliple values of the float will produce the same integer and moving the caching to using the integer for the key is more efficient.

The main use for the more-than-one argument version is to provide cache key information for Handles and ImageParams, which otherwise are not allowed inside compute_cached operations. E.g. when passing a group of parameters to an external array function via a Handle, memoize_tag can be used to isolate the actual values used by that computation. If an ImageParam is a constant image with a persistent digest, memoize_tag can be used to key computations using that image on the digest.

Definition at line 1407 of file IROperator.h.

References Halide::Internal::memoize_tag_helper().

## ◆ likely()

Expr Halide::likely | ( | Expr | e | ) |

Expressions tagged with this intrinsic are considered to be part of the steady state of some loop with a nasty beginning and end (e.g.

a boundary condition). When Halide encounters likely intrinsics, it splits the containing loop body into three, and tries to simplify down all conditions that lead to the likely. For example, given the expression: select(x < 1, bar, x > 10, bar, likely(foo)), Halide will split the loop over x into portions where x < 1, 1 <= x <= 10, and x > 10.

You're unlikely to want to call this directly. You probably want to use the boundary condition helpers in the BoundaryConditions namespace instead.

## ◆ likely_if_innermost()

Expr Halide::likely_if_innermost | ( | Expr | e | ) |

Equivalent to likely, but only triggers a loop partitioning if found in an innermost loop.

## ◆ saturating_cast() [2/3]

template<typename T >

Expr Halide::saturating_cast | ( | Expr | e | ) |

Cast an expression to the halide type corresponding to the C++ type T.

As part of the cast, clamp to the minimum and maximum values of the result type.

Definition at line 1436 of file IROperator.h.

References saturating_cast().

## ◆ saturating_cast() [3/3]

Expr Halide::saturating_cast | ( | Type | t,
|  | Expr | e
| ) |  |

Cast an expression to a new type, clamping to the minimum and maximum values of the result type.

## ◆ strict_float()

Expr Halide::strict_float | ( | const Expr & | e | ) |

Makes a best effort attempt to preserve IEEE floating-point semantics in evaluating an expression.

May not be implemented for all backends. (E.g. it is difficult to do this for C++ code generation as it depends on the compiler flags used to compile the generated code.

## ◆ unsafe_promise_clamped()

Expr Halide::unsafe_promise_clamped | ( | const Expr & | value,
|  | const Expr & | min,
|  | const Expr & | max
| ) |  |

Create an Expr that that promises another Expr is clamped but do not generate code to check the assertion or modify the value.

No attempt is made to prove the bound at compile time. (If it is proved false as a result of something else, an error might be generated, but it is also possible the compiler will crash.) The promised bound is used in bounds inference so it will allow satisfying bounds checks as well as possibly aiding optimization.

unsafe_promise_clamped returns its first argument, the Expr 'value'

This is a very easy way to make Halide generate erroneous code if the bound promises is not kept. Use sparingly when there is no other way to convey the information to the compiler and it is required for a valuable optimization.

Unsafe promises can be checked by turning on Target::CheckUnsafePromises. This is intended for debugging only.

References Internal.

## ◆ scatter() [1/2]

Expr Halide::scatter | ( | const std::vector< Expr > & | args | ) |

Scatter and gather are used for update definition which must store multiple values to distinct locations at the same time.

The multiple expressions on the right-hand-side are bundled together into a "gather", which must match a "scatter" the the same number of arguments on the left-hand-size. For example, to store the values 1 and 2 to the locations (x, y, 3) and (x, y, 4), respectively:

f(x, y, scatter(3, 4)) = gather(1, 2);
Halide::gather
Expr gather(const std::vector< Expr > &args)
Halide::scatter
Expr scatter(const std::vector< Expr > &args)
Scatter and gather are used for update definition which must store multiple values to distinct locati...

The result of gather or scatter can be treated as an expression. Any containing operations on it can be assumed to distribute over the elements. If two gather expressions are combined with an arithmetic operator (e.g. added), they combine element-wise. The following example stores the values 2 * x, 2 * y, and 2 * c to the locations (x + 1, y, c), (x, y + 3, c), and (x, y, c + 2) respectively:

f(x + scatter(1, 0, 0), y + scatter(0, 3, 0), c + scatter(0, 0, 2)) = 2 * gather(x, y, c);

Repeated values in the scatter cause multiple stores to the same location. The stores happen in order from left to right, so the rightmost value wins. The following code is equivalent to f(x) = 5

f(scatter(x, x)) = gather(3, 5);

Gathers are most useful for algorithms which require in-place swapping or permutation of multiple elements, or other kinds of in-place mutations that require loading multiple inputs, doing some operations to them jointly, then storing them again. The following update definition swaps the values of f at locations 3 and 5 if an input parameter p is true:

f(scatter(3, 5)) = f(select(p, gather(5, 3), gather(3, 5)));
Halide::select
Expr select(Expr condition, Expr true_value, Expr false_value)
Returns an expression similar to the ternary operator in C, except that it always evaluates all argum...

For more examples of the use of scatter and gather, see test/correctness/multiple_scatter.cpp

It is not currently possible to use scatter and gather to write an update definition in which the number of values loaded or stored varies, as the size of the scatter/gather packet must be fixed a compile-time. A workaround is to make the unwanted extra operations a redundant copy of the last operation, which will be dead-code-eliminated by the compiler. For example, the following update definition swaps the values at locations 3 and 5 when the parameter p is true, and rotates the values at locations 1, 2, and 3 when it is false. The load from 3 and store to 5 will be redundantly repeated:

f(select(p, scatter(3, 5, 5), scatter(1, 2, 3))) = f(select(p, gather(5, 3, 3), gather(2, 3, 1)));

Note that in the p == true case, we redundantly load from 3 and write to 5 twice.

Referenced by scatter().

## ◆ gather() [1/2]

Expr Halide::gather | ( | const std::vector< Expr > & | args | ) |

Referenced by gather().

## ◆ scatter() [2/2]

template<typename... Args>

Expr Halide::scatter | ( | const Expr & | e,
|  | Args &&... | args
| ) |  |

Definition at line 1569 of file IROperator.h.

References scatter().

## ◆ gather() [2/2]

template<typename... Args>

Expr Halide::gather | ( | const Expr & | e,
|  | Args &&... | args
| ) |  |

Definition at line 1574 of file IROperator.h.

References gather().

## ◆ extract_bits() [1/2]

Expr Halide::extract_bits | ( | Type | t,
|  | const Expr & | e,
|  | const Expr & | lsb
| ) |  |

Extract a contiguous subsequence of the bits of 'e', starting at the bit index given by 'lsb', where zero is the least-significant bit, returning a value of type 't'.

Any out-of-range bits requested are filled with zeros.

extract_bits is especially useful when one wants to load a small vector of a wide type, and treat it as a larger vector of a smaller type. For example, loading a vector of 32 uint8 values from a uint32 Func can be done as follows:

f8(x) = extract_bits<uint8_t>(f32(x/4), 8*(x%4));
f8.align_bounds(x, 4).vectorize(x, 32);
Halide::ConciseCasts::f32
Expr f32(Expr e)
Definition: ConciseCasts.h:23

Note that the align_bounds call is critical so that the narrow Exprs are aligned to the wider Exprs. This makes the x%4 term collapse to a constant. If f8 is an output Func, then constraining the min value of x to be a known multiple of four would also be sufficient, e.g. via:

f8.output_buffer().dim(0).set_min(0);

See test/correctness/extract_concat_bits.cpp for a complete example.

Referenced by extract_bits().

## ◆ extract_bits() [2/2]

template<typename T >

Expr Halide::extract_bits | ( | const Expr & | e,
|  | const Expr & | lsb
| ) |  |

Definition at line 1604 of file IROperator.h.

References extract_bits().

## ◆ concat_bits()

Expr Halide::concat_bits | ( | const std::vector< Expr > & | e | ) |

Given a number of Exprs of the same type, concatenate their bits producing a single Expr of the same type code of the input but with more bits.

The number of arguments must be a power of two.

concat_bits is especially useful when one wants to treat a Func containing values of a narrow type as a Func containing fewer values of a wider type. For example, the following code reinterprets vectors of 32 uint8 values as a vector of 8 uint32s:

f32(x) = concat_bits({f8(4*x), f8(4*x + 1), f8(4*x + 2), f8(4*x + 3)});
f32.vectorize(x, 8);
Halide::concat_bits
Expr concat_bits(const std::vector< Expr > &e)
Given a number of Exprs of the same type, concatenate their bits producing a single Expr of the same ...

See test/correctness/extract_concat_bits.cpp for a complete example.

## ◆ widen_right_add()

Expr Halide::widen_right_add | ( | Expr | a,
|  | Expr | b
| ) |  |

Below is a collection of intrinsics for fixed-point programming.

Most of them can be expressed via other means, but this is more natural for some, as it avoids ghost widened intermediates that don't (or shouldn't) actually show up in codegen, and doesn't rely on pattern-matching inside the compiler to succeed to get good instruction selection.

The semantics of each call are defined in terms of a non-existent 'widen' and 'narrow' operators, which stand in for casts that double or halve the bit-width of a type respectively. Compute a + widen(b).

## ◆ widen_right_mul()

Expr Halide::widen_right_mul | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute a * widen(b).

## ◆ widen_right_sub()

Expr Halide::widen_right_sub | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute a - widen(b).

## ◆ widening_add()

Expr Halide::widening_add | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute widen(a) + widen(b).

## ◆ widening_mul()

Expr Halide::widening_mul | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute widen(a) * widen(b).

a and b may have different signedness, in which case the result is signed.

## ◆ widening_sub()

Expr Halide::widening_sub | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute widen(a) - widen(b).

The result is always signed.

## ◆ widening_shift_left() [1/2]

Expr Halide::widening_shift_left | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute widen(a) << b.

## ◆ widening_shift_left() [2/2]

Expr Halide::widening_shift_left | ( | Expr | a,
|  | int | b
| ) |  |

## ◆ widening_shift_right() [1/2]

Expr Halide::widening_shift_right | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute widen(a) >> b.

## ◆ widening_shift_right() [2/2]

Expr Halide::widening_shift_right | ( | Expr | a,
|  | int | b
| ) |  |

## ◆ rounding_shift_left() [1/2]

Expr Halide::rounding_shift_left | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute saturating_narrow(widening_add(a, (1 >> min(b, 0)) / 2) << b).

When b is positive indicating a left shift, the rounding term is zero.

## ◆ rounding_shift_left() [2/2]

Expr Halide::rounding_shift_left | ( | Expr | a,
|  | int | b
| ) |  |

## ◆ rounding_shift_right() [1/2]

Expr Halide::rounding_shift_right | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute saturating_narrow(widening_add(a, (1 << max(b, 0)) / 2) >> b).

When b is negative indicating a left shift, the rounding term is zero.

## ◆ rounding_shift_right() [2/2]

Expr Halide::rounding_shift_right | ( | Expr | a,
|  | int | b
| ) |  |

## ◆ saturating_add()

Expr Halide::saturating_add | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute saturating_narrow(widen(a) + widen(b))

## ◆ saturating_sub()

Expr Halide::saturating_sub | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute saturating_narrow(widen(a) - widen(b))

## ◆ halving_add()

Expr Halide::halving_add | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute narrow((widen(a) + widen(b)) / 2)

## ◆ rounding_halving_add()

Expr Halide::rounding_halving_add | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute narrow((widen(a) + widen(b) + 1) / 2)

## ◆ halving_sub()

Expr Halide::halving_sub | ( | Expr | a,
|  | Expr | b
| ) |  |

Compute narrow((widen(a) - widen(b)) / 2)

## ◆ mul_shift_right() [1/2]

Expr Halide::mul_shift_right | ( | Expr | a,
|  | Expr | b,
|  | Expr | q
| ) |  |

Compute saturating_narrow(shift_right(widening_mul(a, b), q))

## ◆ mul_shift_right() [2/2]

Expr Halide::mul_shift_right | ( | Expr | a,
|  | Expr | b,
|  | int | q
| ) |  |

## ◆ rounding_mul_shift_right() [1/2]

Expr Halide::rounding_mul_shift_right | ( | Expr | a,
|  | Expr | b,
|  | Expr | q
| ) |  |

Compute saturating_narrow(rounding_shift_right(widening_mul(a, b), q))

## ◆ rounding_mul_shift_right() [2/2]

Expr Halide::rounding_mul_shift_right | ( | Expr | a,
|  | Expr | b,
|  | int | q
| ) |  |

## ◆ target_arch_is()

Expr Halide::target_arch_is | ( | Target::Arch | arch | ) |

Return a boolean Expr for the corresponding field of the Target being used during lowering; they can be useful in writing library code without having to plumb a Target through call sites, so that you can do things like.

Expr e = select(target_arch_is(Target::ARM), something, something_else);
Halide::target_arch_is
Expr target_arch_is(Target::Arch arch)
Return a boolean Expr for the corresponding field of the Target being used during lowering; they can ...
Halide::Target::ARM
@ ARM
Definition: Target.h:42

Note that this doesn't do any checking at runtime to verify that the Target is valid for the current hardware configuration.

## ◆ target_os_is()

Expr Halide::target_os_is | ( | Target::OS | os | ) |

## ◆ target_has_feature()

Expr Halide::target_has_feature | ( | Target::Feature | feat | ) |

## ◆ target_bits()

Expr Halide::target_bits | ( |  | ) |

Return the bit width of the Target used during lowering; this can be useful in writing library code without having to plumb a Target through call sites, so that you can do things like.

Expr e = select(target_bits() == 32, something, something_else);
Halide::target_bits
Expr target_bits()
Return the bit width of the Target used during lowering; this can be useful in writing library code w...

Note that this doesn't do any checking at runtime to verify that the Target is valid for the current hardware configuration.

## ◆ target_natural_vector_size() [1/2]

Expr Halide::target_natural_vector_size | ( | Type | t | ) |

Return the natural vector width for the given Type for the Target being used during lowering; this can be useful in writing library code without having to plumb a Target through call sites, so that you can do things like.

f.vectorize(x, target_natural_vector_size(Float(32)));
Halide::Float
Type Float(int bits, int lanes=1)
Construct a floating-point type.
Definition: Type.h:551
Halide::target_natural_vector_size
Expr target_natural_vector_size(Type t)
Return the natural vector width for the given Type for the Target being used during lowering; this ca...

Note that this doesn't do any checking at runtime to verify that the Target is valid for the current hardware configuration.

Referenced by target_natural_vector_size().

## ◆ target_natural_vector_size() [2/2]

template<typename data_t >

Expr Halide::target_natural_vector_size | ( |  | ) |

Definition at line 1750 of file IROperator.h.

References target_natural_vector_size().

## ◆ operator<<() [7/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const Tuple & |
| ) |  |

Emit a tuple on an output stream (such as std::cout) in human-readable form.

## ◆ operator<<() [8/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const DeviceAPI & |
| ) |  |

Emit a halide device api type in human-readable form.

## ◆ operator<<() [9/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const MemoryType & |
| ) |  |

Emit a halide memory type in human-readable form.

## ◆ operator<<() [10/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const TailStrategy & |
| ) |  |

Emit a halide tail strategy in human-readable form.

## ◆ operator<<() [11/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const Partition & |
| ) |  |

Emit a halide loop partitioning policy in human-readable form.

## ◆ operator<<() [12/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const LoopLevel & |
| ) |  |

Emit a halide LoopLevel in human-readable form.

References Internal.

## ◆ lambda() [1/6]

Func Halide::lambda | ( | const Expr & | e | ) |

Create a zero-dimensional halide function that returns the given expression.

The function may have more dimensions if the expression contains implicit arguments.

Referenced by Halide::BoundaryConditions::Internal::func_like_to_func().

## ◆ lambda() [2/6]

Func Halide::lambda | ( | const Var & | x,
|  | const Expr & | e
| ) |  |

Create a 1-D halide function in the first argument that returns the second argument.

The function may have more dimensions if the expression contains implicit arguments and the list of Var arguments contains a placeholder ("_").

## ◆ lambda() [3/6]

Func Halide::lambda | ( | const Var & | x,
|  | const Var & | y,
|  | const Expr & | e
| ) |  |

Create a 2-D halide function in the first two arguments that returns the last argument.

The function may have more dimensions if the expression contains implicit arguments and the list of Var arguments contains a placeholder ("_").

## ◆ lambda() [4/6]

Func Halide::lambda | ( | const Var & | x,
|  | const Var & | y,
|  | const Var & | z,
|  | const Expr & | e
| ) |  |

Create a 3-D halide function in the first three arguments that returns the last argument.

The function may have more dimensions if the expression contains implicit arguments and the list of Var arguments contains a placeholder ("_").

## ◆ lambda() [5/6]

Func Halide::lambda | ( | const Var & | x,
|  | const Var & | y,
|  | const Var & | z,
|  | const Var & | w,
|  | const Expr & | e
| ) |  |

Create a 4-D halide function in the first four arguments that returns the last argument.

The function may have more dimensions if the expression contains implicit arguments and the list of Var arguments contains a placeholder ("_").

## ◆ lambda() [6/6]

Func Halide::lambda | ( | const Var & | x,
|  | const Var & | y,
|  | const Var & | z,
|  | const Var & | w,
|  | const Var & | v,
|  | const Expr & | e
| ) |  |

Create a 5-D halide function in the first five arguments that returns the last argument.

The function may have more dimensions if the expression contains implicit arguments and the list of Var arguments contains a placeholder ("_").

## ◆ compile_module_to_llvm_module()

std::unique_ptr< llvm::Module > Halide::compile_module_to_llvm_module | ( | const Module & | module,
|  | llvm::LLVMContext & | context
| ) |  |

Generate an LLVM module.

## ◆ make_raw_fd_ostream()

std::unique_ptr< llvm::raw_fd_ostream > Halide::make_raw_fd_ostream | ( | const std::string & | filename | ) |

Construct an llvm output stream for writing to files.

## ◆ compile_llvm_module_to_object()

void Halide::compile_llvm_module_to_object | ( | llvm::Module & | module,
|  | Internal::LLVMOStream & | out
| ) |  |

Compile an LLVM module to native targets (objects, native assembly).

## ◆ compile_llvm_module_to_assembly()

void Halide::compile_llvm_module_to_assembly | ( | llvm::Module & | module,
|  | Internal::LLVMOStream & | out
| ) |  |

## ◆ compile_llvm_module_to_llvm_bitcode()

void Halide::compile_llvm_module_to_llvm_bitcode | ( | llvm::Module & | module,
|  | Internal::LLVMOStream & | out
| ) |  |

Compile an LLVM module to LLVM targets (bitcode, LLVM assembly).

## ◆ compile_llvm_module_to_llvm_assembly()

void Halide::compile_llvm_module_to_llvm_assembly | ( | llvm::Module & | module,
|  | Internal::LLVMOStream & | out
| ) |  |

## ◆ create_static_library()

void Halide::create_static_library | ( | const std::vector< std::string > & | src_files,
|  | const Target & | target,
|  | const std::string & | dst_file,
|  | bool | deterministic = `true`
| ) |  |

Concatenate the list of src_files into dst_file, using the appropriate static library format for the given target (e.g., .a or .lib).

If deterministic is true, emit 0 for all GID/UID/timestamps, and 0644 for all modes (equivalent to the ar -D option).

## ◆ link_modules()

Module Halide::link_modules | ( | const std::string & | name,
|  | const std::vector< Module > & | modules
| ) |  |

Link a set of modules together into one module.

## ◆ compile_standalone_runtime() [1/2]

void Halide::compile_standalone_runtime | ( | const std::string & | object_filename,
|  | const Target & | t
| ) |  |

Create an object file containing the Halide runtime for a given target.

For use with Target::NoRuntime. Standalone runtimes are only compatible with pipelines compiled by the same build of Halide used to call this function.

Referenced by Halide::SimdOpCheckTest::main().

## ◆ compile_standalone_runtime() [2/2]

std::map< OutputFileType, std::string > Halide::compile_standalone_runtime | ( | const std::map< OutputFileType, std::string > & | output_files,
|  | const Target & | t
| ) |  |

Create an object and/or static library file containing the Halide runtime for a given target.

For use with Target::NoRuntime. Standalone runtimes are only compatible with pipelines compiled by the same build of Halide used to call this function. Return a map with just the actual outputs filled in (typically, OutputFileType::object and/or OutputFileType::static_library).

## ◆ compile_multitarget()

void Halide::compile_multitarget | ( | const std::string & | fn_name,
|  | const std::map< OutputFileType, std::string > & | output_files,
|  | const std::vector< Target > & | targets,
|  | const std::vector< std::string > & | suffixes,
|  | const ModuleFactory & | module_factory,
|  | const CompilerLoggerFactory & | compiler_logger_factory = `nullptr`
| ) |  |

## ◆ user_context_value()

Expr Halide::user_context_value | ( |  | ) |
| inline

Returns an Expr corresponding to the user context passed to the function (if any).

It is rare that this function is necessary (e.g. to pass the user context to an extern function written in C).

Definition at line 329 of file Param.h.

References Handle(), and Halide::Internal::Variable::make().

## ◆ operator<<() [13/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const RVar & |
| ) |  |

Emit an RVar in a human-readable form.

## ◆ operator<<() [14/14]

std::ostream & Halide::operator<< | ( | std::ostream & | stream,
|  | const RDom & |
| ) |  |

Emit an RDom in a human-readable form.

## ◆ serialize_pipeline() [1/4]

void Halide::serialize_pipeline | ( | const Pipeline & | pipeline,
|  | std::vector< uint8_t > & | data
| ) |  |

Serialize a Halide pipeline into the given data buffer.

Parameters

  pipeline | The Halide pipeline to serialize.
  data | The data buffer to store the serialized Halide pipeline into. Any existing contents will be destroyed.

## ◆ serialize_pipeline() [2/4]

void Halide::serialize_pipeline | ( | const Pipeline & | pipeline,
|  | std::vector< uint8_t > & | data,
|  | std::map< std::string, Parameter > & | params
| ) |  |

Serialize a Halide pipeline into the given data buffer.

Parameters

  pipeline | The Halide pipeline to serialize.
  data | The data buffer to store the serialized Halide pipeline into. Any existing contents will be destroyed.
  params | Map of named parameters which will get populated during serialization (can be used to bind external parameters to objects in the pipeline by name).

## ◆ serialize_pipeline() [3/4]

void Halide::serialize_pipeline | ( | const Pipeline & | pipeline,
|  | const std::string & | filename
| ) |  |

Serialize a Halide pipeline into the given filename.

Parameters

  pipeline | The Halide pipeline to serialize.
  filename | The location of the file to write into to store the serialized pipeline. Any existing contents will be destroyed.

## ◆ serialize_pipeline() [4/4]

void Halide::serialize_pipeline | ( | const Pipeline & | pipeline,
|  | const std::string & | filename,
|  | std::map< std::string, Parameter > & | params
| ) |  |

Serialize a Halide pipeline into the given filename.

Parameters

  pipeline | The Halide pipeline to serialize.
  filename | The location of the file to write into to store the serialized pipeline. Any existing contents will be destroyed.
  params | Map of named parameters which will get populated during serialization (can be used to bind external parameters to objects in the pipeline by name).

## ◆ get_host_target()

Target Halide::get_host_target | ( |  | ) |

Return the target corresponding to the host machine.

Examples
  tutorial/lesson_12_using_the_gpu.cpp.

Referenced by Halide::SimdOpCheckTest::can_run_code(), and Halide::SimdOpCheckTest::main().

## ◆ get_target_from_environment()

Target Halide::get_target_from_environment | ( |  | ) |

Return the target that Halide will use.

If HL_TARGET is set it uses that. Otherwise calls get_host_target

## ◆ get_jit_target_from_environment()

Target Halide::get_jit_target_from_environment | ( |  | ) |

Return the target that Halide will use for jit-compilation.

If HL_JIT_TARGET is set it uses that. Otherwise calls get_host_target. Throws an error if the architecture, bit width, and OS of the target do not match the host target, so this is only useful for controlling the feature set.

Referenced by Halide::Internal::schedule_scalar().

## ◆ target_feature_for_device_api()

Target::Feature Halide::target_feature_for_device_api | ( | DeviceAPI | api | ) |

Get the Target feature corresponding to a DeviceAPI.

For device apis that do not correspond to any single target feature, returns Target::FeatureEnd

References Internal.

## ◆ Int()

Type Halide::Int | ( | int | bits,
|  | int | lanes = `1`
| ) |  |
| inline

Constructing a signed integer type.

Examples
  tutorial/lesson_14_types.cpp.

Definition at line 541 of file Type.h.

References Halide::Type::Int.

Referenced by Halide::SimdOpCheckTest::check_one(), Halide::Internal::equal(), Halide::ConciseCasts::i16(), Halide::ConciseCasts::i16_sat(), Halide::ConciseCasts::i32(), Halide::ConciseCasts::i32_sat(), Halide::ConciseCasts::i64(), Halide::ConciseCasts::i64_sat(), Halide::ConciseCasts::i8(), Halide::ConciseCasts::i8_sat(), and Halide::NamesInterface::Int().

## ◆ UInt()

Type Halide::UInt | ( | int | bits,
|  | int | lanes = `1`
| ) |  |
| inline

Constructing an unsigned integer type.

Examples
  tutorial/lesson_14_types.cpp.

Definition at line 546 of file Type.h.

References Halide::Type::UInt.

Referenced by Bool(), Halide::SimdOpCheckTest::check_one(), Halide::Internal::Simplify::const_false(), Halide::Internal::Simplify::const_true(), Halide::ConciseCasts::u16(), Halide::ConciseCasts::u16_sat(), Halide::ConciseCasts::u32(), Halide::ConciseCasts::u32_sat(), Halide::ConciseCasts::u64(), Halide::ConciseCasts::u64_sat(), Halide::ConciseCasts::u8(), Halide::ConciseCasts::u8_sat(), and Halide::NamesInterface::UInt().

## ◆ Float()

Type Halide::Float | ( | int | bits,
|  | int | lanes = `1`
| ) |  |
| inline

Construct a floating-point type.

Examples
  tutorial/lesson_14_types.cpp.

Definition at line 551 of file Type.h.

References Halide::Type::Float.

Referenced by Halide::SimdOpCheckTest::check_one(), Halide::ConciseCasts::f16(), Halide::ConciseCasts::f32(), Halide::ConciseCasts::f64(), and Halide::NamesInterface::Float().

## ◆ BFloat()

Type Halide::BFloat | ( | int | bits,
|  | int | lanes = `1`
| ) |  |
| inline

Construct a floating-point type in the bfloat format.

Only 16-bit currently supported.

Definition at line 556 of file Type.h.

References Halide::Type::BFloat.

Referenced by Halide::ConciseCasts::bf16(), and Halide::SimdOpCheckTest::check_one().

## ◆ Bool()

Type Halide::Bool | ( | int | lanes = `1` | ) |
| inline

Construct a boolean type.

Definition at line 561 of file Type.h.

References UInt().

Referenced by Halide::NamesInterface::Bool().

## ◆ Handle()

Type Halide::Handle | ( | int | lanes = `1`,
|  | const halide_handle_cplusplus_type * | handle_type = `nullptr`
| ) |  |
| inline

Construct a handle type.

Examples
  tutorial/lesson_14_types.cpp.

Definition at line 566 of file Type.h.

References Halide::Type::Handle.

Referenced by user_context_value().

## ◆ type_of()

template<typename T >

Type Halide::type_of | ( |  | ) |
| inline

Construct the halide equivalent of a C type.

Definition at line 572 of file Type.h.

## ◆ type_to_c_type()

std::string Halide::type_to_c_type | ( | Type | type,
|  | bool | include_space,
|  | bool | c_plus_plus = `true`
| ) |  |

Halide type to a C++ type.

## ◆ load_plugin()

void Halide::load_plugin | ( | const std::string & | lib_name | ) |

Load a plugin in the form of a dynamic library (e.g.

for custom autoschedulers). If the string doesn't contain any . characters, the proper prefix and/or suffix for the platform will be added:

foo -> libfoo.so (Linux/OSX/etc – note that .dylib is not supported) foo -> foo.dll (Windows)

otherwise, it is assumed to be an appropriate pathname.

Any error in loading will assert-fail.

References Internal.

## ◆ set_compiler_stack_size()

void Halide::set_compiler_stack_size | ( | size_t |  | ) |

Set how much stack the compiler should use for compilation in bytes.

This can also be set through the environment variable HL_COMPILER_STACK_SIZE, though this function takes precedence. A value of zero causes the compiler to just use the calling stack for all compilation tasks.

Calling this or setting the environment variable should not be necessary. It is provided for three kinds of testing:

First, Halide uses it in our internal tests to make sure we're not using a silly amount of stack size on some canary programs to avoid stack usage regressions.

Second, if you have a mysterious crash inside a generator, you can set a larger stack size as a way to test if it's a stack overflow. Perhaps our default stack size is not large enough for your program and schedule. Use this call or the environment var as a workaround, and then open a bug with a reproducer at github.com/halide/Halide/issues so that we can determine what's going wrong that is causing your code to use so much stack.

Third, perhaps using a side-stack is causing problems with sanitizing, debugging, or profiling tools. If this is a problem, you can set HL_COMPILER_STACK_SIZE to zero to make Halide stay on the main thread's stack.

## ◆ get_compiler_stack_size()

size_t Halide::get_compiler_stack_size | ( |  | ) |

Return how much stack size the compiler should use for calls that go through run_with_large_stack below.

Currently that's lowering and codegen. If no call to set_compiler_stack_size has been made, this checks the value of the environment variable HL_COMPILER_STACK_SIZE. If that's unset, it returns default_compiler_stack_size, defined above.

References Internal.

## ◆ pick_value_in_vector()

template<typename T >

T Halide::pick_value_in_vector | ( | FuzzedDataProvider & | fdp,
|  | std::vector< T > & | vec
| ) |  |
| inline

Definition at line 10 of file fuzz_helpers.h.

## Variable Documentation

## ◆ head1_channels

const int Halide::head1_channels = 8

Definition at line 7 of file NetworkSize.h.

## ◆ head1_w

const int Halide::head1_w = 40

Definition at line 7 of file NetworkSize.h.

## ◆ head1_h

const int Halide::head1_h = 7

Definition at line 7 of file NetworkSize.h.

## ◆ head2_channels

const int Halide::head2_channels = 24

Definition at line 8 of file NetworkSize.h.

## ◆ head2_w

const int Halide::head2_w = 39

Definition at line 8 of file NetworkSize.h.

## ◆ conv1_channels

const int Halide::conv1_channels = 32

Definition at line 9 of file NetworkSize.h.

## ◆ AnyDims

constexpr int Halide::AnyDims = Halide::Runtime::AnyDims
| constexpr

Definition at line 11 of file Buffer.h.

## ◆ all_device_apis

const DeviceAPI Halide::all_device_apis[]

Initial value:
= {DeviceAPI::None,
DeviceAPI::Host,
DeviceAPI::Default_GPU,
DeviceAPI::CUDA,
DeviceAPI::OpenCL,
DeviceAPI::Metal,
DeviceAPI::Hexagon,
DeviceAPI::HexagonDma,
DeviceAPI::D3D12Compute,
DeviceAPI::Vulkan,
DeviceAPI::WebGPU}
Message::None
@ None
Definition: sim_protocol.h:6

An array containing all the device apis.

Useful for iterating through them.

Definition at line 31 of file DeviceAPI.h.

## ◆ default_compiler_stack_size

constexpr size_t Halide::default_compiler_stack_size = 32 * 1024 * 1024
| constexpr

The default amount of stack used for lowering and codegen.

32 MB ought to be enough for anyone.

Definition at line 539 of file Util.h.