Beatmup
|
Operation computed on CPU. More...
#include <operation.h>
Public Member Functions | |
bool | usesGpu () const |
Returns true if the operation is run on GPU. More... | |
Public Member Functions inherited from Beatmup::NNets::AbstractOperation | |
virtual | ~AbstractOperation () |
virtual int | getInputCount () const |
Returns number of operation inputs. More... | |
virtual int | getOutputCount () const |
Returns number of operation outputs. More... | |
virtual bool | acceptsStorageInput (int index=0) const |
Returns true if the operation can take a Storage::View at a specific input. More... | |
virtual bool | acceptsVectorInput (int index=0) const |
Returns true if the operation can take a GL::Vector at a specific input. More... | |
virtual bool | acceptsTextureInput (int index=0) const |
Returns true if the operation can take a GL::TextureHandler at a specific input. More... | |
virtual bool | acceptsStorageOutput (int index=0) const |
Returns true if the operation can take a Storage::View at a specific output. More... | |
virtual bool | acceptsVectorOutput (int index=0) const |
Returns true if the operation can take a GL::Vector at a specific output. More... | |
virtual bool | acceptsTextureOutput (int index=0) const |
Returns true if the operation can take a GL::TextureHandler at a specific output. More... | |
virtual Size | getOutputSize (int outputIndex=0) const |
Returns full size of a specific operation output. More... | |
virtual Storage::View | getOutput (int index=0) |
Returns a storage view bound to a specific operation output. More... | |
virtual void | getOutput (GL::Vector *&vector, int index=0) |
Returns a GL::Vector bound to a specific operation output. More... | |
virtual void | getOutput (GL::TextureHandler *&vector, int index=0) |
Returns a GL::TextureHandler bound to a specific operation output. More... | |
virtual void | setInput (Storage::View &&storage, int index=0) |
virtual void | setOutput (Storage::View &&storage, int index=0) |
virtual void | setInput (GL::Vector &vector, int index=0) |
virtual void | setOutput (GL::Vector &vector, int index=0) |
virtual void | setInput (GL::TextureHandler &image, int index=0) |
virtual void | setOutput (GL::TextureHandler &image, int index=0) |
virtual std::map< std::string, std::string > | serialize () const =0 |
Returns a serialized representation of th operation;. More... | |
virtual void | disconnect ()=0 |
Assigns empty inputs and outputs. More... | |
virtual unsigned long | countMultiplyAdds () const |
Counts (approximate) number of multiply-adds used by this operation. More... | |
virtual unsigned long | countTexelFetches () const |
Counts (approximate) number of texels fetches. More... | |
std::string | getName () const |
Protected Member Functions | |
CpuOperation (const std::string &name) | |
void | prepare (GraphicPipeline &gpu, ChunkCollection &data, GL::ProgramBank &bank) |
Compiles GLSL shaders. More... | |
void | getSampledChannels (int index, int &min, int &max) const |
Retrieves range of input features channels sampled at the same time for a specific input. More... | |
virtual int | getAmountOfWork () const =0 |
Returns amount of work in arbitrary units to be splitted among threads. More... | |
virtual void | beforeExecute (GraphicPipeline &gpu, const int threadCount) |
Called right before the operation is executed. More... | |
virtual void | afterExecute (const int threadCount) |
Called right after the operation is executed. More... | |
void | execute (TaskThread &thread, GraphicPipeline &gpu) |
Executes the operation. More... | |
void | execute (TaskThread &thread) |
Executes the operation within a specific CPU thread. More... | |
virtual void | execute (const int sliceStart, const int sliceStop, const int threadIdx, const int threadCount)=0 |
Executes the operation body within a specific CPU thread. More... | |
Protected Member Functions inherited from Beatmup::NNets::AbstractOperation | |
AbstractOperation (const std::string &name) | |
virtual int | getInputPadding (int index=0) const |
Retrieves minimum required size of zero padding for a given input. More... | |
Operation computed on CPU.
Definition at line 434 of file operation.h.
|
inlineprotected |
Definition at line 436 of file operation.h.
|
inlineprotectedvirtual |
Compiles GLSL shaders.
[in,out] | gpu | A graphic pipeline instance |
[in,out] | data | Chunkfile containing operation data (e.g. weights and biases) |
[in,out] | bank | A program bank with existing GLSL programs to be reused when possible. If a new program is built, it is added to the bank. |
Implements Beatmup::NNets::AbstractOperation.
Definition at line 438 of file operation.h.
|
inlineprotectedvirtual |
Retrieves range of input features channels sampled at the same time for a specific input.
The operation would typically take the entire storage and sample it at once, if needed. If the number of textures in a storage exceeds the number of texture samplers that the GPU may use simultaneously, an exception occurs. This function provides the necessary information to limit the number of textures in the storage when allocating it. When the limit is reached, multiple channels are packed into a single texture in the storage.
[in] | index | The input index. Expected to fall in the valid range, i.e. from zero to getInputCount() - 1 inclusive. |
[out] | min | The minimum number of channels that can be sampled at once |
[out] | max | The maximum number of channels that can be sampled at once |
Implements Beatmup::NNets::AbstractOperation.
Definition at line 440 of file operation.h.
|
protectedpure virtual |
Returns amount of work in arbitrary units to be splitted among threads.
Implemented in Beatmup::NNets::Softmax.
|
inlineprotectedvirtual |
Called right before the operation is executed.
Reimplemented in Beatmup::NNets::Softmax.
Definition at line 450 of file operation.h.
|
inlineprotectedvirtual |
Called right after the operation is executed.
Reimplemented in Beatmup::NNets::Softmax.
Definition at line 455 of file operation.h.
|
protectedvirtual |
Executes the operation.
The operation should be prepared.
[in,out] | thread | Calling CPU thread descriptor |
[in,out] | gpu | A graphic pipeline instance |
Implements Beatmup::NNets::AbstractOperation.
Definition at line 298 of file operation.cpp.
|
protectedvirtual |
Executes the operation within a specific CPU thread.
[in,out] | thread | Calling CPU thread descriptor |
Reimplemented from Beatmup::NNets::AbstractOperation.
Definition at line 312 of file operation.cpp.
|
protectedpure virtual |
Executes the operation body within a specific CPU thread.
The threads can process different slices according to a given amount of work (see getAmountOfWork()).
[in] | sliceStart | Current slice starting point (included in the slice) |
[in] | sliceStop | Current slice end point (excluded from the slice) |
[in] | threadIdx | Zero-based calling thread number |
[in] | threadCount | Total number of threads executing the operation |
Implemented in Beatmup::NNets::Softmax.
|
inlinevirtual |
Returns true
if the operation is run on GPU.
Otherwise, it is run on CPU.
Reimplemented from Beatmup::NNets::AbstractOperation.
Definition at line 470 of file operation.h.