23 #include "../bitmap/internal_bitmap.h"
24 #include "../gpu/program_bank.h"
25 #include "../gpu/linear_mapping.h"
26 #include "../context.h"
27 #include "../utils/progress_tracking.h"
28 #include "../utils/profiler.h"
29 #include "../utils/chunkfile.h"
30 #include "../utils/listing.h"
32 #include <initializer_list>
122 std::vector<AbstractOperation*>
ops;
222 void append(std::initializer_list<AbstractOperation*> newOps,
bool connect =
false);
244 void addConnection(
const std::string& sourceOpName,
const std::string& destOpName,
int output = 0,
int input = 0,
int shuffle = 0);
252 void addOutput(
const std::string& operation,
int output = 0);
263 const float*
getOutputData(
size_t& numSamples,
const std::string& operation,
int output = 0)
const;
302 template<
class OperationClass = AbstractOperation>
303 inline OperationClass&
getOperation(
const std::string& operationName) {
304 return *
static_cast<OperationClass*
>((*this)[operationName]);
A key-value pair set storing pieces of arbitrary data (chunks) under string keys.
Basic class: task and memory management, any kind of static data.
Base class for all exceptions.
Stores linked GLSL programs and their associated fragment shader codes.
Real-valued vector usable by GPU.
Internal low-level GPU control API.
Bitmap whose memory is managed by the Beatmup engine.
Parser of simple YAML-like listings.
Abstract neural net operation (layer).
Wrapper for exceptions occuring during the model inference.
InferenceTimeError(const AbstractOperation &op, const std::exception &ex)
size_t getNumberOfOperations() const
size_t getMemorySize() const
Returns the amount of texture memory in bytes currently allocated by the model to run the inference.
const AbstractOperation & getFirstOperation() const
Storage & allocateFlatStorage(GraphicPipeline &gpu, const int size)
Allocates a new flat storage.
bool ready
if true, ops are connected to each other and storages are allocated
std::vector< AbstractOperation * > ops
model operations
void freeMemory()
Frees all allocated storages.
std::multimap< const AbstractOperation *, UserOutput > userOutputs
operation => user output mapping
OperationClass & getOperation(const std::string &operationName)
Retrieves an operation by its name.
unsigned long countTexelFetches() const
Provides an estimation of the total number of texels fetched by all the operations in the model per i...
Storage & allocateStorage(GraphicPipeline &gpu, const Size size, bool forGpu=true, bool forCpu=false, const int pad=0, const int reservedChannels=0)
Allocates a new storage.
ProgressTracking inferenceProgress
inference progress
Profiler * profiler
pointer to a Profiler attached to the model
void addConnection(AbstractOperation &source, AbstractOperation &dest, int output=0, int input=0, int shuffle=0)
Listing serialize() const
Returns serialized representation of the model as a Listing.
ProgressTracking preparingProgress
model preparation progress
void setProfiler(Profiler *profiler)
Attaches a profiler instance to meter the execution time per operation during the inference.
const ProgressTracking & getInferenceProgress() const
Returns inference progress tracking.
void addOutput(const std::string &operation, int output=0)
Enables reading output data from the model memory through getOutputData().
std::vector< Storage * > storages
allocated storages used during the inference
bool isOperationInModel(const AbstractOperation &operation) const
Checks if a specific operation makes part of the model.
unsigned long countMultiplyAdds() const
Provides an estimation of the number of multiply-adds characterizing the model complexity.
GL::Vector & allocateVector(GraphicPipeline &gpu, const int size)
Allocates a vector that can be used as operation input or output.
Model(Context &context, std::initializer_list< AbstractOperation * > ops)
Instantiates a model from a list of operations interconnecting them in a feedforward fashion.
std::multimap< const AbstractOperation *, Connection > connections
source operation => connection descriptor mapping
virtual void prepare(GraphicPipeline &gpu, ChunkCollection &data)
Prepares all operations: reads the model data from chunks and builds GPU programs.
std::string serializeToString() const
Returns serialized representation of the model as a string.
AbstractOperation * operator[](const std::string &operationName)
const ProgressTracking & getPreparingProgress() const
Returns model preparation progress tracking.
void execute(TaskThread &thread, GraphicPipeline *gpu)
Runs the inference.
AbstractOperation & getLastOperation()
AbstractOperation & getFirstOperation()
std::vector< InternalBitmap * > textures
allocated images used during the inference
void addOperation(const std::string &opName, AbstractOperation *newOp)
Adds a new operation to the model before another operation in the execution order.
bool isPreceding(const AbstractOperation &first, const AbstractOperation &second) const
Checks whether an operation goes before another operation in the model according the ops execution or...
std::vector< GL::Vector * > vectors
allocated vectors used during the inference
const AbstractOperation & getLastOperation() const
InternalBitmap & allocateTexture(GraphicPipeline &gpu, const Size size)
Allocates a texture that can be used as operation input or output.
void append(AbstractOperation *newOp, bool connect=false)
Adds a new operation to the model.
const float * getOutputData(size_t &numSamples, const std::string &operation, int output=0) const
Reads data from the model memory.
Operation 3D input/output size.
3D tensor stored in a set of textures.
Collects running time statistics of multiple tracks.
Progress tracking utility.
AbstractOperation * dest
destination operation
int shuffle
shuffling step (details here)
A user-defined output descriptor.
std::vector< float > data
container to store the data
int index
operation output index to fetch data from
JNIEnv jlong jobject jstring opName