* Commit. * Started to write nGraph operation ExperimentalDetectronDetectionOutput. Written draft of the header file. * Written draft of the cpp-file for nGraph operation ExperimentalDetectronDetectionOutput. * Small fix. * Added reading of ExperimentalDetectronDetectionOutput as nGraph operation. * Some fix. * Unregistered old shape infer function of the operation ExperimentalDetectronDetectionOutput. * Written the header file for the operation ExperimentalDetectronPriorGridGenerator. * Small refactoring. * Small fix. * Added set_output_size(3) into op::ExperimentalDetectronDetectionOutput::validate_and_infer_types(). * Added check for number of inputs of ExperimentalDetectronDetectionOutput. * Reverted some changes. * Changed IR for ExperimentalDetectronDetectionOutput serialization test. * Written cpp-file of nGraph operation ExperimentalDetectronPriorGridGenerator. * Small fix. * Some fixes. * Fixes in type and shape infer functions of the MO operation ExperimentalDetectronDetectionOutput. * Now ExperimentalDetectronPriorGridGenerator is readed as nGraph operation. * Fixed the infer function of the nGraph operation ExperimentalDetectronPriorGridGenerator. * Started to write tests for the shape infer function of the nGraph operation ExperimentalDetectronDetectionOutput. * Written the draft of the test for the shape infer function of the nGraph operation ExperimentalDetectronDetectionOutput. * Small fix. * Fixed ngraph/test/CMakeLists.txt. * Started to write tests for the shape infer function of the nGraph operation ExperimentalDetectronPriorGridGenerator. * Now the shape infer function of the nGraph operation ExperimentalDetectronPriorGridGenerator performs correctly case dynamic input shapes with static ranks. * Continued to write test for the nGraph operation ExperimentalDetectronPriorGridGenerator. * Small fixes. * Written tests for the shape infer function of the nGraph operation ExperimentalDetectronPriorGridGenerator (case when input shapes are partially dynamic). * Added test for reading ExperimentalDetectronDetectionOutput as an operation from opset6. * Some fixes. * Added some debug outputs. * Deleted inserted debug output. * Small fixes. * Small fix. * Small fix. * Small change. * Added comments to attributes of ExperimentalDetectronDetectionOutput. * Reverted changes. * Deleted shape infer for output port 3. * Small fixes. * Deleted redundant keyword 'virtual'. * Deleted redundant usings in header files of nGraph operations ExperimentalDetectronDetectionOutput and ExperimentalDetectronPriorGridGenerator. * Some fixes. * Small change. * Now GridGenerator::validate takes three args (input partial shapes). * Small fix. * Deleted some usings. * Small code style fix. * Reverted changes in validate_and_infer_types() and validate() of op::v6::ExperimentalDetectronPriorGridGenerator. * Added description of the class ExperimentalDetectronDetectionOutput. * Added some comments into the header file of the nGraph operation ExperimentalDetectronPriorGridGenerator. * Some fixes. * Added some comments to the class of the nGraph operation ExperimentalDetectronPriorGridGenerator. * Now the MO operation ExperimentalDetectronDetectionOutput has the attribute 'version' as 'opset6'. * Now the MO operation ExperimentalDetectronPriorGridGenerator has the attribute 'version' as 'opset6'. * Some fixes in the MO class ExperimentalDetectronDetectionOutput. * Fixes in the shape infer function of the nGraph operation ExperimentalDetectronPriorGridGenerator. * Renamed test XML model for ExperimentalDetectronDetectionOutput serialization tests. * Added validation of input shapes for the nGraph operation ExperimentalDetectronDetectionOutput. * Small fixes in the XML models for serialization testing of ExperimentalDetectronDetectionOutput. * Added tests of shape infer function of the nGraph operation ExperimentalDetectronDetectionOutput for the case when input shapes are partially dynamic. * Added tests of shape infer function of the nGraph operation ExperimentalDetectronDetectionOutput for the case when some input shapes have dynamic ranks. * Small fixes. * Small fix in the MO operation ExperimentalDetectronDetectionOutput shape infer function. * Fixes in op::v6::ExperimentalDetectronDetectionOutput::validate_and_infer_types(). * Code style fix. * Small refactoring. * Added NGRAPH_OP_SCOPE into ExperimentalDetectronDetectionOutput nGraph class. * Added NGRAPH_OP_SCOPE to the nGraph class ExperimentalDetectronPriorGridGenerator. * Small fixes. * Some refactoring. * Small fix. * Small fixes. * Reverted some changes in ExperimentalDetectronDetectionOutput::validate_and_infer_type(). * Now VPU reads the attribute class_agnostic_box_regression of ExperimentalDetectronDetectionOutput as Bool. * Now MO generates attribute 'class_agnostic_box_regression' of ExperimentalDetectronDetectionOutput only with values false or true. * Small fix. * Tabs were replaced by spaces in some XMLs. * Fixed copyrights. * Refactoring in op::v6::ExperimentalDetectronDetectionOutput::validate_and_infer_types(). * Refactoring in op::v6::ExperimentalDetectronPriorGridGenerator::validate_and_infer_types(). * Small fixes. * Started to write ExperimentalDetectronPriorGridGenerator shape infer tests for the case when dynamic input dimensions are intervals. * Deleted redundant 'return'. * Written tests for interval values of input shapes of op::v6::ExperimentalDetectronPriorGridGenerator. * Code style fix. * Code style fix.
71 lines
2.6 KiB
Python
71 lines
2.6 KiB
Python
"""
|
|
Copyright (C) 2018-2021 Intel Corporation
|
|
|
|
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.
|
|
"""
|
|
|
|
import numpy as np
|
|
|
|
from mo.front.common.partial_infer.utils import int64_array
|
|
from mo.ops.op import Op
|
|
|
|
|
|
class ExperimentalDetectronDetectionOutput(Op):
|
|
op = 'ExperimentalDetectronDetectionOutput'
|
|
enabled = True
|
|
|
|
def __init__(self, graph, attrs):
|
|
mandatory_props = dict(
|
|
type=__class__.op,
|
|
op=__class__.op,
|
|
version='opset6',
|
|
infer=__class__.infer,
|
|
type_infer=self.type_infer,
|
|
in_ports_count=4,
|
|
out_ports_count=3,
|
|
)
|
|
|
|
super().__init__(graph, mandatory_props, attrs)
|
|
|
|
def backend_attrs(self):
|
|
return [
|
|
('class_agnostic_box_regression', lambda node: str(bool(node['class_agnostic_box_regression'])).lower()),
|
|
'max_detections_per_image',
|
|
'nms_threshold',
|
|
'num_classes',
|
|
'post_nms_count',
|
|
'score_threshold',
|
|
'max_delta_log_wh',
|
|
('deltas_weights', lambda node: ','.join(map(str, node['deltas_weights'])))]
|
|
|
|
@staticmethod
|
|
def infer(node):
|
|
rois_num = node.max_detections_per_image
|
|
# boxes
|
|
node.out_node(0).shape = np.array([rois_num, 4], dtype=np.int64)
|
|
# classes, scores, batch indices
|
|
# We use range(1, 1 + max(node.out_ports().keys())) instead of range(1, 3), because there are incorrectly
|
|
# generated models where ExperimentalDetectronDetectionOutput has 4 outputs.
|
|
for port_ind in range(1, 1 + max(node.out_ports().keys())):
|
|
if not node.out_port(port_ind).disconnected():
|
|
node.out_port(port_ind).data.set_shape(int64_array([rois_num]))
|
|
|
|
@staticmethod
|
|
def type_infer(node):
|
|
in_data_type = node.in_port(0).get_data_type()
|
|
node.out_port(0).set_data_type(in_data_type)
|
|
node.out_port(1).set_data_type(np.int32) # the second output contains class indices
|
|
node.out_port(2).set_data_type(in_data_type)
|
|
if node.is_out_port_connected(3):
|
|
node.out_port(3).set_data_type(np.int32) # the fourth output contains batch indices
|