Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
Extern.h File Reference

Convenience macros that lift functions that take C types into functions that take and return exprs, and call the original function at runtime under the hood. More...

#include "Debug.h"

Go to the source code of this file.

Macros

#define _halide_check_arg_type(t, name, e, n)
 
#define HalideExtern_1(rt, name, t1)
 
#define HalideExtern_2(rt, name, t1, t2)
 
#define HalideExtern_3(rt, name, t1, t2, t3)
 
#define HalideExtern_4(rt, name, t1, t2, t3, t4)
 
#define HalideExtern_5(rt, name, t1, t2, t3, t4, t5)
 
#define HalidePureExtern_1(rt, name, t1)
 
#define HalidePureExtern_2(rt, name, t1, t2)
 
#define HalidePureExtern_3(rt, name, t1, t2, t3)
 
#define HalidePureExtern_4(rt, name, t1, t2, t3, t4)
 
#define HalidePureExtern_5(rt, name, t1, t2, t3, t4, t5)
 

Detailed Description

Convenience macros that lift functions that take C types into functions that take and return exprs, and call the original function at runtime under the hood.

See test/c_function.cpp for example usage.

Definition in file Extern.h.

Macro Definition Documentation

◆ _halide_check_arg_type

#define _halide_check_arg_type ( t,
name,
e,
n )
Value:
_halide_user_assert(e.type() == t) << "Type mismatch for argument " << n << " to extern function " << #name << ". Type expected is " << t << " but the argument " << e << " has type " << e.type() << ".\n";
#define _halide_user_assert(c)
Definition Error.h:171

Definition at line 14 of file Extern.h.

◆ HalideExtern_1

#define HalideExtern_1 ( rt,
name,
t1 )
Value:
Halide::Expr name(const Halide::Expr &a1) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
}
Type type_of()
Construct the halide equivalent of a C type.
Definition Type.h:572
A fragment of Halide syntax.
Definition Expr.h:258
@ Extern
A call to an external C-ABI function, possibly with side-effects.
Definition IR.h:494
static Expr make(Type type, IntrinsicOp op, const std::vector< Expr > &args, CallType call_type, FunctionPtr func=FunctionPtr(), int value_index=0, const Buffer<> &image=Buffer<>(), Parameter param=Parameter())

Definition at line 17 of file Extern.h.

◆ HalideExtern_2

#define HalideExtern_2 ( rt,
name,
t1,
t2 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
}

Definition at line 23 of file Extern.h.

◆ HalideExtern_3

#define HalideExtern_3 ( rt,
name,
t1,
t2,
t3 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2, const Halide::Expr &a3) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
_halide_check_arg_type(Halide::type_of<t3>(), name, a3, 3); \
}

Definition at line 30 of file Extern.h.

◆ HalideExtern_4

#define HalideExtern_4 ( rt,
name,
t1,
t2,
t3,
t4 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2, const Halide::Expr &a3, const Halide::Expr &a4) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
_halide_check_arg_type(Halide::type_of<t3>(), name, a3, 3); \
_halide_check_arg_type(Halide::type_of<t4>(), name, a4, 4); \
}

Definition at line 38 of file Extern.h.

◆ HalideExtern_5

#define HalideExtern_5 ( rt,
name,
t1,
t2,
t3,
t4,
t5 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2, const Halide::Expr &a3, const Halide::Expr &a4, const Halide::Expr &a5) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
_halide_check_arg_type(Halide::type_of<t3>(), name, a3, 3); \
_halide_check_arg_type(Halide::type_of<t4>(), name, a4, 4); \
_halide_check_arg_type(Halide::type_of<t5>(), name, a5, 5); \
}

Definition at line 47 of file Extern.h.

◆ HalidePureExtern_1

#define HalidePureExtern_1 ( rt,
name,
t1 )
Value:
Halide::Expr name(const Halide::Expr &a1) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
}
@ PureExtern
A call to a guaranteed-side-effect-free external function.
Definition IR.h:496

Definition at line 57 of file Extern.h.

◆ HalidePureExtern_2

#define HalidePureExtern_2 ( rt,
name,
t1,
t2 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
}

Definition at line 63 of file Extern.h.

◆ HalidePureExtern_3

#define HalidePureExtern_3 ( rt,
name,
t1,
t2,
t3 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2, const Halide::Expr &a3) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
_halide_check_arg_type(Halide::type_of<t3>(), name, a3, 3); \
}

Definition at line 70 of file Extern.h.

◆ HalidePureExtern_4

#define HalidePureExtern_4 ( rt,
name,
t1,
t2,
t3,
t4 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2, const Halide::Expr &a3, const Halide::Expr &a4) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
_halide_check_arg_type(Halide::type_of<t3>(), name, a3, 3); \
_halide_check_arg_type(Halide::type_of<t4>(), name, a4, 4); \
}

Definition at line 78 of file Extern.h.

◆ HalidePureExtern_5

#define HalidePureExtern_5 ( rt,
name,
t1,
t2,
t3,
t4,
t5 )
Value:
Halide::Expr name(const Halide::Expr &a1, const Halide::Expr &a2, const Halide::Expr &a3, const Halide::Expr &a4, const Halide::Expr &a5) { \
_halide_check_arg_type(Halide::type_of<t1>(), name, a1, 1); \
_halide_check_arg_type(Halide::type_of<t2>(), name, a2, 2); \
_halide_check_arg_type(Halide::type_of<t3>(), name, a3, 3); \
_halide_check_arg_type(Halide::type_of<t4>(), name, a4, 4); \
_halide_check_arg_type(Halide::type_of<t5>(), name, a5, 5); \
}

Definition at line 87 of file Extern.h.