2 Copyright (c) 2018-2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
20 from mo.front.common.layout import get_width_dim, get_height_dim
21 from mo.front.extractor import attr_getter
22 from mo.graph.graph import Node, Graph
23 from mo.ops.op import Op
26 class PriorBoxClusteredOp(Op):
27 op = 'PriorBoxClustered'
29 def __init__(self, graph: Graph, attrs: dict):
35 'infer': PriorBoxClusteredOp.priorbox_clustered_infer
37 super().__init__(graph, mandatory_props, attrs)
39 def supported_attrs(self):
55 def backend_attrs(self):
66 ('variance', lambda node: attr_getter(node, 'variance')),
67 ('width', lambda node: attr_getter(node, 'width')),
68 ('height', lambda node: attr_getter(node, 'height'))
72 def priorbox_clustered_infer(node: Node):
73 layout = node.graph.graph['layout']
74 data_shape = node.in_node(0).shape
75 num_ratios = len(node.width)
77 res_prod = data_shape[get_height_dim(layout, 4)] * data_shape[get_width_dim(layout, 4)] * num_ratios * 4
78 node.out_node(0).shape = np.array([1, 2, res_prod], dtype=np.int64)