morapi_DnnLayer Struct Reference
Dnn layer.
More...
#include <morapi_softneuro.h>
Public Member Functions
morapi_Bool | morapi_DnnLayer_isMutable (const morapi_DnnLayer *self) |
morapi_Bool | morapi_DnnLayer_isImmutable (const morapi_DnnLayer *self) |
morapi_Bool | morapi_DnnLayer_isConstant (const morapi_DnnLayer *self) |
Routine
morapi_Result | morapi_DnnLayer_setRoutineDesc (morapi_DnnLayer *self, const morapi_Char *i_routine_desc) |
const morapi_Char * | morapi_DnnLayer_getRoutineDescText (const morapi_DnnLayer *self) |
const morapi_Char * | morapi_DnnLayer_getCompiledRoutineDescText (const morapi_DnnLayer *self) |
morapi_Params * | morapi_DnnLayer_getRoutineParams (morapi_DnnLayer *self) |
const morapi_Params * | morapi_DnnLayer_getCompiledRoutineParams (const morapi_DnnLayer *self) |
morapi_Params * | morapi_DnnLayer_getChildRoutineParams (morapi_DnnLayer *self) |
morapi_Result | morapi_DnnLayer_setRoutineLimit (morapi_DnnLayer *self, morapi_DnnRoutineLimit i_limit) |
Layer settings and data
Weight
Layer Input
morapi_Int32 | morapi_DnnLayer_getInputNum (const morapi_DnnLayer *self) |
morapi_Tensor * | morapi_DnnLayer_getInput (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_Tensor * | morapi_DnnLayer_getInputBlob (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_DnnLayer * | morapi_DnnLayer_getPrevLayer (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_Int32 | morapi_DnnLayer_getPrevLayerOutputIndex (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_Result | morapi_DnnLayer_setInputDType (morapi_DnnLayer *self, morapi_Int32 i_index, morapi_DType i_dtype) |
morapi_Result | morapi_DnnLayer_setInputForLayerParam (morapi_DnnLayer *self, morapi_Int32 i_index, morapi_Bool i_is_for_layer_param) |
Layer Output
morapi_Result | morapi_DnnLayer_enableOutput (morapi_DnnLayer *self, morapi_Int32 i_index, morapi_DType i_dtype, morapi_Int32 i_rank, const morapi_Int32 *i_shape) |
morapi_Int32 | morapi_DnnLayer_getOutputNum (const morapi_DnnLayer *self) |
morapi_Tensor * | morapi_DnnLayer_getOutput (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_Tensor * | morapi_DnnLayer_getOutputBlob (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_DType | morapi_DnnLayer_getOutputDType (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_Tensor * | morapi_DnnLayer_getOutputDump (const morapi_DnnLayer *self, morapi_Int32 i_index) |
morapi_Int32 | morapi_DnnLayer_getNextLayerNumAt (const morapi_DnnLayer *self, morapi_Int32 i_output_index) |
morapi_DnnLayer * | morapi_DnnLayer_getNextLayer (const morapi_DnnLayer *self, morapi_Int32 i_output_index, morapi_Int32 i_next_index) |
morapi_Int32 | morapi_DnnLayer_getNextLayerInputIndex (const morapi_DnnLayer *self, morapi_Int32 i_output_index, morapi_Int32 i_next_index) |
Related Functions
morapi_Int32 | morapi_Dnn_static_getLayerTypeNum (morapi_Env *env) |
const morapi_Char ** | morapi_Dnn_static_getLayerTypes (morapi_Env *env) |
const morapi_Char * | morapi_Dnn_static_getDefaultLayerParams (morapi_Env *env, const morapi_Char *i_layer_type) |
Detailed Description
Dnn layer.
test_decompose_api.c, and test_dnn_api.c.
Member Function Documentation
morapi_DnnLayer_setRoutineDesc()
morapi_Result morapi_DnnLayer_setRoutineDesc (morapi_DnnLayer * self,
const morapi_Char * i_routine_desc)
Sets the routine descriptor.
It clears the routine parameters
Parameters
- self : layer object
- i_routine_desc : routine to be set
morapi_DnnLayer_getRoutineDescText()
const morapi_Char * morapi_DnnLayer_getRoutineDescText (const morapi_DnnLayer * self)
Gets the routine descriptor text.
Parameters
- self : layer object
morapi_DnnLayer_getCompiledRoutineDescText()
const morapi_Char * morapi_DnnLayer_getCompiledRoutineDescText (const morapi_DnnLayer * self)
Gets the compiled routine descriptor text.
Parameters
- self : layer object
morapi_DnnLayer_getRoutineParams()
morapi_Params * morapi_DnnLayer_getRoutineParams (morapi_DnnLayer * self)
Gets the routine parameters.
Parameters
- self : layer object
morapi_DnnLayer_getCompiledRoutineParams()
const morapi_Params * morapi_DnnLayer_getCompiledRoutineParams (const morapi_DnnLayer * self)
Gets the compiled routine parameters.
Parameters
- self : layer object
morapi_DnnLayer_getChildRoutineParams()
morapi_Params * morapi_DnnLayer_getChildRoutineParams (morapi_DnnLayer * self)
Gets the child routine parameters.
Parameters
- self : layer object
morapi_DnnLayer_setRoutineLimit()
morapi_Result morapi_DnnLayer_setRoutineLimit (morapi_DnnLayer * self,
morapi_DnnRoutineLimit i_limit)
Sets the limitation for routine selection.
Parameters
- self : layer object.
- i_limit : OR'ed combination of morapi_DnnRoutineLimit
morapi_DnnLayer_getOwner()
morapi_DnnNet * morapi_DnnLayer_getOwner (const morapi_DnnLayer * self)
Gets the owner net.
Parameters
- self : layer object
morapi_DnnLayer_getName()
const morapi_Char * morapi_DnnLayer_getName (const morapi_DnnLayer * self)
Gets the name of the layer.
Parameters
- self : layer object
morapi_DnnLayer_getType()
const morapi_Char * morapi_DnnLayer_getType (const morapi_DnnLayer * self)
Gets the layer type.
Parameters
- self : layer object
morapi_DnnLayer_getParams()
morapi_Params * morapi_DnnLayer_getParams (morapi_DnnLayer * self)
Gets the parameters.
Parameters
- self : layer object
morapi_DnnLayer_getParsedParams()
const morapi_Params * morapi_DnnLayer_getParsedParams (const morapi_DnnLayer * self)
Gets the parsed parameters.
Parameters
- self : layer object
morapi_DnnLayer_getAttrs()
morapi_Params * morapi_DnnLayer_getAttrs (morapi_DnnLayer * self)
Gets the attributes.
Parameters
- self : layer object
morapi_DnnLayer_getIndex()
morapi_Int32 morapi_DnnLayer_getIndex (const morapi_DnnLayer * self)
Gets the index.
Parameters
- self : layer object
morapi_DnnLayer_getObj()
void * morapi_DnnLayer_getObj (const morapi_DnnLayer * self)
Gets the layer object.
Parameters
- self : layer object
morapi_DnnLayer_connect()
morapi_Result morapi_DnnLayer_connect (morapi_DnnLayer * self,
morapi_Int32 i_output_index,
morapi_DnnLayer * i_next_layer,
morapi_Int32 i_input_index)
Connects the i_output_index-th output to i_next_layer.
If i_next_layer == NULL, just create the i_output_index-th layer output.
Parameters
- self : layer object
- i_output_index : index of the output to be connected
- i_next_layer : index of the layer to be connected
- i_input_index : index of the input in the layer to be connected
morapi_DnnLayer_disconnect()
morapi_Result morapi_DnnLayer_disconnect (morapi_DnnLayer * self,
morapi_Int32 i_output_index,
morapi_DnnLayer * i_next_layer,
morapi_Int32 i_input_index)
Disconnects the i_output_index-th output to i_input_index-th input of i_next_layer.
Parameters
- self : layer object
- i_output_index : index of the output to be disconnected
- i_next_layer : index of the layer to be disconnected
- i_input_index : index of the input in the layer to be disconnected
morapi_DnnLayer_disconnectAll()
morapi_Result morapi_DnnLayer_disconnectAll (morapi_DnnLayer * self)
Disconnects all.
Parameters
- self : layer object
morapi_DnnLayer_setInplace()
morapi_Result morapi_DnnLayer_setInplace (morapi_DnnLayer * self,
morapi_Int32 i_input_index,
morapi_Int32 i_output_index,
morapi_Bool i_is_forced)
Sets that the i_input_index-th input is used as in-place for the i_output_index-th output.
Call this function in morapi_DnnLayerCB_init() or morapi_DnnRoutineCB_init().
Parameters
- self : layer object
- i_input_index : input to be set in-place
- i_output_index : output to contain the in-place input
- i_is_forced : whether to force or not in-place
morapi_DnnLayer_setOps()
morapi_Result morapi_DnnLayer_setOps (morapi_DnnLayer * self,
morapi_Int64 i_ops)
Sets the number of operations.
Call this function in morapi_DnnLayerCB_init().
Parameters
- self : layer object
- i_ops : operation number
morapi_DnnLayer_getChildNet()
morapi_DnnNet * morapi_DnnLayer_getChildNet (const morapi_DnnLayer * self)
Gets the child net.
morapi_DnnLayer_getState()
morapi_DnnLayerState morapi_DnnLayer_getState (const morapi_DnnLayer * self)
Gets the state.
morapi_DnnLayer_isFailed()
morapi_Bool morapi_DnnLayer_isFailed (const morapi_DnnLayer * self)
Returns whether failed or not.
morapi_DnnLayer_addWork()
morapi_Tensor * morapi_DnnLayer_addWork (morapi_DnnLayer * self,
const morapi_Char * i_name,
morapi_DType i_dtype,
morapi_Int32 i_rank,
const morapi_Int32 * i_shape,
morapi_Bool i_is_static)
Adds a working tensor.
Call this function by morapi_DnnLayer_init() or morapi_DnnRoutine_init(). Only a leaf layer can add.
Parameters
- self : layer object
- i_name : tensor name
- i_dtype : tensor data type
- i_rank : tensor rank
- i_shape : tensor shape
- i_is_static : whether it's static or not
morapi_DnnLayer_isMutable()
morapi_Bool morapi_DnnLayer_isMutable (const morapi_DnnLayer * self)
Returns whether mutable or not.
If mutable, an output blob changes during inference.
morapi_DnnLayer_isImmutable()
morapi_Bool morapi_DnnLayer_isImmutable (const morapi_DnnLayer * self)
Returns whether immutable or not.
If immutable, no output blobs change after parsing.
morapi_DnnLayer_isConstant()
morapi_Bool morapi_DnnLayer_isConstant (const morapi_DnnLayer * self)
Returns whether constant or not.
If constant, no output blos change at any time. The constant is always immutable, but opposite is not true.
morapi_DnnLayer_addWeight()
morapi_Tensor * morapi_DnnLayer_addWeight (morapi_DnnLayer * self,
const morapi_Char * i_weight_name)
Adds a weight.
Parameters
- self : layer object
- i_weight_name : weight name
morapi_DnnLayer_addEmbeddedWeight()
morapi_Tensor * morapi_DnnLayer_addEmbeddedWeight (morapi_DnnLayer * self,
const morapi_Char * i_weight_name)
Adds an embedded weight.
Parameters
- self : layer object
- i_weight_name : weight name
morapi_DnnLayer_setWeight()
morapi_Result morapi_DnnLayer_setWeight (morapi_DnnLayer * self,
const morapi_Char * i_weight_name,
morapi_Tensor * io_tensor)
Sets a weight.
Parameters
- self : layer object
- i_weight_name : weight name
- io_tensor : tensor containing weight data
morapi_DnnLayer_eraseWeight()
morapi_Result morapi_DnnLayer_eraseWeight (morapi_DnnLayer * self,
const morapi_Char * i_weight_name)
Erases the weight i_weight_name.
Parameters
- self : layer object
- i_weight_name : name of the weight to be erased
morapi_DnnLayer_clearWeight()
morapi_Result morapi_DnnLayer_clearWeight (morapi_DnnLayer * self)
Clears all weights.
Parameters
- self : layer object
morapi_DnnLayer_getWeightNum()
morapi_Int32 morapi_DnnLayer_getWeightNum (const morapi_DnnLayer * self)
Gets the number of weights.
Parameters
- self : layer object
morapi_DnnLayer_getWeightName()
const morapi_Char * morapi_DnnLayer_getWeightName (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th weight name.
Parameters
- self : layer object
- i_index : weight index
morapi_DnnLayer_getWeight()
morapi_Tensor * morapi_DnnLayer_getWeight (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th weight tensor.
Parameters
- self : layer object
- i_index : weight index
morapi_DnnLayer_findWeight()
morapi_Tensor * morapi_DnnLayer_findWeight (const morapi_DnnLayer * self,
const morapi_Char * i_weight_name)
Finds the weight tensor.
Parameters
- self : layer object
- i_weight_name : weight name
morapi_DnnLayer_installWeightOptimizer()
morapi_Result morapi_DnnLayer_installWeightOptimizer (morapi_DnnLayer * self,
morapi_DnnLayerCB_OptimizeWeight i_weight_optimizer)
Installs a weight optimizer.
morapi_DnnLayer_optimizeWeight()
morapi_Tensors * morapi_DnnLayer_optimizeWeight (morapi_DnnLayer * self,
const morapi_Char * i_weight_name,
const morapi_Char * i_optimized_format)
Optimizes the weight and return the tensors.
Called by morapi_DnnRoutineCB_compile().
Parameters
- self : layer object
- i_weight_name : weight_name
- i_optimized_format : optimization format
morapi_DnnLayer_optimizeWeight0()
morapi_Tensor * morapi_DnnLayer_optimizeWeight0 (morapi_DnnLayer * self,
const morapi_Char * i_weight_name,
const morapi_Char * i_optimized_format)
Optimizes the weight and return the first of tensors.
Called by morapi_DnnRoutineCB_init().
Equivalent to:
morapi_Tensor*
morapi_DnnLayer_optimizeWeight0(morapi_DnnLayer *self,
const morapi_Char *i_weight_name,
const morapi_Char *i_optimized_format)
{
morapi_Tensors *optimized = morapi_DnnLayer_optimizeWeight(self, i_weight_name, i_optimized_format);
return morapi_Tensors_get(optimized, 0);
}
fragment
Parameters
- self : layer object
- i_weight_name : weight name
- i_optimized_format : optimization format
morapi_DnnLayer_getInputNum()
morapi_Int32 morapi_DnnLayer_getInputNum (const morapi_DnnLayer * self)
Gets the number of inputs.
Parameters
- self : layer object
morapi_DnnLayer_getInput()
morapi_Tensor * morapi_DnnLayer_getInput (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th input tensor.
Parameters
- self : layer object
- i_index : input tensor index
morapi_DnnLayer_getInputBlob()
morapi_Tensor * morapi_DnnLayer_getInputBlob (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th input blob.
Called by morapi_DnnRoutineCB_compile() or after compiled.
Parameters
- self : layer object
- i_index : input tensor index
morapi_DnnLayer_getPrevLayer()
morapi_DnnLayer * morapi_DnnLayer_getPrevLayer (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the previous layer connected to i_index-th input.
Parameters
- self : layer object
- i_index : input index
morapi_DnnLayer_getPrevLayerOutputIndex()
morapi_Int32 morapi_DnnLayer_getPrevLayerOutputIndex (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the output index at the sending layer connected to i_index-th input.
Parameters
- self : layer object
- i_index : output index
morapi_DnnLayer_setInputDType()
morapi_Result morapi_DnnLayer_setInputDType (morapi_DnnLayer * self,
morapi_Int32 i_index,
morapi_DType i_dtype)
Sets a data type at the i_index-th input.
Parameters
- self : layer object
- i_index : input index
- i_dtype : data type to be set
morapi_DnnLayer_setInputForLayerParam()
morapi_Result morapi_DnnLayer_setInputForLayerParam (morapi_DnnLayer * self,
morapi_Int32 i_index,
morapi_Bool i_is_for_layer_param)
Sets whether input is for layer parameter or not.
Parameters
- self : layer object
- i_index : input index
- i_is_for_layer_param : whether input is for layer parameter or not.
morapi_DnnLayer_enableOutput()
morapi_Result morapi_DnnLayer_enableOutput (morapi_DnnLayer * self,
morapi_Int32 i_index,
morapi_DType i_dtype,
morapi_Int32 i_rank,
const morapi_Int32 * i_shape)
Enables the i_index-th output tensor.
Parameters
- self : layer object
- i_index : output index
- i_dtype : output data type
- i_rank : output rank
- i_shape : output shape
morapi_DnnLayer_getOutputNum()
morapi_Int32 morapi_DnnLayer_getOutputNum (const morapi_DnnLayer * self)
Gets the number of the outputs.
Parameters
- self : layer object
morapi_DnnLayer_getOutput()
morapi_Tensor * morapi_DnnLayer_getOutput (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th output tensor.
Parameters
- self : layer object
- i_index : output index
morapi_DnnLayer_getOutputBlob()
morapi_Tensor * morapi_DnnLayer_getOutputBlob (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th output blob.
Precondition
Call in morapi_DnnRoutineCB_compile() or after morapi_Dnn_compile().
Parameters
- self : layer object
- i_index : output index
morapi_DnnLayer_getOutputDType()
morapi_DType morapi_DnnLayer_getOutputDType (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th output data type.
morapi_DnnLayer_getOutputDump()
morapi_Tensor * morapi_DnnLayer_getOutputDump (const morapi_DnnLayer * self,
morapi_Int32 i_index)
Gets the i_index-th output dump data.
Precondition
Call after morapi_Dnn_compile().
Parameters
- self : layer object
- i_index : output index
morapi_DnnLayer_getNextLayerNumAt()
morapi_Int32 morapi_DnnLayer_getNextLayerNumAt (const morapi_DnnLayer * self,
morapi_Int32 i_output_index)
Gets the number of next layers connected from the i_output_index-th output.
Parameters
- self : layer object
- i_output_index : output index
morapi_DnnLayer_getNextLayer()
morapi_DnnLayer * morapi_DnnLayer_getNextLayer (const morapi_DnnLayer * self,
morapi_Int32 i_output_index,
morapi_Int32 i_next_index)
Gets the i_next_index-th next layer connected from the i_output_index-th output.
Parameters
- self : layer object
- i_output_index : output index
- i_next_index : next layer index
morapi_DnnLayer_getNextLayerInputIndex()
morapi_Int32 morapi_DnnLayer_getNextLayerInputIndex (const morapi_DnnLayer * self,
morapi_Int32 i_output_index,
morapi_Int32 i_next_index)
Gets the input index at the i_next_index-th next layer connected from the i_output_index-th output.
Parameters
- self : layer object
- i_output_index : output index
- i_next_index : next layer input index
Friends And Related Function Documentation
morapi_Dnn_static_getLayerTypeNum()
morapi_Int32 morapi_Dnn_static_getLayerTypeNum (morapi_Env * env)
Gets the number of installed layer types.
Parameters
- env : environment where the layers are installed
morapi_Dnn_static_getLayerTypes()
const morapi_Char ** morapi_Dnn_static_getLayerTypes (morapi_Env * env)
Gets the installed layer types.
Parameters
- env : environment where the layers are installed
morapi_Dnn_static_getDefaultLayerParams()
const morapi_Char * morapi_Dnn_static_getDefaultLayerParams (morapi_Env * env,
const morapi_Char * i_layer_type)
Gets default layer parameters.
Parameters
- env : environment where the layers are installed
- i_layer_type : layer tpye