2 Copyright (c) 2018 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.extractor import attr_getter
21 from mo.graph.graph import Node
22 from mo.ops.op import Op
25 class PriorBoxClusteredOp(Op):
26 op = 'PriorBoxClustered'
28 def __init__(self, graph: nx.MultiDiGraph, attrs: dict):
32 'infer': PriorBoxClusteredOp.priorbox_clustered_infer
34 super().__init__(graph, mandatory_props, attrs)
36 def supported_attrs(self):
52 def backend_attrs(self):
63 ('variance', lambda node: attr_getter(node, 'variance')),
64 ('width', lambda node: attr_getter(node, 'width')),
65 ('height', lambda node: attr_getter(node, 'height'))
69 def priorbox_clustered_infer(node: Node):
70 data_shape = node.in_node(0).shape
71 num_ratios = len(node.width)
73 res_prod = data_shape[2] * data_shape[3] * num_ratios * 4
74 node.out_node(0).shape = np.array([1, 2, res_prod], dtype=np.int64)