Loading...
Searching...
No Matches
ExternFuncArgument.h
Go to the documentation of this file.
#ifndef HALIDE_EXTERNFUNCARGUMENT_H
#define HALIDE_EXTERNFUNCARGUMENT_H
/** \file
* Defines the internal representation of a halide ExternFuncArgument
*/
#include "Buffer.h"
#include "Expr.h"
#include "FunctionPtr.h"
#include "Parameter.h"
namespace Halide {
/** An argument to an extern-defined Func. May be a Function, Buffer,
* ImageParam or Expr. */
struct ExternFuncArgument {
enum ArgType { UndefinedArg = 0,
FuncArg,
BufferArg,
ExprArg,
ImageParamArg };
ArgType arg_type = UndefinedArg;
Internal::FunctionPtr func;
Buffer<> buffer;
Expr expr;
Parameter image_param;
ExternFuncArgument(Internal::FunctionPtr f)
: arg_type(FuncArg), func(std::move(f)) {
}
template<typename T, int Dims>
ExternFuncArgument(const Buffer<T, Dims> &b)
: arg_type(BufferArg), buffer(b) {
}
ExternFuncArgument(Expr e)
: arg_type(ExprArg), expr(std::move(e)) {
}
ExternFuncArgument(int e)
: arg_type(ExprArg), expr(e) {
}
ExternFuncArgument(float e)
: arg_type(ExprArg), expr(e) {
}
ExternFuncArgument(const Parameter &p)
: arg_type(ImageParamArg), image_param(p) {
// Scalar params come in via the Expr constructor.
internal_assert(p.is_buffer());
}
ExternFuncArgument() = default;
bool is_func() const {
return arg_type == FuncArg;
}
bool is_expr() const {
return arg_type == ExprArg;
}
bool is_buffer() const {
return arg_type == BufferArg;
}
bool is_image_param() const {
return arg_type == ImageParamArg;
}
bool defined() const {
return arg_type != UndefinedArg;
}
};
} // namespace Halide
#endif // HALIDE_EXTERNFUNCARGUMENT_H
Buffer.h
internal_assert
#define internal_assert(c)
Definition Error.h:218
Expr.h
Base classes for Halide expressions (Halide::Expr) and statements (Halide::Internal::Stmt).
FunctionPtr.h
Parameter.h
Defines the internal representation of parameters to halide piplines.
Halide::Buffer<>
Halide::Parameter
A reference-counted handle to a parameter to a halide pipeline.
Definition Parameter.h:40
Halide::Parameter::is_buffer
bool is_buffer() const
Does this parameter refer to a buffer/image?
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::Expr
A fragment of Halide syntax.
Definition Expr.h:258
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument(const Parameter &p)
Definition ExternFuncArgument.h:47
Halide::ExternFuncArgument::buffer
Buffer buffer
Definition ExternFuncArgument.h:25
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument(float e)
Definition ExternFuncArgument.h:43
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument(Internal::FunctionPtr f)
Definition ExternFuncArgument.h:29
Halide::ExternFuncArgument::image_param
Parameter image_param
Definition ExternFuncArgument.h:27
Halide::ExternFuncArgument::defined
bool defined() const
Definition ExternFuncArgument.h:66
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument(const Buffer< T, Dims > &b)
Definition ExternFuncArgument.h:34
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument()=default
Halide::ExternFuncArgument::is_buffer
bool is_buffer() const
Definition ExternFuncArgument.h:60
Halide::ExternFuncArgument::func
Internal::FunctionPtr func
Definition ExternFuncArgument.h:24
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument(Expr e)
Definition ExternFuncArgument.h:37
Halide::ExternFuncArgument::is_image_param
bool is_image_param() const
Definition ExternFuncArgument.h:63
Halide::ExternFuncArgument::ArgType
ArgType
Definition ExternFuncArgument.h:18
Halide::ExternFuncArgument::FuncArg
@ FuncArg
Definition ExternFuncArgument.h:19
Halide::ExternFuncArgument::UndefinedArg
@ UndefinedArg
Definition ExternFuncArgument.h:18
Halide::ExternFuncArgument::ImageParamArg
@ ImageParamArg
Definition ExternFuncArgument.h:22
Halide::ExternFuncArgument::BufferArg
@ BufferArg
Definition ExternFuncArgument.h:20
Halide::ExternFuncArgument::ExprArg
@ ExprArg
Definition ExternFuncArgument.h:21
Halide::ExternFuncArgument::arg_type
ArgType arg_type
Definition ExternFuncArgument.h:23
Halide::ExternFuncArgument::is_func
bool is_func() const
Definition ExternFuncArgument.h:54
Halide::ExternFuncArgument::ExternFuncArgument
ExternFuncArgument(int e)
Definition ExternFuncArgument.h:40
Halide::ExternFuncArgument::expr
Expr expr
Definition ExternFuncArgument.h:26
Halide::ExternFuncArgument::is_expr
bool is_expr() const
Definition ExternFuncArgument.h:57
Halide::Internal::FunctionPtr
A possibly-weak pointer to a Halide function.
Definition FunctionPtr.h:27