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 > | MakeKerasDense (PyObject *fLayer) |
Prepares a ROperator object for Keras Dense Layer. | |
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 > | 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. | |
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 53 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 54 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 115 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 222 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 180 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 328 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 deta-type of the layer are extracted.
Definition at line 242 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 deta-type of the layer are extracted.
Definition at line 271 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 deta-type of the layer are extracted.
Definition at line 299 of file RModelParser_Keras.cxx.
const KerasMethodMap TMVA::Experimental::SOFIE::PyKeras::INTERNAL::mapKerasLayer |
Definition at line 56 of file RModelParser_Keras.cxx.
const KerasMethodMapWithActivation TMVA::Experimental::SOFIE::PyKeras::INTERNAL::mapKerasLayerWithActivation |
Definition at line 69 of file RModelParser_Keras.cxx.