Deformable convolution v8: ngraph part (#6443)
* Deformable convolution: ngraph part * fix docs * add visitor api tests * apply review remarks
This commit is contained in:
@@ -115,6 +115,7 @@ set(SRC
|
||||
type_prop/ctc_greedy_decoder_seq_len.cpp
|
||||
type_prop/ctc_loss.cpp
|
||||
type_prop/deformable_convolution.cpp
|
||||
type_prop/deformable_convolution_opset8.cpp
|
||||
type_prop/deformable_psroi_pooling.cpp
|
||||
type_prop/detection_output.cpp
|
||||
type_prop/depth_to_space.cpp
|
||||
@@ -234,6 +235,7 @@ set(SRC
|
||||
visitors/op/convolution_backprop.cpp
|
||||
visitors/op/cos.cpp
|
||||
visitors/op/cum_sum.cpp
|
||||
visitors/op/deformable_convolution.cpp
|
||||
visitors/op/deformable_psroi_pooling.cpp
|
||||
visitors/op/depth_to_space.cpp
|
||||
visitors/op/detection_output.cpp
|
||||
|
||||
1424
ngraph/test/type_prop/deformable_convolution_opset8.cpp
Normal file
1424
ngraph/test/type_prop/deformable_convolution_opset8.cpp
Normal file
File diff suppressed because it is too large
Load Diff
76
ngraph/test/visitors/op/deformable_convolution.cpp
Normal file
76
ngraph/test/visitors/op/deformable_convolution.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2018-2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "ngraph/ngraph.hpp"
|
||||
#include "ngraph/op/util/attr_types.hpp"
|
||||
#include "ngraph/opsets/opset8.hpp"
|
||||
|
||||
#include "util/visitor.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace ngraph;
|
||||
using ngraph::test::NodeBuilder;
|
||||
using ngraph::test::ValueMap;
|
||||
|
||||
TEST(attributes, deformable_convolution_default_attributes)
|
||||
{
|
||||
NodeBuilder::get_ops().register_factory<opset8::DeformableConvolution>();
|
||||
const Shape inputs_shape{1, 1, 5, 5};
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{1, 1, 5, 5});
|
||||
auto filters = make_shared<op::Parameter>(element::f32, Shape{1, 1, 3, 3});
|
||||
auto offsets = make_shared<op::Parameter>(element::f32, Shape{1, 18, 3, 3});
|
||||
auto strides = Strides{1, 1};
|
||||
auto pads_begin = CoordinateDiff{0, 0};
|
||||
auto pads_end = CoordinateDiff{0, 0};
|
||||
auto dilations = Strides{1, 1};
|
||||
auto convolution = make_shared<opset8::DeformableConvolution>(data, offsets, filters, strides, pads_begin, pads_end, dilations);
|
||||
NodeBuilder builder(convolution);
|
||||
auto g_convolution = as_type_ptr<opset8::DeformableConvolution>(builder.create());
|
||||
|
||||
// attribute count
|
||||
const auto expected_attr_count = 8;
|
||||
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
|
||||
|
||||
EXPECT_EQ(g_convolution->get_strides(), convolution->get_strides());
|
||||
EXPECT_EQ(g_convolution->get_pads_begin(), convolution->get_pads_begin());
|
||||
EXPECT_EQ(g_convolution->get_pads_end(), convolution->get_pads_end());
|
||||
EXPECT_EQ(g_convolution->get_dilations(), convolution->get_dilations());
|
||||
EXPECT_EQ(g_convolution->get_auto_pad(), convolution->get_auto_pad());
|
||||
EXPECT_EQ(g_convolution->get_group(), convolution->get_group());
|
||||
EXPECT_EQ(g_convolution->get_deformable_group(), convolution->get_deformable_group());
|
||||
EXPECT_EQ(g_convolution->get_bilinear_interpolation_pad(), convolution->get_bilinear_interpolation_pad());
|
||||
}
|
||||
|
||||
TEST(attributes, deformable_convolution_attributes)
|
||||
{
|
||||
NodeBuilder::get_ops().register_factory<opset8::DeformableConvolution>();
|
||||
const Shape inputs_shape{1, 1, 5, 5};
|
||||
auto data = make_shared<op::Parameter>(element::f32, Shape{1, 2, 5, 5});
|
||||
auto filters = make_shared<op::Parameter>(element::f32, Shape{2, 1, 3, 3});
|
||||
auto offsets = make_shared<op::Parameter>(element::f32, Shape{1, 36, 5, 5});
|
||||
auto mask = make_shared<op::Parameter>(element::f32, Shape{1, 18, 5, 5});
|
||||
auto strides = Strides{1, 1};
|
||||
auto pads_begin = CoordinateDiff{0, 0};
|
||||
auto pads_end = CoordinateDiff{0, 0};
|
||||
auto dilations = Strides{1, 1};
|
||||
auto convolution = make_shared<opset8::DeformableConvolution>(data, offsets, filters, mask, strides, pads_begin, pads_end, dilations,
|
||||
op::PadType::SAME_LOWER, 2, 2, true);
|
||||
NodeBuilder builder(convolution);
|
||||
auto g_convolution = as_type_ptr<opset8::DeformableConvolution>(builder.create());
|
||||
|
||||
// attribute count
|
||||
const auto expected_attr_count = 8;
|
||||
EXPECT_EQ(builder.get_value_map_size(), expected_attr_count);
|
||||
|
||||
EXPECT_EQ(g_convolution->get_strides(), convolution->get_strides());
|
||||
EXPECT_EQ(g_convolution->get_pads_begin(), convolution->get_pads_begin());
|
||||
EXPECT_EQ(g_convolution->get_pads_end(), convolution->get_pads_end());
|
||||
EXPECT_EQ(g_convolution->get_dilations(), convolution->get_dilations());
|
||||
EXPECT_EQ(g_convolution->get_auto_pad(), convolution->get_auto_pad());
|
||||
EXPECT_EQ(g_convolution->get_group(), convolution->get_group());
|
||||
EXPECT_EQ(g_convolution->get_deformable_group(), convolution->get_deformable_group());
|
||||
EXPECT_EQ(g_convolution->get_bilinear_interpolation_pad(), convolution->get_bilinear_interpolation_pad());
|
||||
}
|
||||
Reference in New Issue
Block a user