Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
ExternFuncArgument.h
Go to the documentation of this file.
1#ifndef HALIDE_EXTERNFUNCARGUMENT_H
2#define HALIDE_EXTERNFUNCARGUMENT_H
3
4/** \file
5 * Defines the internal representation of a halide ExternFuncArgument
6 */
7
8#include "Buffer.h"
9#include "Expr.h"
10#include "FunctionPtr.h"
11#include "Parameter.h"
12
13 namespace Halide {
14
15/** An argument to an extern-defined Func. May be a Function, Buffer,
16 * ImageParam or Expr. */
17 struct ExternFuncArgument {
18 enum ArgType { UndefinedArg = 0,
19 FuncArg,
20 BufferArg,
21 ExprArg,
22 ImageParamArg };
23 ArgType arg_type = UndefinedArg;
24 Internal::FunctionPtr func;
25 Buffer<> buffer;
26 Expr expr;
27 Parameter image_param;
28
29 ExternFuncArgument(Internal::FunctionPtr f)
30 : arg_type(FuncArg), func(std::move(f)) {
31 }
32
33 template<typename T, int Dims>
34 ExternFuncArgument(const Buffer<T, Dims> &b)
35 : arg_type(BufferArg), buffer(b) {
36 }
37 ExternFuncArgument(Expr e)
38 : arg_type(ExprArg), expr(std::move(e)) {
39 }
40 ExternFuncArgument(int e)
41 : arg_type(ExprArg), expr(e) {
42 }
43 ExternFuncArgument(float e)
44 : arg_type(ExprArg), expr(e) {
45 }
46
47 ExternFuncArgument(const Parameter &p)
48 : arg_type(ImageParamArg), image_param(p) {
49 // Scalar params come in via the Expr constructor.
50 internal_assert(p.is_buffer());
51 }
52 ExternFuncArgument() = default;
53
54 bool is_func() const {
55 return arg_type == FuncArg;
56 }
57 bool is_expr() const {
58 return arg_type == ExprArg;
59 }
60 bool is_buffer() const {
61 return arg_type == BufferArg;
62 }
63 bool is_image_param() const {
64 return arg_type == ImageParamArg;
65 }
66 bool defined() const {
67 return arg_type != UndefinedArg;
68 }
69};
70
71} // namespace Halide
72
73#endif // HALIDE_EXTERNFUNCARGUMENT_H
Buffer.h
internal_assert
#define internal_assert(c)
Definition Error.h:232
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
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
Halide::Expr
A fragment of Halide syntax.
Definition Expr.h:258
Halide::ExternFuncArgument
An argument to an extern-defined Func.
Definition ExternFuncArgument.h:17
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