Scanner C++ API
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
scanner::BaseKernel Class Referenceabstract

Interface for a unit of computation in a pipeline. More...

#include <kernel.h>

Inheritance diagram for scanner::BaseKernel:
scanner::BatchedKernel scanner::Kernel scanner::StenciledBatchedKernel scanner::StenciledKernel scanner::ImageEncoderKernel scanner::SampleKernel scanner::SliceKernel scanner::SpaceKernel scanner::UnsliceKernel scanner::SampleKernel scanner::PythonKernel

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

Profilerprofiler_ = nullptr
 

Static Public Attributes

static const i32 UnlimitedDevices = 0
 

Detailed Description

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.

Member Function Documentation

virtual void scanner::BaseKernel::fetch_resources ( proto::Result *  result)
inlinevirtual

Downloads any resources necessary for the kernel to run.

For a given kernel, only run once per worker.

Reimplemented in scanner::PythonKernel.

virtual void scanner::BaseKernel::new_stream ( const std::vector< u8 > &  args)
inlinevirtual

Called when the Kernel is about to process a new stream.

Parameters
argsthe arguments that were bound to this Op for this stream

Reimplemented in scanner::PythonKernel.

virtual void scanner::BaseKernel::reset ( )
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.

virtual void scanner::BaseKernel::setup_with_resources ( proto::Result *  result)
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.

virtual void scanner::BaseKernel::validate ( proto::Result *  result)
inlinevirtual

Checks if kernel arguments are valid.

Only useful if your kernel has its own custom Protobuf arguments.

Member Data Documentation

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.


The documentation for this class was generated from the following files: