Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mxnet extractors #1667

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions docs/MO_DG/prepare_model/Supported_Frameworks_Layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,6 @@ Standard MXNet\* symbols:

| Symbol Name in MXNet\*| Limitations|
| :----------| :----------|
| Activation | supported "act_type" = "relu", "sigmoid", "softrelu" or "tanh" |
| BatchNorm | No |
| Concat | No |
| Convolution | No |
| Crop | "center_crop" = 1 is not supported |
| Custom | [Custom Layers in the Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md) |
| Deconvolution | No |
| DeformableConvolution | No |
| DeformablePSROIPooling | No |
| Dropout | Not needed for inference |
| ElementWiseSum | No |
| Embedding | No |
| Flatten | No |
| FullyConnected | No |
| InstanceNorm | No |
| L2Normalization | only 4D input is supported |
| LRN | No |
| LeakyReLU | No |
| Pad | No |
| Pooling | No |
| ROIPooling | No |
| ReLU | No |
| Reshape | No |
| ScaleShift | No |
| SoftmaxActivation | No |
| SoftmaxOutput | No |
| SoftSign | No |
| Tile | No |
| UpSampling | No |
| Where | No |
| _Plus | No |
| _contrib_MultiBoxDetection | "force_suppress" = 1 is not supported, non-default variances are not supported |
| _contrib_MultiBoxPrior | No |
Expand All @@ -82,6 +52,9 @@ Standard MXNet\* symbols:
| _maximum | No |
| _minimum | No |
| add_n | No |
| arccosh | No |
| arcsinh | No |
| arctanh | No |
| broadcast_add | No |
| broadcast_mul | No |
| cumsum | No |
Expand All @@ -107,6 +80,36 @@ Standard MXNet\* symbols:
| tile | No |
| transpose | No |
| zeros | No |
| Activation | supported "act_type" = "relu", "sigmoid", "softrelu" or "tanh" |
| BatchNorm | No |
| Concat | No |
| Convolution | No |
| Crop | "center_crop" = 1 is not supported |
| Custom | [Custom Layers in the Model Optimizer](customize_model_optimizer/Customize_Model_Optimizer.md) |
| Deconvolution | No |
| DeformableConvolution | No |
| DeformablePSROIPooling | No |
| Dropout | Not needed for inference |
| ElementWiseSum | No |
| Embedding | No |
| Flatten | No |
| FullyConnected | No |
| InstanceNorm | No |
| L2Normalization | only 4D input is supported |
| LRN | No |
| LeakyReLU | No |
| Pad | No |
| Pooling | No |
| ROIPooling | No |
| ReLU | No |
| Reshape | No |
| ScaleShift | No |
| SoftmaxActivation | No |
| SoftmaxOutput | No |
| SoftSign | No |
| Tile | No |
| UpSampling | No |
| Where | No |


## TensorFlow\* Supported Operations
Expand Down
32 changes: 31 additions & 1 deletion model-optimizer/extensions/front/mxnet/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
"""

from extensions.ops.activation_ops import SoftPlus, Sigmoid, Tanh, ReLU
from extensions.ops.activation_ops import SoftPlus, Sigmoid, Tanh, ReLU, Asinh, Acosh, Atanh
from mo.front.extractor import FrontExtractorOp
from mo.front.mxnet.extractors.utils import get_mxnet_layer_attrs
from mo.utils.error import Error
Expand Down Expand Up @@ -44,3 +44,33 @@ def extract(cls, node):
act_type)
act_class.update_node_stat(node)
return cls.enabled


class AsinhFrontExtractor(FrontExtractorOp):
iimironov marked this conversation as resolved.
Show resolved Hide resolved
op = 'arcsinh'
enabled = True

@classmethod
def extract(cls, node):
Asinh.update_node_stat(node)
return cls.enabled


class AcoshFrontExtractor(FrontExtractorOp):
op = 'arccosh'
enabled = True

@classmethod
def extract(cls, node):
Acosh.update_node_stat(node)
return cls.enabled


class AtanhFrontExtractor(FrontExtractorOp):
op = 'arctanh'
enabled = True

@classmethod
def extract(cls, node):
Atanh.update_node_stat(node)
return cls.enabled
15 changes: 15 additions & 0 deletions model-optimizer/extensions/ops/activation_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ class Asinh(Activation):
op = 'Asinh'
operation = staticmethod(lambda x: np.arcsinh(x))

def __init__(self, graph: Graph, attrs: dict):
sp_attrs = {'version': 'opset4'}
sp_attrs.update(attrs)
super().__init__(graph, sp_attrs)


class Cos(Activation):
op = 'Cos'
Expand All @@ -89,6 +94,11 @@ class Acosh(Activation):
op = 'Acosh'
operation = staticmethod(lambda x: np.arccosh(x))

def __init__(self, graph: Graph, attrs: dict):
sp_attrs = {'version': 'opset4'}
sp_attrs.update(attrs)
super().__init__(graph, sp_attrs)


class Tan(Activation):
op = 'Tan'
Expand All @@ -109,6 +119,11 @@ class Atanh(Activation):
op = 'Atanh'
operation = staticmethod(lambda x: np.arctanh(x))

def __init__(self, graph: Graph, attrs: dict):
sp_attrs = {'version': 'opset4'}
sp_attrs.update(attrs)
super().__init__(graph, sp_attrs)


class ReLU6(AttributedClamp):
op = 'ReLU6'
Expand Down