Typedefs | |
using | KerasMethodMap = std::unordered_map< std::string, std::unique_ptr< ROperator >(*)(PyObject *fLayer)> |
using | KerasMethodMapWithActivation = std::unordered_map< std::string, std::unique_ptr< ROperator >(*)(PyObject *fLayer)> |
Functions | |
void | AddKerasLayer (RModel &rmodel, PyObject *fLayer) |
Adds equivalent ROperator with respect to Keras model layer into the referenced RModel object. | |
std::unique_ptr< ROperator > | MakeKerasActivation (PyObject *fLayer) |
Prepares a ROperator object for Keras activation layer. | |
std::unique_ptr< ROperator > | MakeKerasBatchNorm (PyObject *fLayer) |
Prepares a ROperator object for Keras BatchNorm layer. | |
std::unique_ptr< ROperator > | MakeKerasBinary (PyObject *fLayer) |
Prepares a ROperator object for Keras binary operations like Add, subtract, and multiply. | |
std::unique_ptr< ROperator > | MakeKerasConcat (PyObject *fLayer) |
Prepares a ROperator object for Keras Concat layer. | |
std::unique_ptr< ROperator > | MakeKerasConv (PyObject *fLayer) |
Prepares a ROperator object for Keras Conv Layer. | |
std::unique_ptr< ROperator > | MakeKerasDense (PyObject *fLayer) |
Prepares a ROperator object for Keras Dense Layer. | |
std::unique_ptr< ROperator > | MakeKerasIdentity (PyObject *fLayer) |
Prepares a ROperator object for Keras Identity and Dropout Layer. | |
std::unique_ptr< ROperator > | MakeKerasLeakyRelu (PyObject *fLayer) |
Prepares a ROperator object for Keras Leaky Relu activation. | |
std::unique_ptr< ROperator > | MakeKerasPermute (PyObject *fLayer) |
Prepares a ROperator object for Keras Permute layer. | |
std::unique_ptr< ROperator > | MakeKerasReLU (PyObject *fLayer) |
Prepares a ROperator object for Keras ReLU activation. | |
std::unique_ptr< ROperator > | MakeKerasReshape (PyObject *fLayer) |
Prepares a ROperator object for Keras Reshape layer. | |
std::unique_ptr< ROperator > | MakeKerasSelu (PyObject *fLayer) |
Prepares a ROperator object for Keras Selu activation. | |
std::unique_ptr< ROperator > | MakeKerasSigmoid (PyObject *fLayer) |
Prepares a ROperator object for Keras Sigmoid activation. | |
std::unique_ptr< ROperator > | MakeKerasSoftmax (PyObject *fLayer) |
Prepares a ROperator object for Keras Softmax activation. | |
std::unique_ptr< ROperator > | MakeKerasTanh (PyObject *fLayer) |
Prepares a ROperator object for Keras Tanh activation. | |
Variables | |
const KerasMethodMap | mapKerasLayer |
const KerasMethodMapWithActivation | mapKerasLayerWithActivation |
using TMVA::Experimental::SOFIE::PyKeras::INTERNAL::KerasMethodMap = typedef std::unordered_map<std::string, std::unique_ptr<ROperator> (*)(PyObject *fLayer)> |
Definition at line 65 of file RModelParser_Keras.cxx.
using TMVA::Experimental::SOFIE::PyKeras::INTERNAL::KerasMethodMapWithActivation = typedef std::unordered_map<std::string, std::unique_ptr<ROperator> (*)(PyObject *fLayer)> |
Definition at line 66 of file RModelParser_Keras.cxx.
void TMVA::Experimental::SOFIE::PyKeras::INTERNAL::AddKerasLayer | ( | RModel & | rmodel, |
PyObject * | fLayer | ||
) |
Adds equivalent ROperator with respect to Keras model layer into the referenced RModel object.
[in] | rmodel | RModel object |
[in] | fLayer | Python Keras layer as a Dictionary object |
[out] | RModel | object with the added ROperator |
Function adds equivalent ROperator into the referenced RModel object. Keras models can have layers like Dense and Conv which have activation function as an attribute. Function first searches if layer object is among the ones which don't have activation attribute and then calls the respective preparation function to get the ROperator object, which is then added into the RModel object. If passed layer is among the ones which may have activation attribute, then it checks for the activation attribute, if present then first adds the primary operator into the RModel object, and then adds the operator for the activation function with appropriate changes in the names of input and output tensors for both of them. Example of such layers is the Dense Layer. For a dense layer with input tensor name dense2BiasAdd0 and output tensor name dense3Relu0 with relu as activation attribute will be transformed into a ROperator_Gemm with input tensor name dense2BiasAdd0 & output tensor name dense3Dense (layerName+layerType), and a subsequent ROperator_Relu with input tensor name as dense3Dense and output tensor name as dense3Relu0.
For developing new preparatory functions for supporting Keras layers in future, all one needs is to extract the required properties and attributes from the fLayer dictionary which contains all the information about any Keras layer and after any required transformations, these are passed for instantiating the ROperator object.
The fLayer dictionary which holds all the information about a Keras layer has following structure:-
dict fLayer { 'layerType' : Type of the Keras layer 'layerAttributes' : Attributes of the keras layer as returned by layer.get_config() 'layerInput' : List of names of input tensors 'layerOutput' : List of names of output tensors 'layerDType' : Data-type of the Keras layer 'layerWeight' : List of weight tensor names of Keras layers }
Definition at line 140 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasActivation | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras activation layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
For Keras's keras.layers.Activation layer, the activation attribute is extracted and appropriate function for adding the function is called.
Definition at line 361 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasBatchNorm | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras BatchNorm layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
Definition at line 595 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasBinary | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras binary operations like Add, subtract, and multiply.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_BasicBinary object, the names of input & output tensors, the data-type of the layer and the operation type are extracted.
Definition at line 678 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasConcat | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Concat layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
Definition at line 650 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasConv | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Conv Layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
For Keras's Conv layer, the names of the input tensor, output tensor, and weight tensors are extracted, along with attributes like dilation_rate, groups, kernel size, padding, strides. Padding attribute is then computed for ROperator depending on Keras' attribute parameter.
Definition at line 280 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasDense | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Dense Layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
For Keras's Dense layer, the names of the input tensor, output tensor, and weight tensors are extracted, and then are passed to instantiate a ROperator_Gemm object using the required attributes.
Definition at line 235 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasIdentity | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Identity and Dropout Layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
Dropout will have no effect in inference, so instead an Identity operator is added to mimic its presence in the Keras model
Definition at line 713 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasLeakyRelu | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Leaky Relu activation.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_LeakyRelu object, the names of input & output tensors, the data-type and the alpha attribute of the layer are extracted.
Definition at line 494 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasPermute | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Permute layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
The Permute layer in Keras has an equivalent Tranpose operator in ONNX. For adding a Transpose operator, the permute dimensions are found, if they exist are passed in instantiating the ROperator, else default values are used.
Definition at line 551 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasReLU | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras ReLU activation.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_Relu object, the names of input & output tensors and the data-type of the layer are extracted.
Definition at line 382 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasReshape | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Reshape layer.
[in] | fLayer | Python Keras layer as a Dictionary object |
Definition at line 626 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasSelu | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Selu activation.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_Selu object, the names of input & output tensors and the data-type of the layer are extracted.
Definition at line 411 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasSigmoid | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Sigmoid activation.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_Sigmoid object, the names of input & output tensors and the data-type of the layer are extracted.
Definition at line 439 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasSoftmax | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Softmax activation.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_Softmax object, the names of input & output tensors and the data-type of the layer are extracted.
Definition at line 466 of file RModelParser_Keras.cxx.
std::unique_ptr< ROperator > TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasTanh | ( | PyObject * | fLayer | ) |
Prepares a ROperator object for Keras Tanh activation.
[in] | fLayer | Python Keras layer as a Dictionary object |
For instantiating a ROperator_Tanh object, the names of input & output tensors and the data-type of the layer are extracted.
Definition at line 522 of file RModelParser_Keras.cxx.
const KerasMethodMap TMVA::Experimental::SOFIE::PyKeras::INTERNAL::mapKerasLayer |
Definition at line 68 of file RModelParser_Keras.cxx.
const KerasMethodMapWithActivation TMVA::Experimental::SOFIE::PyKeras::INTERNAL::mapKerasLayerWithActivation |
Definition at line 93 of file RModelParser_Keras.cxx.