Refactor ngraph builders 7 (#21181)
* Refactor make_reduce builder * Refactor make_comparison builder * Refactor make_logical builder * Refactor make_fully_connected * Refactor make_lstm builder * Refactor make_gru builder * Refactor make_rnn builder * refactor make_augru builder * Refactor make_gather_nd builders * Refactor make_dft builder * Refactor make_rdft builder * Fix code style * Fix --------- Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>
This commit is contained in:
parent
165f574d8f
commit
6607e5b8c2
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/augru_cell.hpp"
|
||||
#include "test_utils/cpu_test_utils.hpp"
|
||||
|
||||
using namespace CPUTestUtils;
|
||||
@ -101,7 +101,7 @@ protected:
|
||||
paramsOuts.push_back(param);
|
||||
}
|
||||
std::vector<ngraph::Shape> WRB = {{3 * hiddenSize, inputSize}, {3 * hiddenSize, hiddenSize}, {(linearBeforeReset ? 4 : 3) * hiddenSize}};
|
||||
auto augruCellOp = ngraph::builder::makeAUGRU(paramsOuts, WRB, hiddenSize/*, activations, {}, {}, clip, linearBeforeReset*/);
|
||||
auto augruCellOp = ov::test::utils::make_augru(paramsOuts, WRB, hiddenSize/*, activations, {}, {}, clip, linearBeforeReset*/);
|
||||
|
||||
function = makeNgraphFunction(netPrecision, params, augruCellOp, "AUGRUCell");
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/augru_cell.hpp"
|
||||
#include "test_utils/cpu_test_utils.hpp"
|
||||
#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp"
|
||||
#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp"
|
||||
@ -136,7 +136,7 @@ protected:
|
||||
|
||||
std::vector<ov::Shape> WRB = {{numDirections, 3 * hiddenSize, inputSize}, {numDirections, 3 * hiddenSize, hiddenSize},
|
||||
{numDirections, (linearBeforeReset ? 4 : 3) * hiddenSize}, {batchSize}};
|
||||
auto augruSequenceOp = ngraph::builder::makeAUGRU(paramsOuts,
|
||||
auto augruSequenceOp = ov::test::utils::make_augru(paramsOuts,
|
||||
WRB,
|
||||
hiddenSize,
|
||||
true,
|
||||
|
@ -17,8 +17,8 @@ namespace test {
|
||||
|
||||
typedef std::tuple<
|
||||
std::vector<InputShape>, // Input shapes tuple
|
||||
ngraph::helpers::ComparisonTypes, // Comparison op type
|
||||
ngraph::helpers::InputLayerType, // Second input type
|
||||
ov::test::utils::ComparisonTypes, // Comparison op type
|
||||
ov::test::utils::InputLayerType, // Second input type
|
||||
ov::element::Type, // Model type
|
||||
std::string, // Device name
|
||||
std::map<std::string, std::string> // Additional network configuration
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
#include "shared_test_classes/single_op/comparison.hpp"
|
||||
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/comparison.hpp"
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
using ngraph::helpers::ComparisonTypes;
|
||||
using ngraph::helpers::InputLayerType;
|
||||
using ov::test::utils::ComparisonTypes;
|
||||
using ov::test::utils::InputLayerType;
|
||||
|
||||
std::string ComparisonLayerTest::getTestCaseName(const testing::TestParamInfo<ComparisonTestParams> &obj) {
|
||||
std::vector<InputShape> shapes;
|
||||
@ -51,7 +51,7 @@ void ComparisonLayerTest::SetUp() {
|
||||
InputLayerType second_input_type;
|
||||
std::map<std::string, std::string> additional_config;
|
||||
ov::element::Type model_type;
|
||||
ngraph::helpers::ComparisonTypes comparison_op_type;
|
||||
ov::test::utils::ComparisonTypes comparison_op_type;
|
||||
std::tie(shapes,
|
||||
comparison_op_type,
|
||||
second_input_type,
|
||||
@ -72,7 +72,7 @@ void ComparisonLayerTest::SetUp() {
|
||||
second_input = std::make_shared<ov::op::v0::Constant>(tensor);
|
||||
}
|
||||
|
||||
auto comparisonNode = ngraph::builder::makeComparison(inputs[0], second_input, comparison_op_type);
|
||||
auto comparisonNode = ov::test::utils::make_comparison(inputs[0], second_input, comparison_op_type);
|
||||
function = std::make_shared<ov::Model>(comparisonNode, inputs, "Comparison");
|
||||
}
|
||||
} // namespace test
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "shared_test_classes/single_op/dft.hpp"
|
||||
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/dft.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -49,7 +49,7 @@ void DFTLayerTest::SetUp() {
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
|
||||
|
||||
auto dft = ngraph::builder::makeDFT(param, axes, signal_size, op_type);
|
||||
auto dft = ov::test::utils::make_dft(param, axes, signal_size, op_type);
|
||||
|
||||
auto result = std::make_shared<ov::op::v0::Result>(dft);
|
||||
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "DFT");
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "shared_test_classes/single_op/gather_nd.hpp"
|
||||
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/gather_nd.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -47,7 +47,7 @@ void GatherNDLayerTest::SetUp() {
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
|
||||
|
||||
auto gather = ngraph::builder::makeGatherND(param, indices_shape, indices_type, batch_dims);
|
||||
auto gather = ov::test::utils::make_gather_nd(param, indices_shape, indices_type, batch_dims);
|
||||
|
||||
auto result = std::make_shared<ov::op::v0::Result>(gather);
|
||||
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gatherND");
|
||||
@ -68,7 +68,7 @@ void GatherND8LayerTest::SetUp() {
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
|
||||
|
||||
auto gather = ngraph::builder::makeGatherND8(param, indices_shape, indices_type, batch_dims);
|
||||
auto gather = ov::test::utils::make_gather_nd8(param, indices_shape, indices_type, batch_dims);
|
||||
|
||||
auto result = std::make_shared<ov::op::v0::Result>(gather);
|
||||
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "gatherND");
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "shared_test_classes/single_op/logical.hpp"
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/logical.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -63,7 +63,7 @@ void LogicalLayerTest::SetUp() {
|
||||
secondInput = param;
|
||||
params.push_back(param);
|
||||
}
|
||||
logical_node = ngraph::builder::makeLogical(params[0], secondInput, logical_op_type);
|
||||
logical_node = ov::test::utils::make_logical(params[0], secondInput, logical_op_type);
|
||||
} else {
|
||||
logical_node = std::make_shared<ov::op::v1::LogicalNot>(params[0]);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "shared_test_classes/single_op/rdft.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/rdft.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -35,7 +35,7 @@ void RDFTLayerTest::SetUp() {
|
||||
std::tie(input_shape, model_type, axes, signal_size, op_type, targetDevice) = this->GetParam();
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape));
|
||||
auto rdft = ngraph::builder::makeRDFT(param, axes, signal_size, op_type);
|
||||
auto rdft = ov::test::utils::make_rdft(param, axes, signal_size, op_type);
|
||||
function = std::make_shared<ov::Model>(rdft->outputs(), ov::ParameterVector{param}, "RDFT");
|
||||
}
|
||||
} // namespace test
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "shared_test_classes/single_op/reduce_ops.hpp"
|
||||
#include "common_test_utils/data_utils.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/reduce.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -55,7 +55,7 @@ void ReduceOpsLayerTest::SetUp() {
|
||||
}
|
||||
auto reduction_axes_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape(shape_axes), axes);
|
||||
|
||||
const auto reduce = ngraph::builder::makeReduce(param, reduction_axes_node, keep_dims, reduction_type);
|
||||
const auto reduce = ov::test::utils::make_reduce(param, reduction_axes_node, keep_dims, reduction_type);
|
||||
function = std::make_shared<ov::Model>(reduce->outputs(), ov::ParameterVector{param}, "Reduce");
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,9 @@
|
||||
#include "transformations/control_flow/unroll_tensor_iterator.hpp"
|
||||
#include "shared_test_classes/single_op/tensor_iterator.hpp"
|
||||
#include "openvino/pass/manager.hpp"
|
||||
#include "ov_models/builders.hpp"
|
||||
#include "common_test_utils/node_builders/lstm_cell.hpp"
|
||||
#include "common_test_utils/node_builders/gru_cell.hpp"
|
||||
#include "common_test_utils/node_builders/rnn_cell.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -106,7 +108,7 @@ void TensorIteratorTest::SetUp() {
|
||||
auto squeeze = std::make_shared<ov::op::v0::Squeeze>(body_params[0], axis);
|
||||
std::vector<ov::Shape> WRB = {input_shapes[3], input_shapes[4], input_shapes[5]};
|
||||
ov::OutputVector out_vector = {squeeze, body_params[1], body_params[2]};
|
||||
auto lstm_cell = ngraph::builder::makeLSTM(out_vector, WRB, hidden_size, {"sigmoid", "tanh", "tanh"}, {}, {}, clip);
|
||||
auto lstm_cell = ov::test::utils::make_lstm(out_vector, WRB, hidden_size, {"sigmoid", "tanh", "tanh"}, {}, {}, clip);
|
||||
auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(lstm_cell->output(0), axis);
|
||||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(unsqueeze),
|
||||
std::make_shared<ov::op::v0::Result>(lstm_cell->output(0)),
|
||||
@ -155,7 +157,7 @@ void TensorIteratorTest::SetUp() {
|
||||
std::vector<ov::Shape> WRB = {input_shapes[2], input_shapes[3], input_shapes[4]};
|
||||
auto squeeze = std::make_shared<ov::op::v0::Squeeze>(body_params[0], axis);
|
||||
ov::OutputVector out_vector = {squeeze, body_params[1]};
|
||||
auto gru_cell = ngraph::builder::makeGRU(out_vector, WRB, hidden_size, {"sigmoid", "tanh"},
|
||||
auto gru_cell = ov::test::utils::make_gru(out_vector, WRB, hidden_size, {"sigmoid", "tanh"},
|
||||
{}, {}, clip, false);
|
||||
auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(gru_cell->output(0), axis);
|
||||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(gru_cell->output(0)),
|
||||
@ -202,7 +204,7 @@ void TensorIteratorTest::SetUp() {
|
||||
std::vector<ov::Shape> WRB = {input_shapes[2], input_shapes[3], input_shapes[4]};
|
||||
auto squeeze = std::make_shared<ov::op::v0::Squeeze>(body_params[0], axis);
|
||||
ov::OutputVector out_vector = {squeeze, body_params[1]};
|
||||
auto rnn_cell = ngraph::builder::makeRNN(out_vector, WRB, hidden_size, {"tanh"}, {}, {}, clip);
|
||||
auto rnn_cell = ov::test::utils::make_rnn(out_vector, WRB, hidden_size, {"tanh"}, {}, {}, clip);
|
||||
auto unsqueeze = std::make_shared<ov::op::v0::Unsqueeze>(rnn_cell->output(0), axis);
|
||||
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(rnn_cell),
|
||||
std::make_shared<ov::op::v0::Result>(unsqueeze)};
|
||||
|
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_augru(
|
||||
const OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
bool make_sequence = false,
|
||||
ov::op::RecurrentSequenceDirection direction = ov::op::RecurrentSequenceDirection::FORWARD,
|
||||
ov::test::utils::SequenceTestsMode mode = ov::test::utils::SequenceTestsMode::PURE_SEQ);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_comparison(const ov::Output<Node>& in0,
|
||||
const ov::Output<Node>& in1,
|
||||
ov::test::utils::ComparisonTypes comparison_type);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_dft(const ov::Output<Node>& data_node,
|
||||
const std::vector<int64_t>& axes,
|
||||
const std::vector<int64_t>& signal_size,
|
||||
const ov::test::utils::DFTOpType op_type);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,20 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_fully_connected(const ov::Output<Node>& in,
|
||||
const ov::element::Type& type,
|
||||
const size_t output_size,
|
||||
bool addBias = true,
|
||||
const ov::Shape& weights_shape = {},
|
||||
const std::vector<float>& weights = {},
|
||||
const std::vector<float>& bias_weights = {});
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,21 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_gather_nd(const ov::Output<Node>& data_node,
|
||||
const ov::Shape& indices_shape,
|
||||
const ov::element::Type& indices_type,
|
||||
const std::size_t batch_dims);
|
||||
|
||||
std::shared_ptr<ov::Node> make_gather_nd8(const ov::Output<Node>& data_node,
|
||||
const ov::Shape& indices_shape,
|
||||
const ov::element::Type& indices_type,
|
||||
const std::size_t batch_dims);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_gru(
|
||||
const OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
const std::vector<std::string>& activations = std::vector<std::string>{"sigmoid", "tanh"},
|
||||
const std::vector<float>& activations_alpha = {},
|
||||
const std::vector<float>& activations_beta = {},
|
||||
float clip = 0.f,
|
||||
bool linear_before_reset = false,
|
||||
bool make_sequence = false,
|
||||
ov::op::RecurrentSequenceDirection direction = ov::op::RecurrentSequenceDirection::FORWARD,
|
||||
ov::test::utils::SequenceTestsMode mode = ov::test::utils::SequenceTestsMode::PURE_SEQ);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,16 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_logical(const ov::Output<Node>& in0,
|
||||
const ov::Output<Node>& in1,
|
||||
ov::test::utils::LogicalTypes logical_type);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_lstm(
|
||||
const ov::OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
const std::vector<std::string>& activations = std::vector<std::string>{"sigmoid", "tanh", "tanh"},
|
||||
const std::vector<float>& activations_alpha = {},
|
||||
const std::vector<float>& activations_beta = {},
|
||||
float clip = 0.f,
|
||||
bool make_sequence = false,
|
||||
ov::op::RecurrentSequenceDirection direction = ov::op::RecurrentSequenceDirection::FORWARD,
|
||||
ov::test::utils::SequenceTestsMode mode = ov::test::utils::SequenceTestsMode::PURE_SEQ,
|
||||
float WRB_range = 0.f);
|
||||
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_rdft(const ov::Output<Node>& data_node,
|
||||
const std::vector<int64_t>& axes,
|
||||
const std::vector<int64_t>& signal_size,
|
||||
const ov::test::utils::DFTOpType op_type);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_reduce(const ov::Output<Node>& data,
|
||||
const ov::Output<Node>& axes,
|
||||
bool keep_dims,
|
||||
ov::test::utils::ReductionType reduction_type);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/test_enums.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_rnn(
|
||||
const OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
const std::vector<std::string>& activations = std::vector<std::string>{"tanh"},
|
||||
const std::vector<float>& activations_alpha = {},
|
||||
const std::vector<float>& activations_beta = {},
|
||||
float clip = 0.f,
|
||||
bool make_sequence = false,
|
||||
ov::op::RecurrentSequenceDirection direction = ov::op::RecurrentSequenceDirection::FORWARD,
|
||||
ov::test::utils::SequenceTestsMode mode = ov::test::utils::SequenceTestsMode::PURE_SEQ);
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,89 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/augru_cell.hpp"
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "ov_ops/augru_cell.hpp"
|
||||
#include "ov_ops/augru_sequence.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
/**
|
||||
* There are 2 options to paramter "in" when "make_sequence" is true.
|
||||
* 0 1 2 3
|
||||
* X init_hidden_state attention seq_length
|
||||
* or,
|
||||
* 0 1 2
|
||||
* X init_hidden_state attention
|
||||
*
|
||||
*/
|
||||
std::shared_ptr<ov::Node> make_augru(const OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
bool make_sequence,
|
||||
ov::op::RecurrentSequenceDirection direction,
|
||||
ov::test::utils::SequenceTestsMode mode) {
|
||||
auto w_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[0]);
|
||||
auto W = std::make_shared<ov::op::v0::Constant>(w_tensor);
|
||||
W->set_friendly_name("augru_w");
|
||||
auto r_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[1]);
|
||||
auto R = std::make_shared<ov::op::v0::Constant>(r_tensor);
|
||||
R->set_friendly_name("augru_r");
|
||||
auto b_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[2]);
|
||||
auto B = std::make_shared<ov::op::v0::Constant>(b_tensor);
|
||||
B->set_friendly_name("augru_b");
|
||||
|
||||
if (!make_sequence) {
|
||||
return std::make_shared<ov::op::internal::AUGRUCell>(in[0], in[1], W, R, B, in[2], hidden_size);
|
||||
} else {
|
||||
if (in.size() > 3 && in[3].get_partial_shape().is_dynamic()) {
|
||||
return std::make_shared<ov::op::internal::AUGRUSequence>(in[0], in[1], in[3], W, R, B, in[2], hidden_size);
|
||||
} else {
|
||||
std::shared_ptr<Node> seq_lengths;
|
||||
switch (mode) {
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: {
|
||||
std::vector<float> lengths(in[0].get_partial_shape()[0].get_min_length(),
|
||||
in[0].get_partial_shape()[1].get_min_length());
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(element::i64, constants[3], lengths);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST: {
|
||||
auto seq_lengths_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(ov::element::i64,
|
||||
constants[3],
|
||||
static_cast<float>(in[0].get_shape()[1]),
|
||||
0);
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(seq_lengths_tensor);
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM: {
|
||||
// Seq_lengths should be as a Parameter node for these two modes
|
||||
if (in.size() < 4)
|
||||
throw std::runtime_error("Incorrect number of inputs for creation of Sequence operation");
|
||||
seq_lengths = in.at(3).get_node_shared_ptr();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error("Incorrect mode for creation of Sequence operation");
|
||||
}
|
||||
return std::make_shared<ov::op::internal::AUGRUSequence>(in[0],
|
||||
in[1],
|
||||
seq_lengths,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
in[2],
|
||||
hidden_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/comparison.hpp"
|
||||
|
||||
#include "openvino/op/equal.hpp"
|
||||
#include "openvino/op/greater.hpp"
|
||||
#include "openvino/op/greater_eq.hpp"
|
||||
#include "openvino/op/is_finite.hpp"
|
||||
#include "openvino/op/is_inf.hpp"
|
||||
#include "openvino/op/is_nan.hpp"
|
||||
#include "openvino/op/less.hpp"
|
||||
#include "openvino/op/less_eq.hpp"
|
||||
#include "openvino/op/not_equal.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_comparison(const ov::Output<Node>& in0,
|
||||
const ov::Output<Node>& in1,
|
||||
ov::test::utils::ComparisonTypes comparison_type) {
|
||||
switch (comparison_type) {
|
||||
case ov::test::utils::ComparisonTypes::EQUAL:
|
||||
return std::make_shared<ov::op::v1::Equal>(in0, in1);
|
||||
case ov::test::utils::ComparisonTypes::NOT_EQUAL:
|
||||
return std::make_shared<ov::op::v1::NotEqual>(in0, in1);
|
||||
case ov::test::utils::ComparisonTypes::GREATER:
|
||||
return std::make_shared<ov::op::v1::Greater>(in0, in1);
|
||||
case ov::test::utils::ComparisonTypes::GREATER_EQUAL:
|
||||
return std::make_shared<ov::op::v1::GreaterEqual>(in0, in1);
|
||||
case ov::test::utils::ComparisonTypes::IS_FINITE:
|
||||
return std::make_shared<ov::op::v10::IsFinite>(in0);
|
||||
case ov::test::utils::ComparisonTypes::IS_INF:
|
||||
return std::make_shared<ov::op::v10::IsInf>(in0);
|
||||
case ov::test::utils::ComparisonTypes::IS_NAN:
|
||||
return std::make_shared<ov::op::v10::IsNaN>(in0);
|
||||
case ov::test::utils::ComparisonTypes::LESS:
|
||||
return std::make_shared<ov::op::v1::Less>(in0, in1);
|
||||
case ov::test::utils::ComparisonTypes::LESS_EQUAL:
|
||||
return std::make_shared<ov::op::v1::LessEqual>(in0, in1);
|
||||
default: {
|
||||
throw std::runtime_error("Incorrect type of Comparison operation");
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/dft.hpp"
|
||||
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/dft.hpp"
|
||||
#include "openvino/op/idft.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
namespace {
|
||||
template <typename... Args>
|
||||
std::shared_ptr<ov::Node> CallDftCtorWithArgs(const ov::test::utils::DFTOpType op_type, Args&&... args) {
|
||||
switch (op_type) {
|
||||
case ov::test::utils::DFTOpType::FORWARD:
|
||||
return std::make_shared<ov::op::v7::DFT>(std::forward<Args>(args)...);
|
||||
case ov::test::utils::DFTOpType::INVERSE:
|
||||
return std::make_shared<ov::op::v7::IDFT>(std::forward<Args>(args)...);
|
||||
default:
|
||||
throw std::logic_error("Unsupported operation type");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<ov::Node> make_dft(const ov::Output<Node>& data_node,
|
||||
const std::vector<int64_t>& axes,
|
||||
const std::vector<int64_t>& signal_size,
|
||||
const ov::test::utils::DFTOpType op_type) {
|
||||
auto axesNode = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::i64, ov::Shape{axes.size()}, axes);
|
||||
|
||||
if (!signal_size.empty()) {
|
||||
auto signal_size_node = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::i64,
|
||||
ov::Shape{signal_size.size()},
|
||||
signal_size);
|
||||
return CallDftCtorWithArgs(op_type, data_node, axesNode, signal_size_node);
|
||||
}
|
||||
return CallDftCtorWithArgs(op_type, data_node, axesNode);
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,57 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/fully_connected.hpp"
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "openvino/op/add.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/matmul.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_fully_connected(const ov::Output<Node>& in,
|
||||
const ov::element::Type& type,
|
||||
const size_t output_size,
|
||||
bool addBias,
|
||||
const ov::Shape& weights_shape,
|
||||
const std::vector<float>& weights,
|
||||
const std::vector<float>& bias_weights) {
|
||||
auto shape = weights_shape;
|
||||
if (shape.empty()) {
|
||||
auto input_shape = in.get_shape();
|
||||
shape = {input_shape[1], output_size};
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::op::v0::Constant> weights_node;
|
||||
if (weights.empty()) {
|
||||
auto tensor = ov::test::utils::create_and_fill_tensor(type, shape);
|
||||
weights_node = std::make_shared<ov::op::v0::Constant>(tensor);
|
||||
} else {
|
||||
weights_node = std::make_shared<ov::op::v0::Constant>(type, shape, weights);
|
||||
}
|
||||
|
||||
auto fc = std::make_shared<ov::op::v0::MatMul>(in, weights_node, false, false);
|
||||
fc->set_friendly_name("FullyConnected");
|
||||
|
||||
if (addBias) {
|
||||
std::shared_ptr<ov::op::v0::Constant> bias_weights_node;
|
||||
if (bias_weights.empty()) {
|
||||
auto tensor = ov::test::utils::create_and_fill_tensor(type, ov::Shape{});
|
||||
bias_weights_node = std::make_shared<ov::op::v0::Constant>(tensor);
|
||||
} else {
|
||||
bias_weights_node = std::make_shared<ov::op::v0::Constant>(type, ov::Shape{}, bias_weights);
|
||||
}
|
||||
|
||||
auto add = std::make_shared<ov::op::v1::Add>(fc, bias_weights_node);
|
||||
|
||||
return add;
|
||||
} else {
|
||||
return fc;
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,77 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/gather_nd.hpp"
|
||||
|
||||
#include "common_test_utils/data_utils.hpp"
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/gather_nd.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_gather_nd(const ov::Output<Node>& data_node,
|
||||
const ov::Shape& indices_shape,
|
||||
const ov::element::Type& indices_type,
|
||||
const std::size_t batch_dims) {
|
||||
const auto indices = [&] {
|
||||
const auto& data_shape = data_node.get_shape();
|
||||
const auto indices_count =
|
||||
std::accumulate(begin(indices_shape), prev(end(indices_shape)), 1ull, std::multiplies<std::size_t>{});
|
||||
|
||||
const auto slice_rank = indices_shape.back();
|
||||
|
||||
const auto max_dim = *std::max_element(begin(data_shape), end(data_shape));
|
||||
|
||||
std::vector<int> indices_values(indices_count * slice_rank);
|
||||
ov::test::utils::fill_data_random(indices_values.data(), indices_count * slice_rank, max_dim, 0);
|
||||
auto indices_data = indices_values.data();
|
||||
for (int i = 0; i < indices_count; i++) {
|
||||
for (int dim = 0; dim < slice_rank; dim++) {
|
||||
indices_data[0] = indices_data[0] % data_shape[dim + batch_dims];
|
||||
indices_data++;
|
||||
}
|
||||
}
|
||||
return op::v0::Constant::create(indices_type, indices_shape, indices_values);
|
||||
}();
|
||||
|
||||
auto gather_nd_node = std::make_shared<ov::op::v5::GatherND>(data_node, indices, batch_dims);
|
||||
gather_nd_node->set_friendly_name("GatherND");
|
||||
|
||||
return gather_nd_node;
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Node> make_gather_nd8(const ov::Output<Node>& data_node,
|
||||
const ov::Shape& indices_shape,
|
||||
const ov::element::Type& indices_type,
|
||||
const std::size_t batch_dims) {
|
||||
const auto indices = [&] {
|
||||
const auto& data_shape = data_node.get_shape();
|
||||
const auto indices_count =
|
||||
std::accumulate(begin(indices_shape), prev(end(indices_shape)), 1ull, std::multiplies<std::size_t>{});
|
||||
const auto slice_rank = indices_shape.back();
|
||||
|
||||
const auto max_dim = *std::max_element(begin(data_shape), end(data_shape));
|
||||
|
||||
std::vector<int> indices_values(indices_count * slice_rank);
|
||||
ov::test::utils::fill_data_random(indices_values.data(), indices_count * slice_rank, max_dim, 0);
|
||||
auto indices_data = indices_values.data();
|
||||
for (int i = 0; i < indices_count; i++) {
|
||||
for (int dim = 0; dim < slice_rank; dim++) {
|
||||
indices_data[0] = indices_data[0] % data_shape[dim + batch_dims];
|
||||
indices_data++;
|
||||
}
|
||||
}
|
||||
return op::v0::Constant::create(indices_type, indices_shape, indices_values);
|
||||
}();
|
||||
|
||||
auto gather_nd_node = std::make_shared<ov::op::v8::GatherND>(data_node, indices, batch_dims);
|
||||
gather_nd_node->set_friendly_name("GatherND");
|
||||
|
||||
return gather_nd_node;
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,108 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/gru_cell.hpp"
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/gru_cell.hpp"
|
||||
#include "openvino/op/gru_sequence.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_gru(const OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
const std::vector<std::string>& activations,
|
||||
const std::vector<float>& activations_alpha,
|
||||
const std::vector<float>& activations_beta,
|
||||
float clip,
|
||||
bool linear_before_reset,
|
||||
bool make_sequence,
|
||||
ov::op::RecurrentSequenceDirection direction,
|
||||
ov::test::utils::SequenceTestsMode mode) {
|
||||
auto w_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[0]);
|
||||
auto W = std::make_shared<ov::op::v0::Constant>(w_tensor);
|
||||
auto r_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[1]);
|
||||
auto R = std::make_shared<ov::op::v0::Constant>(r_tensor);
|
||||
auto b_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[2]);
|
||||
auto B = std::make_shared<ov::op::v0::Constant>(b_tensor);
|
||||
|
||||
if (!make_sequence) {
|
||||
return std::make_shared<ov::op::v3::GRUCell>(in[0],
|
||||
in[1],
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip,
|
||||
linear_before_reset);
|
||||
} else {
|
||||
if (in.size() > 2 && in[2].get_partial_shape().is_dynamic()) {
|
||||
return std::make_shared<ov::op::v5::GRUSequence>(in[0],
|
||||
in[1],
|
||||
in[2],
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
direction,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip,
|
||||
linear_before_reset);
|
||||
} else {
|
||||
std::shared_ptr<ov::Node> seq_lengths;
|
||||
switch (mode) {
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: {
|
||||
std::vector<float> lengths(in[0].get_partial_shape()[0].get_min_length(),
|
||||
in[0].get_partial_shape()[1].get_min_length());
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(element::i64, constants[3], lengths);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST: {
|
||||
auto seq_lengths_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(ov::element::i64,
|
||||
constants[3],
|
||||
static_cast<float>(in[0].get_shape()[1]),
|
||||
0);
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(seq_lengths_tensor);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM: {
|
||||
// Seq_lengths should be as a Parameter node for these two modes
|
||||
seq_lengths = in.at(2).get_node_shared_ptr();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error("Incorrect mode for creation of Sequence operation");
|
||||
}
|
||||
return std::make_shared<ov::op::v5::GRUSequence>(in[0],
|
||||
in[1],
|
||||
seq_lengths,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
direction,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip,
|
||||
linear_before_reset);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,34 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/logical.hpp"
|
||||
|
||||
#include "openvino/op/logical_and.hpp"
|
||||
#include "openvino/op/logical_not.hpp"
|
||||
#include "openvino/op/logical_or.hpp"
|
||||
#include "openvino/op/logical_xor.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_logical(const ov::Output<Node>& in0,
|
||||
const ov::Output<Node>& in1,
|
||||
ov::test::utils::LogicalTypes logical_type) {
|
||||
switch (logical_type) {
|
||||
case ov::test::utils::LogicalTypes::LOGICAL_AND:
|
||||
return std::make_shared<ov::op::v1::LogicalAnd>(in0, in1);
|
||||
case ov::test::utils::LogicalTypes::LOGICAL_OR:
|
||||
return std::make_shared<ov::op::v1::LogicalOr>(in0, in1);
|
||||
case ov::test::utils::LogicalTypes::LOGICAL_NOT:
|
||||
return std::make_shared<ov::op::v1::LogicalNot>(in0);
|
||||
case ov::test::utils::LogicalTypes::LOGICAL_XOR:
|
||||
return std::make_shared<ov::op::v1::LogicalXor>(in0, in1);
|
||||
default: {
|
||||
OPENVINO_THROW("Incorrect type of Logical operation");
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,119 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/lstm_cell.hpp"
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/lstm_cell.hpp"
|
||||
#include "openvino/op/lstm_sequence.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_lstm(const std::vector<ov::Output<Node>>& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
const std::vector<std::string>& activations,
|
||||
const std::vector<float>& activations_alpha,
|
||||
const std::vector<float>& activations_beta,
|
||||
float clip,
|
||||
bool make_sequence,
|
||||
ov::op::RecurrentSequenceDirection direction,
|
||||
ov::test::utils::SequenceTestsMode mode,
|
||||
float WRB_range) {
|
||||
auto w_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[0]);
|
||||
auto W = std::make_shared<ov::op::v0::Constant>(w_tensor);
|
||||
auto r_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[1]);
|
||||
auto R = std::make_shared<ov::op::v0::Constant>(r_tensor);
|
||||
auto b_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[2]);
|
||||
auto B = std::make_shared<ov::op::v0::Constant>(b_tensor);
|
||||
|
||||
if (WRB_range > 0) {
|
||||
w_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[0], 2 * WRB_range, -WRB_range);
|
||||
W = std::make_shared<ov::op::v0::Constant>(w_tensor);
|
||||
r_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[1], 2 * WRB_range, -WRB_range);
|
||||
R = std::make_shared<ov::op::v0::Constant>(r_tensor);
|
||||
b_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[2], 2 * WRB_range, -WRB_range);
|
||||
B = std::make_shared<ov::op::v0::Constant>(b_tensor);
|
||||
}
|
||||
if (!make_sequence) {
|
||||
return std::make_shared<ov::op::v4::LSTMCell>(in[0],
|
||||
in[1],
|
||||
in[2],
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip);
|
||||
} else {
|
||||
if (in.size() > 3 && in[3].get_partial_shape().is_dynamic()) {
|
||||
return std::make_shared<ov::op::v5::LSTMSequence>(in[0],
|
||||
in[1],
|
||||
in[2],
|
||||
in[3],
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
direction,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
activations,
|
||||
clip);
|
||||
} else {
|
||||
std::shared_ptr<Node> seq_lengths;
|
||||
switch (mode) {
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: {
|
||||
std::vector<float> lengths(in[0].get_partial_shape()[0].get_min_length(),
|
||||
in[0].get_partial_shape()[1].get_min_length());
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(element::i64, constants[3], lengths);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST: {
|
||||
auto seq_lengths_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(ov::element::i64,
|
||||
constants[3],
|
||||
static_cast<float>(in[0].get_shape()[1]),
|
||||
0);
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(seq_lengths_tensor);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM: {
|
||||
// Seq_lengths should be as a Parameter node for these two modes
|
||||
seq_lengths = in.at(3).get_node_shared_ptr();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error("Incorrect mode for creation of Sequence operation");
|
||||
}
|
||||
return std::make_shared<ov::op::v5::LSTMSequence>(in[0],
|
||||
in[1],
|
||||
in[2],
|
||||
seq_lengths,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
direction,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
activations,
|
||||
clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/rdft.hpp"
|
||||
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/irdft.hpp"
|
||||
#include "openvino/op/rdft.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
namespace {
|
||||
template <typename... Args>
|
||||
std::shared_ptr<ov::Node> CallRdftCtorWithArgs(const ov::test::utils::DFTOpType op_type, Args&&... args) {
|
||||
switch (op_type) {
|
||||
case ov::test::utils::DFTOpType::FORWARD:
|
||||
return std::make_shared<ov::op::v9::RDFT>(std::forward<Args>(args)...);
|
||||
case ov::test::utils::DFTOpType::INVERSE:
|
||||
return std::make_shared<ov::op::v9::IRDFT>(std::forward<Args>(args)...);
|
||||
default:
|
||||
throw std::logic_error("Unsupported operation type");
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::shared_ptr<ov::Node> make_rdft(const ov::Output<Node>& data_node,
|
||||
const std::vector<int64_t>& axes,
|
||||
const std::vector<int64_t>& signal_size,
|
||||
const ov::test::utils::DFTOpType op_type) {
|
||||
auto axesNode = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::i64, ov::Shape{axes.size()}, axes);
|
||||
|
||||
if (!signal_size.empty()) {
|
||||
auto signal_size_node = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::i64,
|
||||
ov::Shape{signal_size.size()},
|
||||
signal_size);
|
||||
return CallRdftCtorWithArgs(op_type, data_node, axesNode, signal_size_node);
|
||||
}
|
||||
return CallRdftCtorWithArgs(op_type, data_node, axesNode);
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/reduce.hpp"
|
||||
|
||||
#include "openvino/op/reduce_l1.hpp"
|
||||
#include "openvino/op/reduce_l2.hpp"
|
||||
#include "openvino/op/reduce_logical_and.hpp"
|
||||
#include "openvino/op/reduce_logical_or.hpp"
|
||||
#include "openvino/op/reduce_max.hpp"
|
||||
#include "openvino/op/reduce_mean.hpp"
|
||||
#include "openvino/op/reduce_min.hpp"
|
||||
#include "openvino/op/reduce_prod.hpp"
|
||||
#include "openvino/op/reduce_sum.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
std::shared_ptr<ov::Node> make_reduce(const ov::Output<Node>& data,
|
||||
const ov::Output<Node>& axes,
|
||||
bool keep_dims,
|
||||
ov::test::utils::ReductionType reduction_type) {
|
||||
switch (reduction_type) {
|
||||
case ov::test::utils::Mean:
|
||||
return std::make_shared<ov::op::v1::ReduceMean>(data, axes, keep_dims);
|
||||
case ov::test::utils::Max:
|
||||
return std::make_shared<ov::op::v1::ReduceMax>(data, axes, keep_dims);
|
||||
case ov::test::utils::Min:
|
||||
return std::make_shared<ov::op::v1::ReduceMin>(data, axes, keep_dims);
|
||||
case ov::test::utils::Prod:
|
||||
return std::make_shared<ov::op::v1::ReduceProd>(data, axes, keep_dims);
|
||||
case ov::test::utils::Sum:
|
||||
return std::make_shared<ov::op::v1::ReduceSum>(data, axes, keep_dims);
|
||||
case ov::test::utils::LogicalOr:
|
||||
return std::make_shared<ov::op::v1::ReduceLogicalOr>(data, axes, keep_dims);
|
||||
case ov::test::utils::LogicalAnd:
|
||||
return std::make_shared<ov::op::v1::ReduceLogicalAnd>(data, axes, keep_dims);
|
||||
case ov::test::utils::L1:
|
||||
return std::make_shared<ov::op::v4::ReduceL1>(data, axes, keep_dims);
|
||||
case ov::test::utils::L2:
|
||||
return std::make_shared<ov::op::v4::ReduceL2>(data, axes, keep_dims);
|
||||
default:
|
||||
OPENVINO_THROW("Can't create layer for this reduction type");
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,105 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/node_builders/rnn_cell.hpp"
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "openvino/op/rnn_cell.hpp"
|
||||
#include "openvino/op/rnn_sequence.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace utils {
|
||||
|
||||
std::shared_ptr<ov::Node> make_rnn(const OutputVector& in,
|
||||
const std::vector<ov::Shape>& constants,
|
||||
std::size_t hidden_size,
|
||||
const std::vector<std::string>& activations,
|
||||
const std::vector<float>& activations_alpha,
|
||||
const std::vector<float>& activations_beta,
|
||||
float clip,
|
||||
bool make_sequence,
|
||||
ov::op::RecurrentSequenceDirection direction,
|
||||
ov::test::utils::SequenceTestsMode mode) {
|
||||
auto w_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[0]);
|
||||
auto W = std::make_shared<ov::op::v0::Constant>(w_tensor);
|
||||
auto r_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[1]);
|
||||
auto R = std::make_shared<ov::op::v0::Constant>(r_tensor);
|
||||
auto b_tensor = ov::test::utils::create_and_fill_tensor(in[0].get_element_type(), constants[2]);
|
||||
auto B = std::make_shared<ov::op::v0::Constant>(b_tensor);
|
||||
|
||||
if (!make_sequence) {
|
||||
return std::make_shared<ov::op::v0::RNNCell>(in[0],
|
||||
in[1],
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip);
|
||||
} else {
|
||||
if (in.size() > 2 && in[2].get_partial_shape().is_dynamic()) {
|
||||
return std::make_shared<ov::op::v5::RNNSequence>(in[0],
|
||||
in[1],
|
||||
in[2],
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
direction,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip);
|
||||
} else {
|
||||
std::shared_ptr<Node> seq_lengths;
|
||||
switch (mode) {
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST: {
|
||||
std::vector<float> lengths(in[0].get_partial_shape()[0].get_min_length(),
|
||||
in[0].get_partial_shape()[1].get_min_length());
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(element::i64, constants[3], lengths);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST: {
|
||||
auto seq_lengths_tensor =
|
||||
ov::test::utils::create_and_fill_tensor(ov::element::i64,
|
||||
constants[3],
|
||||
static_cast<float>(in[0].get_shape()[1]),
|
||||
0);
|
||||
seq_lengths = std::make_shared<ov::op::v0::Constant>(seq_lengths_tensor);
|
||||
break;
|
||||
}
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM:
|
||||
case ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM: {
|
||||
// Seq_lengths should be as a Parameter node for these two modes
|
||||
seq_lengths = in.at(2).get_node_shared_ptr();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw std::runtime_error("Incorrect mode for creation of Sequence operation");
|
||||
}
|
||||
return std::make_shared<ov::op::v5::RNNSequence>(in[0],
|
||||
in[1],
|
||||
seq_lengths,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
hidden_size,
|
||||
direction,
|
||||
activations,
|
||||
activations_alpha,
|
||||
activations_beta,
|
||||
clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace ov
|
Loading…
Reference in New Issue
Block a user