Scanner C++ API
|
Interface for a unit of computation in a pipeline. More...
#include <kernel.h>
Public Member Functions | |
BaseKernel (const KernelConfig &config) | |
virtual void | validate (proto::Result *result) |
Checks if kernel arguments are valid. More... | |
virtual void | fetch_resources (proto::Result *result) |
Downloads any resources necessary for the kernel to run. More... | |
virtual void | setup_with_resources (proto::Result *result) |
Runs any setup code that relies on fetched resources. More... | |
virtual void | new_stream (const std::vector< u8 > &args) |
Called when the Kernel is about to process a new stream. More... | |
virtual void | reset () |
Requests that kernel resets its logical state. More... | |
virtual void | execute_kernel (const StenciledBatchedElements &input_columns, BatchedElements &output_columns)=0 |
For internal use. | |
virtual void | set_profiler (Profiler *profiler) |
For internal use. | |
Public Attributes | |
Profiler * | profiler_ = nullptr |
Static Public Attributes | |
static const i32 | UnlimitedDevices = 0 |
Interface for a unit of computation in a pipeline.
Kernels form the core of Scanner's interface. They are essentially functions that take elements of inputs and produce an equal number elements of outputs. Kernels are stateful operators that get reset when provided non-contiguous batches of input. See KernelFactory for how an op defines what hardware it can use for its computation.
|
inlinevirtual |
Downloads any resources necessary for the kernel to run.
For a given kernel, only run once per worker.
Reimplemented in scanner::PythonKernel.
|
inlinevirtual |
Called when the Kernel is about to process a new stream.
args | the arguments that were bound to this Op for this stream |
Reimplemented in scanner::PythonKernel.
|
inlinevirtual |
Requests that kernel resets its logical state.
Scanner calls reset on a kernel when it provides non-consecutive inputs or when about to provide inputs from a difference slice. This allows unbounded or bounded state kernels to clear their logical state so that state from logically unrelated parts of the input do not affect the output.
Reimplemented in scanner::PythonKernel.
|
inlinevirtual |
Runs any setup code that relies on fetched resources.
Guaranteed to be called on all kernels after fetch_resources is called on one kernel.
Reimplemented in scanner::PythonKernel.
|
inlinevirtual |
Checks if kernel arguments are valid.
Only useful if your kernel has its own custom Protobuf arguments.
Profiler* scanner::BaseKernel::profiler_ = nullptr |
The profiler allows an op to save profiling data for later visualization. It is not guaranteed to be non-null, so check before use.