add preliminary support of Proposal-4 in nGraph (#1448)

renamed logits -> bbox_deltas

updated ngraph unittests for Proposal

removed validate_and_infer_types Proposal-4

removed validate_and_infer_types Proposal-4

changed validate_and_infer_types in parent class of Proposal

removed get_output_size

successfully inferred Proposal on SSH and Faster-RCNN

added unittests for Proposal-4

added unittests for Proposal-4

added unittests for Proposal-4

returned back default namespace for Proposal

reduced number of outputs in v0::Proposal

correct conversion of Proposal-4 -> propodal_ie with 2 outputs

removed creator for proposal v0

removed converter for proposal v0

added Proposal-4 to MO

removed `for_deformable` attribute

added Proposal-4 to MO and nGraph Python API

removed typo in Proposal-4 specification

style corrections

style corrections and removed some redundant code

rename proposal Python api test

removed 'attrs' context from visitor

returned back AttrVisitor to check if passes OpenVINO ONNX pipeline

Should pass OpenVINO ONNX pipeline (returned back AttrVisitor just to check)

python api for Proposal-4 works ok

(style correction) python api for Proposal-4 works ok

parametrized proposal_ie some other corrections

removed 'attrs.' context from nGraph Python API tests for Proposal

minor corrections in replacer proposal->proposal_ie

corrected Python API OpenVINO-ONNX tests should pass

Improved workaround for AttributeVisitor for Proposal

Add additional check of im_info tensor shape to Proposal node in MKLDNNPlugin

😠 removed 4 extra spaces from test_dyn_attributes.py to match The Style

added new nGraph RTTI declarations, removed throwing exception in transformation

added new nGraph RTTI declarations, removed throwing exception in transformation, corrected exception in MKLDNNplugin

corrected im_info size checking in Proposal node of MKLDNNPlugin
This commit is contained in:
Pavel Esir
2020-08-16 15:49:49 +03:00
committed by GitHub
parent bfedee88b2
commit 4302e2c120
27 changed files with 564 additions and 213 deletions

View File

@@ -750,25 +750,25 @@ def test_detection_output(int_dtype, fp_dtype):
)
def test_proposal(int_dtype, fp_dtype):
attributes = {
"attrs.base_size": int_dtype(1),
"attrs.pre_nms_topn": int_dtype(20),
"attrs.post_nms_topn": int_dtype(64),
"attrs.nms_thresh": fp_dtype(0.34),
"attrs.feat_stride": int_dtype(16),
"attrs.min_size": int_dtype(32),
"attrs.ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=fp_dtype),
"attrs.scale": np.array([2, 3, 3, 4], dtype=fp_dtype),
"base_size": int_dtype(1),
"pre_nms_topn": int_dtype(20),
"post_nms_topn": int_dtype(64),
"nms_thresh": fp_dtype(0.34),
"feat_stride": int_dtype(16),
"min_size": int_dtype(32),
"ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=fp_dtype),
"scale": np.array([2, 3, 3, 4], dtype=fp_dtype),
}
batch_size = 7
class_probs = ng.parameter([batch_size, 12, 34, 62], fp_dtype, "class_probs")
class_logits = ng.parameter([batch_size, 24, 34, 62], fp_dtype, "class_logits")
bbox_deltas = ng.parameter([batch_size, 24, 34, 62], fp_dtype, "bbox_deltas")
image_shape = ng.parameter([3], fp_dtype, "image_shape")
node = ng.proposal(class_probs, class_logits, image_shape, attributes)
node = ng.proposal(class_probs, bbox_deltas, image_shape, attributes)
assert node.get_type_name() == "Proposal"
assert node.get_output_size() == 1
assert list(node.get_output_shape(0)) == [batch_size * attributes["attrs.post_nms_topn"], 5]
assert node.get_output_size() == 2
assert list(node.get_output_shape(0)) == [batch_size * attributes["post_nms_topn"], 5]
def test_tensor_iterator():

View File

