22 #include "../gpu/texture_handler.h"
80 std::vector<std::array<float, 4>>
coeffs;
113 const std::string&
name,
115 const int numInputChannels,
141 std::map<std::string, std::string>
serialize()
const;
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
Stores linked GLSL programs and their associated fragment shader codes.
Internal low-level GPU control API.
Abstract neural net operation (layer).
A mixin implementing activation functions in GLSL.
2D convolution operation computed on GPU.
const bool isDepthwise
if true, the convolution is depthwise, otherwise regular
std::vector< std::array< float, 4 > > coeffs
model data to pass to uniform variables, if used
Storage::View getOutput(int index=0)
Returns a storage view bound to a specific operation output.
static const char * BIAS_CHUNK_SUFFIX
suffix added to the op name to get the bias chunk id in the model data
void setOutput(Storage::View &&storage, int outputIndex=0)
const int numGroups
number of convolution groups
std::vector< GL::RenderingProgram * > programs
pointers to GLSL program, one per quad of output channels
const bool useBias
if true, the bias addition is enabled
void execute(TaskThread &thread, GraphicPipeline &gpu)
Executes the operation.
const Size::Padding padding
int getInputCount() const
Returns number of operation inputs.
Size getOutputSize(int outputIndex=0) const
Returns full size of a specific operation output.
GL::TextureHandler * inputImage
input texture handler to be used instead input view
static bool initDeserializer()
Sets up deserialization of the operation.
void prepare(GraphicPipeline &gpu, ChunkCollection &data, GL::ProgramBank &bank)
Compiles GLSL shaders.
std::map< std::string, std::string > serialize() const
Returns a serialized representation of th operation;.
static const char * FILTERS_CHUNK_SUFFIX
suffix added to the op name to get the filters chunk id in the model data
const bool useInputImage
if true, input is the texture handler, not the view
bool acceptsTextureInput(int index=0) const
Returns true if the operation can take a GL::TextureHandler at a specific input.
std::vector< int > execOrder
execution order of GLSL programs
void getSampledChannels(int index, int &min, int &max) const
Retrieves range of input features channels sampled at the same time for a specific input.
int getInputPadding(int index=0) const
Retrieves minimum required size of zero padding for a given input.
void setResidualInput(Storage::View &&storage)
Connects a tensor to a residual input.
bool acceptsStorageInput(int index=0) const
Returns true if the operation can take a Storage::View at a specific input.
bool acceptsStorageOutput(int index=0) const
Returns true if the operation can take a Storage::View at a specific output.
const int numOutputChannels
number of output feature maps
std::vector< Storage::View > groupViews
views per convolution group
void setInput(Storage::View &&storage, int inputIndex=0)
unsigned long countMultiplyAdds() const
Counts (approximate) number of multiply-adds used by this operation.
int getOutputCount() const
Returns number of operation outputs.
Conv2D(const std::string &name, const int kernelSize, const int numInputChannels, const int numOutputChannels, const int stride=1, const Size::Padding padding=Size::Padding::VALID, const bool useBias=true, const int numGroups=1, const ActivationFunction activation=ActivationFunction::DEFAULT)
Instantiates a 2D convolution operation.
void disconnect()
Assigns empty inputs and outputs.
Storage::View residualInput
optional tensor to be added to the output before activation
unsigned long countTexelFetches() const
Counts (approximate) number of texels fetches.
int getIdx(int output, int input, int x, int y) const
Maps an (inputChannel, outputChannel, x, y) position to a linear coefficient index in the chunkfile.
Operation 3D input/output size.
Padding
Zero padding specification.
Generates GLSL fragment shader code sampling a local neighborhood around the current texture coordina...
Maps a 3D tensor onto a storage.
static const bool CONV2D_OP_DESERIALIZABLE
ActivationFunction
Activation function specification.
@ DEFAULT
default activation: 0..1 bounded ReLU (identity clipped to 0..1 range)
CustomPoint< numeric > min(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
jobject jlong jint jint y