Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
Macros
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";
_halide_user_assert
#define _halide_user_assert(c)
Definition Error.h:243

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); \
}
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::Internal::Call::Extern
@ Extern
A call to an external C-ABI function, possibly with side-effects.
Definition IR.h:504
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())

Definition at line 20 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 26 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 33 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 41 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 50 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); \
}
Halide::Internal::Call::PureExtern
@ PureExtern
A call to a guaranteed-side-effect-free external function.
Definition IR.h:506

Definition at line 60 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 66 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 73 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 81 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 90 of file Extern.h.