23 using namespace NNets;
32 LinearMapping(context, false),
33 numOutputDims(numOutputDims), useBias(useBias), inputVector(nullptr), outputVector(nullptr)
49 RuntimeError::check(view.getStorage().getPadding() == 0,
"Storages with padding are not supported");
50 const auto& storage = view.getStorage();
51 RuntimeError::check(view.getNumberOfTextures() == 1 && storage.getTextureWidth() == 1,
"Input size mismatch: a column-like view is expected");
71 #ifdef BEATMUP_OPENGLVERSION_GLES20
84 {
"use_bias",
useBias ?
"true" :
"false" },
92 DenseDeserializer() : Deserializer(
"dense") {}
104 block.
get<
int>(
"output_dims"),
105 block.
get<
bool>(
"use_bias")
134 #ifdef BEATMUP_OPENGLVERSION_GLES20
170 LinearMapping::prepare(gpu, *
outputVector, inputHandle, &bank);
181 LinearMapping::process(gpu, *
outputVector, inputHandle);
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
Simply a piece of binary data of a specific size.
Basic class: task and memory management, any kind of static data.
Matrix * matrix
the matrix ("A")
Vector * bias
optional bias vector ("b")
Stores linked GLSL programs and their associated fragment shader codes.
Real-valued vector usable by GPU.
const int getHeight() const
Height of the texture in pixels.
const int size
number of samples in the vector
int getSize() const
Returns the length of the vector.
Format
Vector data format.
@ FIXED16
16 bit per element
@ FLOAT
32 bit per element, floating point
Internal low-level GPU control API.
T get(const std::string &key) const
Returns a value by key casted to a given type.
Enables construction of an operation from its serialized representation.
Abstract neural net operation (layer).
std::string getName() const
static const char * BIAS_CHUNK_SUFFIX
suffix added to the op name to get the bias chunk id in the model data
GL::Vector * outputVector
pointer to the output vector
GL::Vector * inputVector
if not null, points the input vector x; otherwise the input is a storage view
void setInput(Storage::View &&view, int index=0)
static const char * MATRIX_CHUNK_SUFFIX
suffix added to the op name to get the matrix chunk id in the model data
void setOutput(GL::Vector &vector, int index=0)
unsigned long countMultiplyAdds() const
Counts (approximate) number of multiply-adds used by this operation.
GL::Vector::Format getOutputVectorFormat() const
unsigned long countTexelFetches() const
Counts (approximate) number of texels fetches.
void getOutput(GL::Vector *&, int index=0)
Returns a GL::Vector bound to a specific operation output.
Storage::View inputStorage
if not empty, contains the input features; otherwise the input is a GL vector
void getSampledChannels(int index, int &min, int &max) const
Retrieves range of input features channels sampled at the same time for a specific input.
std::map< std::string, std::string > serialize() const
Returns a serialized representation of th operation;.
static bool initDeserializer()
Sets up deserialization of the operation.
void execute(TaskThread &thread, GraphicPipeline &gpu)
Executes the operation.
Dense(Context &context, const std::string &name, int numOutputDims, bool useBias)
Creates a Dense operation.
const bool useBias
if true, the bias vector b is searched in the model data to add to the output
const int numOutputDims
output feature vector size / number of rows in A
void prepare(GraphicPipeline &gpu, ChunkCollection &data, GL::ProgramBank &bank)
Compiles GLSL shaders.
void disconnect()
Assigns empty inputs and outputs.
TextureHandler representation of a pack of 4 channels from a non-empty View.
Maps a 3D tensor onto a storage.
static void checkChannelNumber(int channel)
Checks whether a channel number points to the first channel in a texture.
static void checkMin(const datatype value, const datatype min, const char *message)
static void check(const datatype value, const datatype min, const datatype max, const char *message)
static void check(const bool condition, const std::string &message)
std::string to_string(Beatmup::NNets::ActivationFunction function)
CustomPoint< numeric > min(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
CustomPoint< numeric > max(const CustomPoint< numeric > &a, const CustomPoint< numeric > &b)
return(jlong) new Beatmup jlong jstring name
JNIEnv jlong jint jint count