@@ -22,21 +22,21 @@ import ngraph as ng
@pytest.fixture()
def _proposal_node():
attributes = {
"attrs.base_size": np.uint16(1),
"attrs.pre_nms_topn": np.uint16(20),
"attrs.post_nms_topn": np.uint16(64),
"attrs.nms_thresh": np.float64(0.34),
"attrs.feat_stride": np.uint16(16),
"attrs.min_size": np.uint16(32),
"attrs.ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=np.float64),
"attrs.scale": np.array([2, 3, 3, 4], dtype=np.float64),
"base_size": np.uint16(1),
"pre_nms_topn": np.uint16(20),
"post_nms_topn": np.uint16(64),
"nms_thresh": np.float64(0.34),
"feat_stride": np.uint16(16),
"min_size": np.uint16(32),
"ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=np.float64),
"scale": np.array([2, 3, 3, 4], dtype=np.float64),
}
batch_size = 7
class_probs = ng.parameter([batch_size, 12, 34, 62], np.float64, "class_probs")
class_logits = ng.parameter([batch_size, 24, 34, 62], np.float64, "class_logits")
bbox_deltas = ng.parameter([batch_size, 24, 34, 62], np.float64, "bbox_deltas")
image_shape = ng.parameter([3], np.float64, "image_shape")
return ng.proposal(class_probs, class_logits, image_shape, attributes)
return ng.proposal(class_probs, bbox_deltas, image_shape, attributes)
def test_dynamic_attributes_softmax():
@@ -124,21 +124,21 @@ def test_dynamic_get_attribute_value(int_dtype, fp_dtype):
)
def test_dynamic_set_attribute_value(int_dtype, fp_dtype):
attributes = {
"attrs.base_size": int_dtype(1),
"attrs.pre_nms_topn": int_dtype(20),
"attrs.post_nms_topn": int_dtype(64),
"attrs.nms_thresh": fp_dtype(0.34),
"attrs.feat_stride": int_dtype(16),
"attrs.min_size": int_dtype(32),
"attrs.ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=fp_dtype),
"attrs.scale": np.array([2, 3, 3, 4], dtype=fp_dtype),
"base_size": int_dtype(1),
"pre_nms_topn": int_dtype(20),
"post_nms_topn": int_dtype(64),
"nms_thresh": fp_dtype(0.34),
"feat_stride": int_dtype(16),
"min_size": int_dtype(32),
"ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=fp_dtype),
"scale": np.array([2, 3, 3, 4], dtype=fp_dtype),
}
batch_size = 7
class_probs = ng.parameter([batch_size, 12, 34, 62], fp_dtype, "class_probs")
class_logits = ng.parameter([batch_size, 24, 34, 62], fp_dtype, "class_logits")
bbox_deltas = ng.parameter([batch_size, 24, 34, 62], fp_dtype, "bbox_deltas")
image_shape = ng.parameter([3], fp_dtype, "image_shape")
node = ng.proposal(class_probs, class_logits, image_shape, attributes)
node = ng.proposal(class_probs, bbox_deltas, image_shape, attributes)
node.set_base_size(int_dtype(15))
node.set_pre_nms_topn(int_dtype(7))

View File

@@ -0,0 +1,48 @@
# ******************************************************************************
# Copyright 2017-2020 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
import ngraph as ng
from ngraph.impl import Shape, Type
def test_proposal_props():
float_dtype = np.float32
batch_size = 1
post_nms_topn = 20
probs = ng.parameter(Shape([batch_size, 8, 255, 255]), dtype=float_dtype, name="probs")
deltas = ng.parameter(Shape([batch_size, 16, 255, 255]), dtype=float_dtype, name="bbox_deltas")
im_info = ng.parameter(Shape([4]), dtype=float_dtype, name="im_info")
attrs = {
"base_size": np.uint32(85),
"pre_nms_topn": np.uint32(10),
"post_nms_topn": np.uint32(post_nms_topn),
"nms_thresh": np.float32(0.34),
"feat_stride": np.uint32(16),
"min_size": np.uint32(32),
"ratio": np.array([0.1, 1.5, 2.0, 2.5], dtype=np.float32),
"scale": np.array([2, 3, 3, 4], dtype=np.float32),
}
node = ng.proposal(probs, deltas, im_info, attrs)
assert node.get_type_name() == "Proposal"
assert node.get_output_size() == 2
assert list(node.get_output_shape(0)) == [batch_size * post_nms_topn, 5]
assert list(node.get_output_shape(1)) == [batch_size * post_nms_topn]
assert node.get_output_element_type(0) == Type.f32
assert node.get_output_element_type(1) == Type.f32