Beatmup
|
Model reconstructed from a serialized representation. More...
#include <deserialized_model.h>
Public Member Functions | |
DeserializedModel (Context &context, const Listing &listing) | |
DeserializedModel (Context &context, const std::string &str) | |
Constructs a model from its serialized representation. More... | |
~DeserializedModel () | |
Public Member Functions inherited from Beatmup::NNets::Model | |
Model (Context &context, std::initializer_list< AbstractOperation * > ops) | |
Instantiates a model from a list of operations interconnecting them in a feedforward fashion. More... | |
Model (Context &context) | |
Instantiates an empty model. More... | |
~Model () | |
void | append (AbstractOperation *newOp, bool connect=false) |
Adds a new operation to the model. More... | |
void | append (std::initializer_list< AbstractOperation * > newOps, bool connect=false) |
Adds new operations to the model. More... | |
void | addOperation (const std::string &opName, AbstractOperation *newOp) |
Adds a new operation to the model before another operation in the execution order. More... | |
void | addOperation (const AbstractOperation &operation, AbstractOperation *newOp) |
void | addConnection (const std::string &sourceOpName, const std::string &destOpName, int output=0, int input=0, int shuffle=0) |
Adds a connection between two given ops. More... | |
void | addOutput (const std::string &operation, int output=0) |
Enables reading output data from the model memory through getOutputData(). More... | |
void | addOutput (const AbstractOperation &operation, int output=0) |
const float * | getOutputData (size_t &numSamples, const std::string &operation, int output=0) const |
Reads data from the model memory. More... | |
const float * | getOutputData (size_t &numSamples, const AbstractOperation &operation, int output=0) const |
virtual void | prepare (GraphicPipeline &gpu, ChunkCollection &data) |
Prepares all operations: reads the model data from chunks and builds GPU programs. More... | |
bool | isReady () const |
void | execute (TaskThread &thread, GraphicPipeline *gpu) |
Runs the inference. More... | |
bool | isOperationInModel (const AbstractOperation &operation) const |
Checks if a specific operation makes part of the model. More... | |
AbstractOperation & | getFirstOperation () |
AbstractOperation & | getLastOperation () |
const AbstractOperation & | getFirstOperation () const |
const AbstractOperation & | getLastOperation () const |
size_t | getNumberOfOperations () const |
template<class OperationClass = AbstractOperation> | |
OperationClass & | getOperation (const std::string &operationName) |
Retrieves an operation by its name. More... | |
const ProgressTracking & | getPreparingProgress () const |
Returns model preparation progress tracking. More... | |
const ProgressTracking & | getInferenceProgress () const |
Returns inference progress tracking. More... | |
unsigned long | countMultiplyAdds () const |
Provides an estimation of the number of multiply-adds characterizing the model complexity. More... | |
unsigned long | countTexelFetches () const |
Provides an estimation of the total number of texels fetched by all the operations in the model per image. More... | |
size_t | getMemorySize () const |
Returns the amount of texture memory in bytes currently allocated by the model to run the inference. More... | |
Listing | serialize () const |
Returns serialized representation of the model as a Listing. More... | |
std::string | serializeToString () const |
Returns serialized representation of the model as a string. More... | |
void | setProfiler (Profiler *profiler) |
Attaches a profiler instance to meter the execution time per operation during the inference. More... | |
Public Member Functions inherited from Beatmup::GL::ProgramBank | |
ProgramBank (Context &context) | |
~ProgramBank () | |
GL::RenderingProgram * | operator() (GraphicPipeline &gpu, const std::string &code, bool enableExternalTextures=false) |
Provides a program given a fragment shader source code. More... | |
void | release (GraphicPipeline &gpu, GL::RenderingProgram *program) |
Marks a program as unused any more. More... | |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Private Member Functions | |
void | deserialize (const Listing &listing) |
Private Attributes | |
std::vector< AbstractOperation * > | ownedOps |
initially deserialized operations to be destroyed with the model More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Beatmup::NNets::Model | |
void | freeMemory () |
Frees all allocated storages. More... | |
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. More... | |
Storage & | allocateFlatStorage (GraphicPipeline &gpu, const int size) |
Allocates a new flat storage. More... | |
GL::Vector & | allocateVector (GraphicPipeline &gpu, const int size) |
Allocates a vector that can be used as operation input or output. More... | |
InternalBitmap & | allocateTexture (GraphicPipeline &gpu, const Size size) |
Allocates a texture that can be used as operation input or output. More... | |
bool | isPreceding (const AbstractOperation &first, const AbstractOperation &second) const |
Checks whether an operation goes before another operation in the model according the ops execution order. More... | |
AbstractOperation * | operator[] (const std::string &operationName) |
const AbstractOperation * | operator[] (const std::string &operationName) const |
void | addConnection (AbstractOperation &source, AbstractOperation &dest, int output=0, int input=0, int shuffle=0) |
Protected Attributes inherited from Beatmup::NNets::Model | |
std::vector< AbstractOperation * > | ops |
model operations More... | |
ProgressTracking | preparingProgress |
model preparation progress More... | |
ProgressTracking | inferenceProgress |
inference progress More... | |
bool | ready |
if true , ops are connected to each other and storages are allocated More... | |
Protected Attributes inherited from Beatmup::GL::ProgramBank | |
Context & | context |
Model reconstructed from a serialized representation.
The representation format is the one rendered with Model::serialize(): a YAML-like listing containing "ops" and "connections" sections describing the model operations in execution order and connections between them respectively (see NNets model serialization format).
Definition at line 89 of file deserialized_model.h.
Definition at line 60 of file deserialized_model.cpp.
DeserializedModel::DeserializedModel | ( | Context & | context, |
const std::string & | str | ||
) |
Constructs a model from its serialized representation.
The expected representation format is the one rendered with Model::serialize().
[in] | context | A context instance the model resources are bound to |
[in] | str | A string containing the model representation |
Definition at line 67 of file deserialized_model.cpp.
DeserializedModel::~DeserializedModel | ( | ) |
Definition at line 76 of file deserialized_model.cpp.
|
private |
Definition at line 26 of file deserialized_model.cpp.
|
private |
initially deserialized operations to be destroyed with the model
Definition at line 93 of file deserialized_model.h.