2#ifndef poplar_HostCallback_hpp
3#define poplar_HostCallback_hpp
5#include <poplar/CallbackTraits.hpp>
22 ArrayRef<void *> outputs) = 0;
38 template <
class CallbackImpl,
39 typename =
typename std::enable_if<
40 std::is_base_of<HostCallback, CallbackImpl>::value>::type>
42 : callback(std::move(f)) {}
50 template <
class F,
typename =
typename std::enable_if<
51 traits::is_host_callback<F>::value>::type>
65 operator std::unique_ptr<HostCallback>() && {
return std::move(callback); }
68 template <
class F> std::unique_ptr<HostCallback> makeCallback(F &&f) {
70 using Function =
typename traits::remove_cvref<F>::type;
74 Callback(F &&f) : function(std::forward<F>(f)) {}
76 void operator()(ArrayRef<const void *> ins,
77 ArrayRef<void *> outs)
override {
81 return std::unique_ptr<HostCallback>(
new Callback{std::forward<F>(f)});
84 std::unique_ptr<HostCallback> callback;
A reference to a function stored within a graph.
Definition: GraphElements.hpp:148
Wrapper for HostCallback instances.
Definition: HostFunctionCallback.hpp:31
HostCallbackHandle(F &&f)
Constructs a handle from a callable instance.
Definition: HostFunctionCallback.hpp:52
HostCallbackHandle(std::unique_ptr< CallbackImpl > f)
Constructs a handle from an instance of a host callback implementation.
Definition: HostFunctionCallback.hpp:41
Interface used during host function calls to produce/consume the data being exchanged between the hos...
Definition: HostFunctionCallback.hpp:14
virtual void operator()(ArrayRef< const void * > inputs, ArrayRef< void * > outputs)=0
Callback function that is invoked as a result of calling a host function in an IPU program.
Poplar classes and functions.
Definition: ArrayRef.hpp:14