Files
openvino/model-optimizer/extensions/ops/reverse_sequence.py
T

50 lines
1.5 KiB
Python
Raw Normal View History

2018-11-23 16:19:43 +03:00
"""
2020-02-11 22:48:49 +03:00
Copyright (C) 2017-2020 Intel Corporation
2018-11-23 16:19:43 +03:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
2019-04-12 18:25:53 +03:00
from mo.graph.graph import Graph
from mo.ops.op import Op
2018-11-23 16:19:43 +03:00
2019-01-21 21:31:31 +03:00
class ReverseSequence(Op):
op = 'ReverseSequence'
2018-11-23 16:19:43 +03:00
2019-04-12 18:25:53 +03:00
def __init__(self, graph: Graph, attrs: dict):
2018-11-23 16:19:43 +03:00
mandatory_props = {
2019-04-12 18:25:53 +03:00
'type': __class__.op,
'version': 'opset1',
2019-04-12 18:25:53 +03:00
'seq_axis': None,
'batch_axis': 0,
2018-11-23 16:19:43 +03:00
'op': __class__.op,
2019-04-12 18:25:53 +03:00
'in_ports_count': 2,
'out_ports_count': 1,
2019-01-21 21:31:31 +03:00
'infer': __class__.infer,
2018-11-23 16:19:43 +03:00
}
super().__init__(graph, mandatory_props, attrs)
def supported_attrs(self):
return [
2019-04-12 18:25:53 +03:00
'seq_axis', 'batch_axis',
2018-11-23 16:19:43 +03:00
]
2019-04-12 18:25:53 +03:00
2018-11-23 16:19:43 +03:00
@staticmethod
2019-01-21 21:31:31 +03:00
def infer(node):
2019-04-12 18:25:53 +03:00
input_data_shape = node.in_node(0).shape
assert input_data_shape is not None
assert node.has_valid('seq_axis')
assert node.has_valid('batch_axis')
2019-01-21 21:31:31 +03:00
assert len(node.out_nodes()) == 1
2019-04-12 18:25:53 +03:00
node.out_node().shape = input_data_shape.copy()