-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add single layer test for FakeConvert
- Loading branch information
1 parent
39041c8
commit cd1b9a9
Showing
5 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/fake_convert.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "single_op_tests/fake_convert.hpp" | ||
|
||
namespace { | ||
using ov::test::FakeConvertLayerTest; | ||
|
||
const std::vector<std::vector<ov::Shape>> shapes = {{{2, 3, 4, 5}}}; | ||
|
||
const std::vector<ov::element::Type> data_precisions = {ov::element::f32, ov::element::f16, ov::element::bf16}; | ||
|
||
const std::vector<ov::element::Type> destination_precisions = {ov::element::f8e4m3, ov::element::f8e5m2}; | ||
|
||
const std::vector<bool> default_shift = {true, false}; | ||
|
||
const auto simple_fake_convert_params = | ||
::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes)), | ||
::testing::Values(ov::Shape{1}), | ||
::testing::Values(ov::Shape{1}), | ||
::testing::ValuesIn(data_precisions), | ||
::testing::ValuesIn(destination_precisions), | ||
::testing::ValuesIn(default_shift), | ||
::testing::Values(ov::test::utils::DEVICE_CPU)); | ||
|
||
const auto broadcast_fake_convert_params = | ||
::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes)), | ||
::testing::Values(ov::Shape{2, 3, 1, 1}), | ||
::testing::Values(ov::Shape{2, 3, 1, 1}), | ||
::testing::ValuesIn(data_precisions), | ||
::testing::ValuesIn(destination_precisions), | ||
::testing::ValuesIn(default_shift), | ||
::testing::Values(ov::test::utils::DEVICE_CPU)); | ||
|
||
const auto elementwise_fake_convert_params = | ||
::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes)), | ||
::testing::Values(ov::Shape{2, 3, 4, 5}), | ||
::testing::Values(ov::Shape{2, 3, 4, 5}), | ||
::testing::ValuesIn(data_precisions), | ||
::testing::ValuesIn(destination_precisions), | ||
::testing::ValuesIn(default_shift), | ||
::testing::Values(ov::test::utils::DEVICE_CPU)); | ||
|
||
INSTANTIATE_TEST_SUITE_P(smoke_FakeConvert_simple, | ||
FakeConvertLayerTest, | ||
simple_fake_convert_params, | ||
FakeConvertLayerTest::getTestCaseName); | ||
|
||
INSTANTIATE_TEST_SUITE_P(smoke_FakeConvert_broadcast, | ||
FakeConvertLayerTest, | ||
broadcast_fake_convert_params, | ||
FakeConvertLayerTest::getTestCaseName); | ||
|
||
INSTANTIATE_TEST_SUITE_P(smoke_FakeConvert_elementwise, | ||
FakeConvertLayerTest, | ||
elementwise_fake_convert_params, | ||
FakeConvertLayerTest::getTestCaseName); | ||
} // namespace |
16 changes: 16 additions & 0 deletions
16
src/tests/functional/plugin/shared/include/single_op_tests/fake_convert.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/single_op/fake_convert.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
|
||
TEST_P(FakeConvertLayerTest, Inference) { | ||
run(); | ||
} | ||
} // namespace test | ||
} // namespace ov |
28 changes: 28 additions & 0 deletions
28
...sts/functional/shared_test_classes/include/shared_test_classes/single_op/fake_convert.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/base/ov_subgraph.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
using FakeConvertParams = std::tuple<std::vector<InputShape>, // Data shape | ||
Shape, // Scale shape | ||
Shape, // Shift shape | ||
ov::element::Type, // Input precision | ||
ov::element::Type, // Ddestination precision | ||
bool, // Default shift | ||
std::string>; // Device name | ||
|
||
class FakeConvertLayerTest : public testing::WithParamInterface<FakeConvertParams>, | ||
virtual public ov::test::SubgraphBaseTest { | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<FakeConvertParams>& obj); | ||
|
||
protected: | ||
void SetUp() override; | ||
}; | ||
} // namespace test | ||
} // namespace ov |
64 changes: 64 additions & 0 deletions
64
src/tests/functional/shared_test_classes/src/single_op/fake_convert.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "shared_test_classes/single_op/fake_convert.hpp" | ||
|
||
#include "openvino/opsets/opset1.hpp" | ||
#include "openvino/opsets/opset13.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
std::string FakeConvertLayerTest::getTestCaseName(const testing::TestParamInfo<FakeConvertParams>& obj) { | ||
FakeConvertParams params = obj.param; | ||
|
||
std::vector<InputShape> data_shapes; | ||
Shape scale_shape, shift_shape; | ||
element::Type_t data_prec, dst_prec; | ||
bool default_shift; | ||
std::string target_device; | ||
std::tie(data_shapes, scale_shape, shift_shape, data_prec, dst_prec, default_shift, target_device) = params; | ||
|
||
std::ostringstream result; | ||
result << "IS=("; | ||
for (const auto& shape : data_shapes) { | ||
result << ov::test::utils::partialShape2str({shape.first}) << "_"; | ||
} | ||
result << ")_TS=("; | ||
for (const auto& shape : data_shapes) { | ||
for (const auto& item : shape.second) { | ||
result << ov::test::utils::vec2str(item) << "_"; | ||
} | ||
} | ||
result << ")_scaleShape=" << ov::test::utils::vec2str(scale_shape) << "_"; | ||
result << "shiftShape=" << ov::test::utils::vec2str(shift_shape) << "_"; | ||
result << "dataPrecision=" << element::Type(data_prec) << "_"; | ||
result << "destinationPrecision=" << element::Type(dst_prec) << "_"; | ||
if (default_shift) | ||
result << "defaultShift=true"; | ||
else | ||
result << "defaultShift=false"; | ||
return result.str(); | ||
} | ||
|
||
void FakeConvertLayerTest::SetUp() { | ||
FakeConvertParams params = this->GetParam(); | ||
|
||
std::vector<InputShape> data_shapes; | ||
Shape scale_shape, shift_shape; | ||
element::Type_t data_prec, dst_prec; | ||
bool default_shift; | ||
std::tie(data_shapes, scale_shape, shift_shape, data_prec, dst_prec, default_shift, targetDevice) = params; | ||
|
||
init_input_shapes(data_shapes); | ||
|
||
const auto data = std::make_shared<opset1::Parameter>(data_prec, inputDynamicShapes.front()); | ||
const auto scale = std::make_shared<opset1::Constant>(data_prec, scale_shape); | ||
const auto shift = std::make_shared<opset1::Constant>(data_prec, shift_shape); | ||
|
||
const auto fake_convert = default_shift ? std::make_shared<opset13::FakeConvert>(data, scale, dst_prec) | ||
: std::make_shared<opset13::FakeConvert>(data, scale, shift, dst_prec); | ||
function = std::make_shared<ov::Model>(NodeVector{fake_convert}, ParameterVector{data}); | ||
} | ||
} // namespace test | ||
} // namespace ov |