Halide
Extern.h File Reference
#include "Debug.h"

Go to the source code of this file.

Macros

#define _halide_check_arg_type(t, name, e, n)   _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 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,
 
)    _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";

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1}, Halide::Internal::Call::Extern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2}, Halide::Internal::Call::Extern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2, a3}, Halide::Internal::Call::Extern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2, a3, a4}, Halide::Internal::Call::Extern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2, a3, a4, a5}, Halide::Internal::Call::Extern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1}, Halide::Internal::Call::PureExtern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2}, Halide::Internal::Call::PureExtern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2, a3}, Halide::Internal::Call::PureExtern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2, a3, a4}, Halide::Internal::Call::PureExtern); \
}

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); \
return Halide::Internal::Call::make(Halide::type_of<rt>(), #name, {a1, a2, a3, a4, a5}, Halide::Internal::Call::PureExtern); \
}

Definition at line 87 of file Extern.h.

Halide::Internal::Call::make
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())
Halide::Internal::Call::Extern
@ Extern
A call to an external C-ABI function, possibly with side-effects.
Definition: IR.h:468
Halide::Internal::Call::PureExtern
@ PureExtern
A call to a guaranteed-side-effect-free external function.
Definition: IR.h:470
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:256