Skip to content

Commit

Permalink
[Template plugin] Unify headers inclusion (openvinotoolkit#20326)
Browse files Browse the repository at this point in the history
* Use precise op version - Parameter

* Use precise op version - Constant

* Use precise op version - Result

* Use precise op version - Add, Concat, Subtract

* Use precise op version - NMS

* Use precise op version - TopK, Broadcast

* Use precise op version

* Include openvino headers in quotes

* Use precise op version - LSTMCell

* Fix code style
  • Loading branch information
t-jankowski authored Oct 11, 2023
1 parent 10d1862 commit aa7405f
Show file tree
Hide file tree
Showing 38 changed files with 750 additions and 702 deletions.
2 changes: 1 addition & 1 deletion src/plugins/template/src/itt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include <openvino/itt.hpp>
#include "openvino/itt.hpp"

namespace ov {
namespace template_plugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/batch_to_space.hpp"

#include <gtest/gtest.h>

#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset2.hpp"
#include "openvino/op/parameter.hpp"

using namespace reference_tests;
using namespace ov;
Expand Down Expand Up @@ -47,7 +48,7 @@ class ReferenceBatchToSpaceLayerTest : public testing::TestWithParam<BatchToSpac
}

static std::string getTestCaseName(const testing::TestParamInfo<BatchToSpaceParams>& obj) {
auto param = obj.param;
const auto& param = obj.param;
std::ostringstream result;
result << "dType=" << param.dataTensor.type;
result << "_dShape=" << param.dataTensor.shape;
Expand All @@ -69,11 +70,11 @@ class ReferenceBatchToSpaceLayerTest : public testing::TestWithParam<BatchToSpac

private:
static std::shared_ptr<Model> CreateFunction(const BatchToSpaceParams& params) {
const auto data = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto blockShape = std::make_shared<opset1::Parameter>(element::i64, params.blockShapeTensor.shape);
const auto cropsBegin = std::make_shared<opset1::Parameter>(element::i64, params.cropsBeginTensor.shape);
const auto cropsEnd = std::make_shared<opset1::Parameter>(element::i64, params.cropsEndTensor.shape);
const auto batchToSpace = std::make_shared<opset2::BatchToSpace>(data, blockShape, cropsBegin, cropsEnd);
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto blockShape = std::make_shared<op::v0::Parameter>(element::i64, params.blockShapeTensor.shape);
const auto cropsBegin = std::make_shared<op::v0::Parameter>(element::i64, params.cropsBeginTensor.shape);
const auto cropsEnd = std::make_shared<op::v0::Parameter>(element::i64, params.cropsEndTensor.shape);
const auto batchToSpace = std::make_shared<op::v1::BatchToSpace>(data, blockShape, cropsBegin, cropsEnd);
return std::make_shared<Model>(NodeVector{batchToSpace},
ParameterVector{data, blockShape, cropsBegin, cropsEnd});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <gtest/gtest.h>

#include "base_reference_test.hpp"
#include "openvino/opsets/opset8.hpp"
#include "openvino/op/constant.hpp"

using namespace reference_tests;
using namespace ov;
Expand Down Expand Up @@ -95,7 +95,7 @@ class ReferenceBinaryConvolutionLayerTest : public testing::TestWithParam<Binary
const std::vector<uint8_t>& filterData) {
const op::PadType auto_pad{op::PadType::EXPLICIT};
const auto in = std::make_shared<op::v0::Parameter>(params.inType, params.inputShape);
auto filter = std::make_shared<opset8::Constant>(ov::element::u1, params.filterShape, &filterData[0]);
auto filter = std::make_shared<op::v0::Constant>(ov::element::u1, params.filterShape, &filterData[0]);
const auto BinaryConvolution = std::make_shared<op::v1::BinaryConvolution>(in,
filter,
params.strides,
Expand Down
51 changes: 27 additions & 24 deletions src/plugins/template/tests/functional/op_reference/broadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/broadcast.hpp"

#include <gtest/gtest.h>

#include "base_reference_test.hpp"
#include "openvino/opsets/opset1.hpp"
#include "openvino/opsets/opset3.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/reverse.hpp"

using namespace reference_tests;
using namespace ov;
Expand Down Expand Up @@ -56,10 +59,10 @@ class ReferenceBroadcastTest : public testing::TestWithParam<BroadcastParams>, p

private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParams& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto A = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto f = std::make_shared<Model>(
std::make_shared<opset1::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
std::make_shared<op::v1::Broadcast>(A,
op::v0::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data())),
ParameterVector{A});
Expand All @@ -74,10 +77,10 @@ TEST_P(ReferenceBroadcastTest, CompareWithRefs) {
class ReferenceBroadcastTestV3 : public ReferenceBroadcastTest {
private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParams& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto A = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto f = std::make_shared<Model>(
std::make_shared<opset3::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
std::make_shared<op::v3::Broadcast>(A,
op::v0::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data())),
ParameterVector{A});
Expand Down Expand Up @@ -132,13 +135,13 @@ class ReferenceBroadcastTestExplicitAxis : public testing::TestWithParam<Broadca

private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParamsExplicitAxis& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto A = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto f = std::make_shared<Model>(
std::make_shared<opset1::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
std::make_shared<op::v1::Broadcast>(A,
op::v0::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data()),
opset1::Constant::create(params.axesMappingTensor.type,
op::v0::Constant::create(params.axesMappingTensor.type,
params.axesMappingTensor.shape,
params.axesMappingTensor.data.data())),
ParameterVector{A});
Expand Down Expand Up @@ -203,15 +206,15 @@ class ReferenceBroadcastTestTestHelper : public testing::TestWithParam<Broadcast

private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParamsTestHelper& params) {
const auto A = std::make_shared<opset1::Parameter>(element::f32, params.shapeA);
const auto shape_const = opset1::Constant::create(element::u64, Shape{params.shapeR.size()}, params.shapeR);
const auto A = std::make_shared<op::v0::Parameter>(element::f32, params.shapeA);
const auto shape_const = op::v0::Constant::create(element::u64, Shape{params.shapeR.size()}, params.shapeR);
std::shared_ptr<Node> broadcast;
if (params.axes.size() > 0) {
auto axes_const =
opset1::Constant::create(element::i64, Shape{params.axes.size()}, params.axes.to_vector());
broadcast = std::make_shared<opset1::Broadcast>(A, shape_const, axes_const);
op::v0::Constant::create(element::i64, Shape{params.axes.size()}, params.axes.to_vector());
broadcast = std::make_shared<op::v1::Broadcast>(A, shape_const, axes_const);
} else {
broadcast = std::make_shared<opset1::Broadcast>(A, shape_const);
broadcast = std::make_shared<op::v1::Broadcast>(A, shape_const);
}
auto f = std::make_shared<Model>(broadcast, ParameterVector{A});
return f;
Expand Down Expand Up @@ -239,18 +242,18 @@ TEST_P(ReferenceBroadcastTestTestHelper, CompareWithRefs) {
class ReferenceBroadcastTestExplicitAxisReversed : public ReferenceBroadcastTestExplicitAxis {
private:
static std::shared_ptr<Model> CreateFunction(const BroadcastParamsExplicitAxis& params) {
const auto A = std::make_shared<opset1::Parameter>(params.dataTensor.type, params.dataTensor.shape);
const auto A = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
auto broadcast =
std::make_shared<opset1::Broadcast>(A,
opset1::Constant::create(params.targetShapeTensor.type,
std::make_shared<op::v1::Broadcast>(A,
op::v0::Constant::create(params.targetShapeTensor.type,
params.targetShapeTensor.shape,
params.targetShapeTensor.data.data()),
opset1::Constant::create(params.axesMappingTensor.type,
op::v0::Constant::create(params.axesMappingTensor.type,
params.axesMappingTensor.shape,
params.axesMappingTensor.data.data()));
auto reverse = std::make_shared<opset1::Reverse>(broadcast,
opset1::Constant::create(element::i64, {1}, {1}),
opset1::Reverse::Mode::INDEX);
auto reverse = std::make_shared<op::v1::Reverse>(broadcast,
op::v0::Constant::create(element::i64, {1}, {1}),
op::v1::Reverse::Mode::INDEX);
auto f = std::make_shared<Model>(NodeVector{reverse}, ParameterVector{A});
return f;
}
Expand Down
Loading

0 comments on commit aa7405f

Please sign in to comment.