Migrate Sequence (CTCGreedyDecoder-1, CTCGreedyDecoderSeqLen-6, GRUCell-3, LSTMCell-4, OneHot-1, RNNCell-1) and Sort (ExperimentalDetectronTopKROIs-6) (#8314)
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/ctc_greedy_decoder.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct CTCGreedyDecoderParams {
|
||||
CTCGreedyDecoderParams(
|
||||
const Tensor& dataTensor, const Tensor& masksTensor, int64_t ctcMergedRepeat,
|
||||
const Tensor& expectedTensor, const std::string& testcaseName = "") :
|
||||
dataTensor(dataTensor), masksTensor(masksTensor), ctcMergedRepeat(ctcMergedRepeat),
|
||||
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
|
||||
|
||||
Tensor dataTensor;
|
||||
Tensor masksTensor;
|
||||
bool ctcMergedRepeat;
|
||||
Tensor expectedTensor;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceCTCGreedyDecoderTest : public testing::TestWithParam<CTCGreedyDecoderParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.dataTensor.data, params.masksTensor.data};
|
||||
refOutData = {params.expectedTensor.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<CTCGreedyDecoderParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "dType=" << param.dataTensor.type;
|
||||
result << "_dShape=" << param.dataTensor.shape;
|
||||
result << "_aType=" << param.masksTensor.type;
|
||||
result << "_aShape=" << param.masksTensor.shape;
|
||||
result << "_bDims=" << param.ctcMergedRepeat;
|
||||
result << "_eType=" << param.expectedTensor.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const CTCGreedyDecoderParams& params) {
|
||||
std::shared_ptr<Function> function;
|
||||
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
|
||||
const auto indices = std::make_shared<op::v0::Parameter>(params.masksTensor.type, params.masksTensor.shape);
|
||||
const auto decoder = std::make_shared<op::v0::CTCGreedyDecoder>(data, indices, params.ctcMergedRepeat);
|
||||
function = std::make_shared<ov::Function>(NodeVector{decoder}, ParameterVector{data, indices});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceCTCGreedyDecoderTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t IN_ET>
|
||||
std::vector<CTCGreedyDecoderParams> generateParams() {
|
||||
using T = typename element_type_traits<IN_ET>::value_type;
|
||||
std::vector<CTCGreedyDecoderParams> params {
|
||||
CTCGreedyDecoderParams(
|
||||
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
|
||||
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
|
||||
false,
|
||||
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, 1.0f}),
|
||||
"ctc_greedy_decoder"),
|
||||
CTCGreedyDecoderParams(
|
||||
Tensor(IN_ET, {3, 2, 3}, std::vector<T>{
|
||||
0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f, 0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f}),
|
||||
Tensor(IN_ET, {3, 2}, std::vector<T>{1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}),
|
||||
false,
|
||||
Tensor(IN_ET, {2, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f}),
|
||||
"ctc_greedy_decoder_multiple_batches"),
|
||||
CTCGreedyDecoderParams(
|
||||
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
|
||||
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 0.0f}),
|
||||
false,
|
||||
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, -1.0f}),
|
||||
"ctc_greedy_decoder_single_batch_short_sequence"),
|
||||
CTCGreedyDecoderParams(
|
||||
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
|
||||
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
|
||||
true,
|
||||
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 0.0f, -1.0f}),
|
||||
"ctc_greedy_decoder_merge"),
|
||||
CTCGreedyDecoderParams(
|
||||
Tensor(IN_ET, {3, 1, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.3f, 0.4f, 0.f, 0.6f, 0.5f, 0.f}),
|
||||
Tensor(IN_ET, {3, 1}, std::vector<T>{1.0f, 1.0f, 1.0f}),
|
||||
false,
|
||||
Tensor(IN_ET, {1, 3, 1, 1}, std::vector<T>{1.0f, 1.0f, 0.0f}),
|
||||
"ctc_greedy_decoder_single_no_merge"),
|
||||
CTCGreedyDecoderParams(
|
||||
Tensor(IN_ET, {2, 2, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f, 0.7f, 0.8f, 0.f}),
|
||||
Tensor(IN_ET, {2, 2}, std::vector<T>{1.0f, 1.0f, 1.0f, 0.0f}),
|
||||
false,
|
||||
Tensor(IN_ET, {2, 2, 1, 1}, std::vector<T>{1.0f, 1.0f, 0.0f, -1.0f}),
|
||||
"ctc_greedy_decoder_multiple_sequences"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<CTCGreedyDecoderParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<CTCGreedyDecoderParams>> generatedParams {
|
||||
generateParams<element::Type_t::bf16>(),
|
||||
generateParams<element::Type_t::f16>(),
|
||||
generateParams<element::Type_t::f32>(),
|
||||
generateParams<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<CTCGreedyDecoderParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoder_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceCTCGreedyDecoderTest::getTestCaseName);
|
||||
} // namespace
|
||||
@@ -0,0 +1,228 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/ctc_greedy_decoder_seq_len.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct CTCGreedyDecoderSeqLenParams {
|
||||
CTCGreedyDecoderSeqLenParams(
|
||||
const Tensor& dataTensor, const Tensor& seqLenTensor, const Tensor& blankIndexTensor, int64_t mergeRepeated,
|
||||
const Tensor& expectedTensor, const Tensor& expectedTensor2, const std::string& testcaseName = "") :
|
||||
dataTensor(dataTensor), seqLenTensor(seqLenTensor), blankIndexTensor(blankIndexTensor), mergeRepeated(mergeRepeated),
|
||||
expectedTensor(expectedTensor), expectedTensor2(expectedTensor2), testcaseName(testcaseName) {}
|
||||
|
||||
Tensor dataTensor;
|
||||
Tensor seqLenTensor;
|
||||
Tensor blankIndexTensor;
|
||||
bool mergeRepeated;
|
||||
Tensor expectedTensor;
|
||||
Tensor expectedTensor2;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
struct CTCGreedyDecoderSeqLenParamsNoOptionalInput {
|
||||
CTCGreedyDecoderSeqLenParamsNoOptionalInput(
|
||||
const Tensor& dataTensor, const Tensor& seqLenTensor, int64_t mergeRepeated,
|
||||
const Tensor& expectedTensor, const Tensor& expectedTensor2, const std::string& testcaseName = "") :
|
||||
dataTensor(dataTensor), seqLenTensor(seqLenTensor), mergeRepeated(mergeRepeated),
|
||||
expectedTensor(expectedTensor), expectedTensor2(expectedTensor2), testcaseName(testcaseName) {}
|
||||
|
||||
Tensor dataTensor;
|
||||
Tensor seqLenTensor;
|
||||
bool mergeRepeated;
|
||||
Tensor expectedTensor;
|
||||
Tensor expectedTensor2;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceCTCGreedyDecoderSeqLenTest : public testing::TestWithParam<CTCGreedyDecoderSeqLenParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.dataTensor.data, params.seqLenTensor.data};
|
||||
refOutData = {params.expectedTensor.data, params.expectedTensor2.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<CTCGreedyDecoderSeqLenParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "dType=" << param.dataTensor.type;
|
||||
result << "_dShape=" << param.dataTensor.shape;
|
||||
result << "_sType=" << param.seqLenTensor.type;
|
||||
result << "_sShape=" << param.seqLenTensor.shape;
|
||||
result << "_bType=" << param.blankIndexTensor.type;
|
||||
result << "_bShape=" << param.blankIndexTensor.shape;
|
||||
result << "_mRepeated=" << param.mergeRepeated;
|
||||
result << "_eType=" << param.expectedTensor.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const CTCGreedyDecoderSeqLenParams& params) {
|
||||
std::shared_ptr<Function> function;
|
||||
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
|
||||
const auto seq_len = std::make_shared<op::v0::Parameter>(params.seqLenTensor.type, params.seqLenTensor.shape);
|
||||
auto blank_index = std::make_shared<op::v0::Constant>(params.blankIndexTensor.type, params.blankIndexTensor.shape,
|
||||
params.blankIndexTensor.data.data());
|
||||
const auto decoder = std::make_shared<op::v6::CTCGreedyDecoderSeqLen>(data, seq_len, blank_index, params.mergeRepeated);
|
||||
function = std::make_shared<ov::Function>(decoder->outputs(), ParameterVector{data, seq_len});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput :
|
||||
public testing::TestWithParam<CTCGreedyDecoderSeqLenParamsNoOptionalInput>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.dataTensor.data, params.seqLenTensor.data};
|
||||
refOutData = {params.expectedTensor.data, params.expectedTensor2.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<CTCGreedyDecoderSeqLenParamsNoOptionalInput>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "dType=" << param.dataTensor.type;
|
||||
result << "_dShape=" << param.dataTensor.shape;
|
||||
result << "_sType=" << param.seqLenTensor.type;
|
||||
result << "_sShape=" << param.seqLenTensor.shape;
|
||||
result << "_mRepeated=" << param.mergeRepeated;
|
||||
result << "_eType=" << param.expectedTensor.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const CTCGreedyDecoderSeqLenParamsNoOptionalInput& params) {
|
||||
std::shared_ptr<Function> function;
|
||||
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
|
||||
const auto seq_len = std::make_shared<op::v0::Parameter>(params.seqLenTensor.type, params.seqLenTensor.shape);
|
||||
const auto decoder = std::make_shared<op::v6::CTCGreedyDecoderSeqLen>(data, seq_len, params.mergeRepeated);
|
||||
function = std::make_shared<ov::Function>(decoder->outputs(), ParameterVector{data, seq_len});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceCTCGreedyDecoderSeqLenTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<CTCGreedyDecoderSeqLenParams> generateParams() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<CTCGreedyDecoderSeqLenParams> params {
|
||||
CTCGreedyDecoderSeqLenParams(
|
||||
Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
|
||||
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
|
||||
Tensor(element::i32, {}, std::vector<int32_t>{2}),
|
||||
false,
|
||||
Tensor(element::i32, {1, 3}, std::vector<int32_t>{1, 0, -1}),
|
||||
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
|
||||
"evaluate_ctc_greedy_decoder_seq_len"),
|
||||
CTCGreedyDecoderSeqLenParams(
|
||||
Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
|
||||
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
|
||||
Tensor(element::i32, {}, std::vector<int32_t>{2}),
|
||||
true,
|
||||
Tensor(element::i32, {1, 3}, std::vector<int32_t>{1, 0, -1}),
|
||||
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
|
||||
"evaluate_ctc_greedy_decoder_seq_len_merge"),
|
||||
CTCGreedyDecoderSeqLenParams(
|
||||
Tensor(ET, {2, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f,
|
||||
0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f}),
|
||||
Tensor(element::i32, {2}, std::vector<int32_t>{1, 1}),
|
||||
Tensor(element::i32, {}, std::vector<int32_t>{2}),
|
||||
false,
|
||||
Tensor(element::i32, {2, 3}, std::vector<int32_t>{1, -1, -1, 0, -1, -1}),
|
||||
Tensor(element::i32, {2}, std::vector<int32_t>{1, 1}),
|
||||
"evaluate_ctc_greedy_decoder_seq_len_multiple_batches"),
|
||||
CTCGreedyDecoderSeqLenParams(
|
||||
Tensor(ET, {3, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f,
|
||||
0.45f, 0.35f, 0.f, 0.5f, 0.6f, 0.f, 0.55f, 0.65f, 0.f,
|
||||
0.1f, 0.2f, 0.f, 0.15f, 0.25f, 0.f, 0.4f, 0.3f, 0.f}),
|
||||
Tensor(element::i32, {3}, std::vector<int32_t>{2, 3, 1}),
|
||||
Tensor(element::i32, {}, std::vector<int32_t>{2}),
|
||||
false,
|
||||
Tensor(element::i32, {3, 3}, std::vector<int32_t>{1, 1, -1, 0, 1, 1, 1, -1, -1}),
|
||||
Tensor(element::i32, {3}, std::vector<int32_t>{2, 3, 1}),
|
||||
"evaluate_ctc_greedy_decoder_seq_len_multiple_batches2"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<CTCGreedyDecoderSeqLenParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<CTCGreedyDecoderSeqLenParams>> generatedParams {
|
||||
generateParams<element::Type_t::bf16>(),
|
||||
generateParams<element::Type_t::f16>(),
|
||||
generateParams<element::Type_t::f32>(),
|
||||
generateParams<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<CTCGreedyDecoderSeqLenParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateParamsNoOptionalInput() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> params {
|
||||
CTCGreedyDecoderSeqLenParamsNoOptionalInput(
|
||||
Tensor(ET, {1, 3, 3}, std::vector<T>{0.1f, 0.2f, 0.f, 0.4f, 0.3f, 0.f, 0.5f, 0.6f, 0.f}),
|
||||
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
|
||||
false,
|
||||
Tensor(element::i32, {1, 3}, std::vector<int32_t>{1, 0, -1}),
|
||||
Tensor(element::i32, {1}, std::vector<int32_t>{2}),
|
||||
"evaluate_ctc_greedy_decoder_seq_len_no_optional_input"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> generateCombinedParamsNoOptionalInput() {
|
||||
const std::vector<std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput>> generatedParams {
|
||||
generateParamsNoOptionalInput<element::Type_t::bf16>(),
|
||||
generateParamsNoOptionalInput<element::Type_t::f16>(),
|
||||
generateParamsNoOptionalInput<element::Type_t::f32>(),
|
||||
generateParamsNoOptionalInput<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<CTCGreedyDecoderSeqLenParamsNoOptionalInput> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderSeqLenTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceCTCGreedyDecoderSeqLenTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_CTCGreedyDecoderSeqLen_With_Hardcoded_Refs, ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput,
|
||||
testing::ValuesIn(generateCombinedParamsNoOptionalInput()), ReferenceCTCGreedyDecoderSeqLenTestNoOptionalInput::getTestCaseName);
|
||||
} // namespace
|
||||
@@ -0,0 +1,108 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/experimental_detectron_topkrois.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct ExperimentalDetectronTopKROIsParams {
|
||||
ExperimentalDetectronTopKROIsParams(
|
||||
const Tensor& dataTensor, const Tensor& probsTensor, const int32_t numRois,
|
||||
const Tensor& expectedTensor, const std::string& testcaseName = "") :
|
||||
dataTensor(dataTensor), probsTensor(probsTensor), numRois(numRois),
|
||||
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
|
||||
|
||||
Tensor dataTensor;
|
||||
Tensor probsTensor;
|
||||
int32_t numRois;
|
||||
Tensor expectedTensor;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceExperimentalDetectronTopKROIsTest : public testing::TestWithParam<ExperimentalDetectronTopKROIsParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.dataTensor.data, params.probsTensor.data};
|
||||
refOutData = {params.expectedTensor.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronTopKROIsParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "dType=" << param.dataTensor.type;
|
||||
result << "_dShape=" << param.dataTensor.shape;
|
||||
result << "_pType=" << param.probsTensor.type;
|
||||
result << "_pShape=" << param.probsTensor.shape;
|
||||
result << "_numRois=" << param.numRois;
|
||||
result << "_eType=" << param.expectedTensor.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const ExperimentalDetectronTopKROIsParams& params) {
|
||||
std::shared_ptr<Function> function;
|
||||
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
|
||||
const auto probs = std::make_shared<op::v0::Parameter>(params.probsTensor.type, params.probsTensor.shape);
|
||||
const auto topkRois = std::make_shared<op::v6::ExperimentalDetectronTopKROIs>(data, probs, params.numRois);
|
||||
function = std::make_shared<ov::Function>(topkRois, ParameterVector{data, probs});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceExperimentalDetectronTopKROIsTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<ExperimentalDetectronTopKROIsParams> generateParams() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<ExperimentalDetectronTopKROIsParams> params {
|
||||
ExperimentalDetectronTopKROIsParams(
|
||||
Tensor(ET, {2, 4}, std::vector<T>{1.0f, 1.0f, 3.0f, 4.0f, 2.0f, 1.0f, 5.0f, 7.0f}),
|
||||
Tensor(ET, {2}, std::vector<T>{0.5f, 0.3f}),
|
||||
1,
|
||||
Tensor(ET, {1, 4}, std::vector<T>{1.0, 1.0, 3.0, 4.0}),
|
||||
"experimental_detectron_topk_rois_eval"),
|
||||
ExperimentalDetectronTopKROIsParams(
|
||||
Tensor(ET, {4, 4}, std::vector<T>{1.0f, 1.0f, 4.0f, 5.0f, 3.0f, 2.0f, 7.0f, 9.0f,
|
||||
10.0f, 15.0f, 13.0f, 17.0f, 13.0f, 10.0f, 18.0f, 15.0f}),
|
||||
Tensor(ET, {4}, std::vector<T>{0.1f, 0.7f, 0.5f, 0.9f}),
|
||||
2,
|
||||
Tensor(ET, {2, 4}, std::vector<T>{13.0f, 10.0f, 18.0f, 15.0f, 3.0f, 2.0f, 7.0f, 9.0f}),
|
||||
"experimental_detectron_topk_rois_eval"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<ExperimentalDetectronTopKROIsParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<ExperimentalDetectronTopKROIsParams>> generatedParams {
|
||||
generateParams<element::Type_t::bf16>(),
|
||||
generateParams<element::Type_t::f16>(),
|
||||
generateParams<element::Type_t::f32>(),
|
||||
generateParams<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<ExperimentalDetectronTopKROIsParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronTopKROIs_With_Hardcoded_Refs, ReferenceExperimentalDetectronTopKROIsTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceExperimentalDetectronTopKROIsTest::getTestCaseName);
|
||||
} // namespace
|
||||
294
docs/template_plugin/tests/functional/op_reference/gru_cell.cpp
Normal file
294
docs/template_plugin/tests/functional/op_reference/gru_cell.cpp
Normal file
@@ -0,0 +1,294 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/gru_cell.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct GRUCellParams {
|
||||
GRUCellParams(
|
||||
const int32_t batchSize, const int32_t inputSize, const int32_t hiddenSize, const int32_t gatesCount, const bool linearBeforeReset,
|
||||
const Tensor& X, const Tensor& H_t, const Tensor& W, const Tensor& R, const Tensor& B,
|
||||
const Tensor& Ho, const std::string& testcaseName = "") :
|
||||
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize), gatesCount(gatesCount), linearBeforeReset(linearBeforeReset),
|
||||
X(X), H_t(H_t), W(W), R(R), B(B), Ho(Ho), testcaseName(testcaseName) {}
|
||||
|
||||
int32_t batchSize;
|
||||
int32_t inputSize;
|
||||
int32_t hiddenSize;
|
||||
int32_t gatesCount;
|
||||
bool linearBeforeReset;
|
||||
Tensor X;
|
||||
Tensor H_t;
|
||||
Tensor W;
|
||||
Tensor R;
|
||||
Tensor B;
|
||||
Tensor Ho;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceGRUCellTest : public testing::TestWithParam<GRUCellParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<GRUCellParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "bSize=" << param.batchSize;
|
||||
result << "_iSize=" << param.inputSize;
|
||||
result << "_hSize=" << param.hiddenSize;
|
||||
result << "_gCount=" << param.gatesCount;
|
||||
result << "_lbReset=" << param.linearBeforeReset;
|
||||
result << "_xType=" << param.X.type;
|
||||
result << "_xShape=" << param.X.shape;
|
||||
result << "_htType=" << param.H_t.type;
|
||||
result << "_htShape=" << param.H_t.shape;
|
||||
result << "_wType=" << param.W.type;
|
||||
result << "_wShape=" << param.W.shape;
|
||||
result << "_rType=" << param.R.type;
|
||||
result << "_rShape=" << param.R.shape;
|
||||
result << "_hoType=" << param.Ho.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_hoShape=" << param.Ho.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_hoShape=" << param.Ho.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const GRUCellParams& params) {
|
||||
float clip = 2.88f;
|
||||
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto gru_cell = std::make_shared<op::v3::GRUCell>(X,
|
||||
H_t,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
params.hiddenSize,
|
||||
std::vector<std::string>{"sigmoid", "tanh"},
|
||||
std::vector<float>{},
|
||||
std::vector<float>{},
|
||||
clip,
|
||||
params.linearBeforeReset);
|
||||
|
||||
auto function = std::make_shared<Function>(NodeVector{gru_cell}, ParameterVector{X, H_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
// Hard Sigmoid activation function is unsupprted with v3::GRUCell
|
||||
class ReferenceGRUCellTestHardsigmoidActivationFunction : public ReferenceGRUCellTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
threshold = 1e-1f;
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data};
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const GRUCellParams& params) {
|
||||
float clip = 2.88f;
|
||||
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto gru_cell = std::make_shared<op::v3::GRUCell>(X,
|
||||
H_t,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
params.hiddenSize,
|
||||
std::vector<std::string>{"hardsigmoid", "hardsigmoid"},
|
||||
std::vector<float>{1.8345f, 1.8345f},
|
||||
std::vector<float>{3.05f, 3.05f},
|
||||
clip,
|
||||
params.linearBeforeReset);
|
||||
|
||||
auto function = std::make_shared<Function>(NodeVector{gru_cell}, ParameterVector{X, H_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceGRUCellTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceGRUCellTestHardsigmoidActivationFunction, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<GRUCellParams> generateParams() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<GRUCellParams> params {
|
||||
GRUCellParams(
|
||||
2, 3, 3, 3, false,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.52421564f, 0.78845507f, 0.9372873f, 0.59783894f, 0.18278378f, 0.2084126f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.45738035f, 0.996877f, 0.82882977f, 0.47492632f, 0.88471466f, 0.57833236f}),
|
||||
Tensor(ET, {3 * 3, 3}, std::vector<T>{
|
||||
0.5815369f, 0.16559383f, 0.08464007f, 0.843122f, 0.73968244f, 0.11359601f,
|
||||
0.8295078f, 0.9240567f, 0.10007995f, 0.20573162f, 0.09002485f, 0.2839569f,
|
||||
0.3096991f, 0.5638341f, 0.5787327f, 0.84552664f, 0.16263747f, 0.7243242f,
|
||||
0.8049057f, 0.43966424f, 0.46294412f, 0.9833361f, 0.31369713f, 0.1719934f,
|
||||
0.4937093f, 0.6353004f, 0.77982515f}),
|
||||
Tensor(ET, {3 * 3, 3}, std::vector<T>{
|
||||
0.16510165f, 0.52435565f, 0.2788478f, 0.99427545f, 0.1623331f, 0.01389796f,
|
||||
0.99669236f, 0.53901845f, 0.8737506f, 0.9254788f, 0.21172932f, 0.11634306f,
|
||||
0.40111724f, 0.37497616f, 0.2903471f, 0.6796794f, 0.65131867f, 0.78163475f,
|
||||
0.12058706f, 0.45591718f, 0.791677f, 0.76497287f, 0.9895242f, 0.7845312f,
|
||||
0.51267904f, 0.49030215f, 0.08498167f}),
|
||||
Tensor(ET, {3 * 3}, std::vector<T>{
|
||||
0.8286678f + 0.9175602f,
|
||||
0.9153158f + 0.14958014f,
|
||||
0.9581612f + 0.49230585f,
|
||||
0.6639213f + 0.63162816f,
|
||||
0.84239805f + 0.4161903f,
|
||||
0.5282445f + 0.22148274f,
|
||||
0.14153397f + 0.50496656f,
|
||||
0.22404431f + 0.34798595f,
|
||||
0.6549655f + 0.6699164f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.48588726f, 0.99670005f, 0.83759373f, 0.5023099f, 0.89410484f, 0.60011315f}),
|
||||
"gru_cell_bias_clip"),
|
||||
GRUCellParams(
|
||||
2, 3, 3, 3, true,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
|
||||
Tensor(ET, {3 * 3, 3}, std::vector<T>{
|
||||
0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f, 0.6964006f, 0.33459795f,
|
||||
0.5468904f, 0.85646594f, 0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
|
||||
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f, 0.85542053f, 0.29660386f,
|
||||
0.49717373f, 0.7473479f, 0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
|
||||
0.07514781f, 0.5865731f, 0.76409274f}),
|
||||
Tensor(ET, {3 * 3, 3}, std::vector<T>{
|
||||
0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f, 0.04471736f, 0.03888785f,
|
||||
0.06308217f, 0.44844428f, 0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
|
||||
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f, 0.4613444f, 0.10999731f,
|
||||
0.78273284f, 0.21453214f, 0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
|
||||
0.19263928f, 0.10979804f, 0.52575564f}),
|
||||
Tensor(ET, {(3 + 1) * 3}, std::vector<T>{
|
||||
0.61395123f, // 0.09875853f + 0.5151927f,
|
||||
1.08667738f, // 0.37801138f + 0.708666f,
|
||||
1.32600244f, // 0.7729636f + 0.55303884f,
|
||||
0.81917698f, // 0.78493553f + 0.03424145f,
|
||||
1.37736335f, // 0.5662702f + 0.81109315f,
|
||||
0.42931147f, // 0.12406381f + 0.30524766f,
|
||||
0.66729516f,
|
||||
0.7752771f,
|
||||
0.78819966f,
|
||||
0.6606634f,
|
||||
0.99040645f,
|
||||
0.21112025f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8709214f, 0.48411977f, 0.74495184f, 0.6074972f, 0.44572943f, 0.1467715f}),
|
||||
"gru_cell_linear_before_reset"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<GRUCellParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<GRUCellParams>> generatedParams {
|
||||
generateParams<element::Type_t::bf16>(),
|
||||
generateParams<element::Type_t::f16>(),
|
||||
generateParams<element::Type_t::f32>(),
|
||||
generateParams<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<GRUCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<GRUCellParams> generateParamsHardsigmoidActivationFunction() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<GRUCellParams> params {
|
||||
GRUCellParams(
|
||||
2, 3, 3, 3, true,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.12249453f, 0.6127907f, 0.5001741f, 0.5124603f, 0.04329684f, 0.023834f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
|
||||
Tensor(ET, {3 * 3, 3}, std::vector<T>{
|
||||
0.72259396f, 0.11561195f, 0.9457856f, 0.19037509f, 0.6964006f, 0.33459795f,
|
||||
0.5468904f, 0.85646594f, 0.5101311f, 0.9712257f, 0.3687071f, 0.60280246f,
|
||||
0.56943774f, 0.7475505f, 0.2490578f, 0.86977345f, 0.85542053f, 0.29660386f,
|
||||
0.49717373f, 0.7473479f, 0.53454477f, 0.15974349f, 0.5804805f, 0.14303213f,
|
||||
0.07514781f, 0.5865731f, 0.76409274f}),
|
||||
Tensor(ET, {3 * 3, 3}, std::vector<T>{
|
||||
0.91382647f, 0.41527033f, 0.28040004f, 0.23601337f, 0.04471736f, 0.03888785f,
|
||||
0.06308217f, 0.44844428f, 0.29384327f, 0.49037653f, 0.50421673f, 0.7366393f,
|
||||
0.63143945f, 0.00277612f, 0.37198433f, 0.06966069f, 0.4613444f, 0.10999731f,
|
||||
0.78273284f, 0.21453214f, 0.10751773f, 0.18332677f, 0.1326976f, 0.9998985f,
|
||||
0.19263928f, 0.10979804f, 0.52575564f}),
|
||||
Tensor(ET, {(3 + 1) * 3}, std::vector<T>{
|
||||
0.09875853f + 0.5151927f,
|
||||
0.37801138f + 0.708666f,
|
||||
0.7729636f + 0.55303884f,
|
||||
0.78493553f + 0.03424145f,
|
||||
0.5662702f + 0.81109315f,
|
||||
0.12406381f + 0.30524766f,
|
||||
0.66729516f,
|
||||
0.7752771f,
|
||||
0.78819966f,
|
||||
0.6606634f,
|
||||
0.99040645f,
|
||||
0.21112025f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8598948f, 0.41189128f, 0.72824323f, 0.53940123f, 0.31485787f, 0.04053852f}),
|
||||
"gru_cell_hardsigmoid_activation_function"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<GRUCellParams> generateCombinedParamsHardsigmoidActivationFunction() {
|
||||
const std::vector<std::vector<GRUCellParams>> generatedParams {
|
||||
generateParamsHardsigmoidActivationFunction<element::Type_t::bf16>(),
|
||||
generateParamsHardsigmoidActivationFunction<element::Type_t::f16>(),
|
||||
generateParamsHardsigmoidActivationFunction<element::Type_t::f32>(),
|
||||
generateParamsHardsigmoidActivationFunction<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<GRUCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs, ReferenceGRUCellTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceGRUCellTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_GRUCell_With_Hardcoded_Refs, ReferenceGRUCellTestHardsigmoidActivationFunction,
|
||||
testing::ValuesIn(generateCombinedParamsHardsigmoidActivationFunction()), ReferenceGRUCellTest::getTestCaseName);
|
||||
} // namespace
|
||||
379
docs/template_plugin/tests/functional/op_reference/lstm_cell.cpp
Normal file
379
docs/template_plugin/tests/functional/op_reference/lstm_cell.cpp
Normal file
@@ -0,0 +1,379 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/lstm_cell.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct LSTMCellParams {
|
||||
LSTMCellParams(
|
||||
int32_t batchSize, int32_t inputSize, int32_t hiddenSize, int32_t gatesCount,
|
||||
const Tensor& X, const Tensor& W, const Tensor& R, const Tensor& H_t, const Tensor& C_t, const Tensor& B,
|
||||
const Tensor& Ho, const Tensor& Co, const std::string& testcaseName = "") :
|
||||
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize), gatesCount(gatesCount),
|
||||
X(X), W(W), R(R), H_t(H_t), C_t(C_t), B(B), Ho(Ho), Co(Co), testcaseName(testcaseName) {}
|
||||
|
||||
int32_t batchSize;
|
||||
int32_t inputSize;
|
||||
int32_t hiddenSize;
|
||||
int32_t gatesCount;
|
||||
Tensor X;
|
||||
Tensor W;
|
||||
Tensor R;
|
||||
Tensor H_t;
|
||||
Tensor C_t;
|
||||
Tensor B;
|
||||
Tensor Ho;
|
||||
Tensor Co;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceLSTMCellTest : public testing::TestWithParam<LSTMCellParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data, params.Co.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<LSTMCellParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "bSize=" << param.batchSize;
|
||||
result << "_iSize=" << param.inputSize;
|
||||
result << "_hSize=" << param.hiddenSize;
|
||||
result << "_gCount=" << param.gatesCount;
|
||||
result << "_xType=" << param.X.type;
|
||||
result << "_xShape=" << param.X.shape;
|
||||
result << "_wType=" << param.W.type;
|
||||
result << "_wShape=" << param.W.shape;
|
||||
result << "_rType=" << param.R.type;
|
||||
result << "_rShape=" << param.R.shape;
|
||||
result << "_htType=" << param.H_t.type;
|
||||
result << "_htShape=" << param.H_t.shape;
|
||||
result << "_ctType=" << param.C_t.type;
|
||||
result << "_ctShape=" << param.C_t.shape;
|
||||
result << "_hoType=" << param.Ho.type;
|
||||
result << "_hoShape=" << param.Ho.shape;
|
||||
result << "_coType=" << param.Co.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_coShape=" << param.Co.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_coShape=" << param.Co.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const LSTMCellParams& params) {
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto C_t = std::make_shared<op::v0::Parameter>(params.C_t.type, params.C_t.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto lstm_cell =
|
||||
std::make_shared<op::v4::LSTMCell>(X,
|
||||
H_t,
|
||||
C_t,
|
||||
op::util::convert_lstm_node_format(W, op::util::LSTMWeightsFormat::IOFC),
|
||||
op::util::convert_lstm_node_format(R, op::util::LSTMWeightsFormat::IOFC),
|
||||
op::util::convert_lstm_node_format(B, op::util::LSTMWeightsFormat::IOFC),
|
||||
params.hiddenSize);
|
||||
|
||||
auto function = std::make_shared<Function>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceLSTMCellTestBiasDefaultAttrs : public ReferenceLSTMCellTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
threshold = 1e-1f;
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data, params.Co.data};
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const LSTMCellParams& params) {
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto C_t = std::make_shared<op::v0::Parameter>(params.C_t.type, params.C_t.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto lstm_cell =
|
||||
std::make_shared<op::v4::LSTMCell>(X,
|
||||
H_t,
|
||||
C_t,
|
||||
op::util::convert_lstm_node_format(W, op::util::LSTMWeightsFormat::IOFC),
|
||||
op::util::convert_lstm_node_format(R, op::util::LSTMWeightsFormat::IOFC),
|
||||
op::util::convert_lstm_node_format(B, op::util::LSTMWeightsFormat::IOFC),
|
||||
params.hiddenSize);
|
||||
|
||||
auto function = std::make_shared<Function>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceLSTMCellTestBiasClip : public ReferenceLSTMCellTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
threshold = 1e-1f;
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.C_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data, params.Co.data};
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const LSTMCellParams& params) {
|
||||
const float clip_threshold = 3.5f;
|
||||
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto C_t = std::make_shared<op::v0::Parameter>(params.C_t.type, params.C_t.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto lstm_cell =
|
||||
std::make_shared<op::v4::LSTMCell>(X,
|
||||
H_t,
|
||||
C_t,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
params.hiddenSize,
|
||||
std::vector<std::string>{"sigmoid", "tanh", "tanh"},
|
||||
std::vector<float>{},
|
||||
std::vector<float>{},
|
||||
clip_threshold);
|
||||
|
||||
auto function = std::make_shared<Function>(lstm_cell->outputs(), ParameterVector{X, H_t, C_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceLSTMCellTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceLSTMCellTestBiasDefaultAttrs, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceLSTMCellTestBiasClip, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<LSTMCellParams> generateParams() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<LSTMCellParams> params {
|
||||
LSTMCellParams(
|
||||
2, 3, 3, 4,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}),
|
||||
Tensor(ET, {4 * 3, 3}, std::vector<T>{
|
||||
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
|
||||
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
|
||||
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
|
||||
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
|
||||
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
|
||||
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}),
|
||||
Tensor(ET, {4 * 3, 3}, std::vector<T>{
|
||||
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
|
||||
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
|
||||
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
|
||||
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
|
||||
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
|
||||
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}),
|
||||
Tensor(ET, {4 * 3}, std::vector<T>(4 * 3, 0.f)),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{0.81457126f, 0.61109227f, 0.769522f, 0.52239674f, 0.4324641f, 0.63183f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{1.4444952f, 0.9635685f, 1.2875274f, 0.8053419f, 0.7184521f, 0.95803297f}),
|
||||
"lstm_cell_zero_bias_default_attrs"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<LSTMCellParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<LSTMCellParams>> generatedParams {
|
||||
generateParams<element::Type_t::bf16>(),
|
||||
generateParams<element::Type_t::f16>(),
|
||||
generateParams<element::Type_t::f32>(),
|
||||
generateParams<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<LSTMCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<LSTMCellParams> generateParamsBiasDefaultAttrs() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<LSTMCellParams> params {
|
||||
LSTMCellParams(
|
||||
2, 3, 3, 4,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}),
|
||||
Tensor(ET, {4 * 3, 3}, std::vector<T>{
|
||||
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
|
||||
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
|
||||
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
|
||||
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
|
||||
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
|
||||
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}),
|
||||
Tensor(ET, {4 * 3, 3}, std::vector<T>{
|
||||
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
|
||||
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
|
||||
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
|
||||
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
|
||||
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
|
||||
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}),
|
||||
Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
|
||||
1.15248052f,
|
||||
1.16671345f,
|
||||
0.21450312f,
|
||||
1.2380678f,
|
||||
1.51688835f,
|
||||
0.46718366f,
|
||||
0.91810346f,
|
||||
1.1274234f,
|
||||
0.51022074f,
|
||||
1.11389844f,
|
||||
0.74174305f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
|
||||
0.76665538549423218,
|
||||
0.82509011030197144,
|
||||
0.6479143500328064,
|
||||
0.66586339473724365,
|
||||
0.74838578701019287}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
|
||||
1.1150213479995728,
|
||||
1.4578367471694946,
|
||||
1.0649888515472412,
|
||||
0.93761754035949707,
|
||||
1.3659683465957642}),
|
||||
"lstm_cell_bias_default_attrs"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<LSTMCellParams> generateCombinedParamsBiasDefaultAttrs() {
|
||||
const std::vector<std::vector<LSTMCellParams>> generatedParams {
|
||||
generateParamsBiasDefaultAttrs<element::Type_t::bf16>(),
|
||||
generateParamsBiasDefaultAttrs<element::Type_t::f16>(),
|
||||
generateParamsBiasDefaultAttrs<element::Type_t::f32>(),
|
||||
generateParamsBiasDefaultAttrs<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<LSTMCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<LSTMCellParams> generateParamsBiasClip() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<LSTMCellParams> params {
|
||||
LSTMCellParams(
|
||||
2, 3, 3, 4,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.81342685f, 0.84108883f, 0.8152282f, 0.46893653f, 0.0901856f, 0.37088776f}),
|
||||
Tensor(ET, {4 * 3, 3}, std::vector<T>{
|
||||
3.3330739e-01f, 3.6229487e-04f, 4.6773660e-01f, 4.3046016e-01f, 7.3950343e-02f, 3.8063636e-01f,
|
||||
9.6921772e-01f, 9.6897459e-01f, 6.2964785e-01f, 3.1134409e-01f, 8.4709978e-01f, 9.4928098e-01f,
|
||||
6.1676943e-01f, 6.6020679e-01f, 1.9072217e-01f, 8.8032126e-02f, 4.0472135e-01f, 6.8342745e-01f,
|
||||
8.3432144e-01f, 4.4928190e-01f, 7.9524308e-01f, 5.3966165e-01f, 8.5936421e-01f, 8.3136767e-01f,
|
||||
5.5125546e-02f, 4.7791195e-01f, 3.5788772e-01f, 6.7507404e-01f, 2.1716513e-01f, 2.7473119e-01f,
|
||||
3.3999152e-02f, 9.6835363e-01f, 3.7581277e-01f, 2.4026000e-01f, 6.7418844e-01f, 3.4199652e-01f}),
|
||||
Tensor(ET, {4 * 3, 3}, std::vector<T>{
|
||||
0.0987983f, 0.52032113f, 0.5848073f, 0.5356095f, 0.74497133f, 0.73260087f,
|
||||
0.1700787f, 0.45684233f, 0.1495722f, 0.42734373f, 0.4433832f, 0.25906256f,
|
||||
0.03854987f, 0.47480518f, 0.37215272f, 0.99890584f, 0.74019486f, 0.3518967f,
|
||||
0.6881257f, 0.8170279f, 0.54088944f, 0.81225616f, 0.14619833f, 0.42941234f,
|
||||
0.86843914f, 0.45967972f, 0.6237719f, 0.11074839f, 0.6029616f, 0.3149305f,
|
||||
0.46504205f, 0.5843412f, 0.8733427f, 0.7687243f, 0.07074859f, 0.39188156f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.77956f, 0.5331557f, 0.04297554f, 0.7962175f, 0.7635707f, 0.11989366f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.8488452f, 0.18851636f, 0.5020695f, 0.29716516f, 0.06740791f, 0.45384037f}),
|
||||
Tensor(ET, {4 * 3}, std::vector<T>{1.07393714f,
|
||||
1.15248052f,
|
||||
1.16671345f,
|
||||
0.21450312f,
|
||||
1.2380678f,
|
||||
1.51688835f,
|
||||
0.46718366f,
|
||||
0.91810346f,
|
||||
1.1274234f,
|
||||
0.51022074f,
|
||||
1.11389844f,
|
||||
0.74174305f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{0.81014400720596313,
|
||||
0.76665538549423218,
|
||||
0.82387429475784302,
|
||||
0.6479143500328064,
|
||||
0.66586339473724365,
|
||||
0.74838578701019287}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{1.6800162792205811,
|
||||
1.1150213479995728,
|
||||
1.4510968923568726,
|
||||
1.0649888515472412,
|
||||
0.93761754035949707,
|
||||
1.3659683465957642}),
|
||||
"lstm_cell_bias_clip"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<LSTMCellParams> generateCombinedParamsBiasClip() {
|
||||
const std::vector<std::vector<LSTMCellParams>> generatedParams {
|
||||
generateParamsBiasClip<element::Type_t::bf16>(),
|
||||
generateParamsBiasClip<element::Type_t::f16>(),
|
||||
generateParamsBiasClip<element::Type_t::f32>(),
|
||||
generateParamsBiasClip<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<LSTMCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceLSTMCellTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTestBiasDefaultAttrs,
|
||||
testing::ValuesIn(generateCombinedParamsBiasDefaultAttrs()), ReferenceLSTMCellTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_LSTMCell_With_Hardcoded_Refs, ReferenceLSTMCellTestBiasClip,
|
||||
testing::ValuesIn(generateCombinedParamsBiasClip()), ReferenceLSTMCellTest::getTestCaseName);
|
||||
} // namespace
|
||||
226
docs/template_plugin/tests/functional/op_reference/one_hot.cpp
Normal file
226
docs/template_plugin/tests/functional/op_reference/one_hot.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/one_hot.hpp"
|
||||
#include "openvino/op/constant.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct OneHotParams {
|
||||
OneHotParams(
|
||||
const Tensor& dataTensor, const int32_t axis,
|
||||
const Tensor& depthTensor, const Tensor& onValueTensor, const Tensor& offValueTensor,
|
||||
const Tensor& expectedTensor, const std::string& testcaseName = "") :
|
||||
dataTensor(dataTensor), axis(axis),
|
||||
depthTensor(depthTensor), onValueTensor(onValueTensor), offValueTensor(offValueTensor),
|
||||
expectedTensor(expectedTensor), testcaseName(testcaseName) {}
|
||||
|
||||
Tensor dataTensor;
|
||||
int32_t axis;
|
||||
Tensor depthTensor;
|
||||
Tensor onValueTensor;
|
||||
Tensor offValueTensor;
|
||||
Tensor expectedTensor;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceOneHotTest : public testing::TestWithParam<OneHotParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.dataTensor.data};
|
||||
refOutData = {params.expectedTensor.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<OneHotParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "dType=" << param.dataTensor.type;
|
||||
result << "_dShape=" << param.dataTensor.shape;
|
||||
result << "_axis=" << param.axis;
|
||||
result << "_deType=" << param.depthTensor.type;
|
||||
result << "_deShape=" << param.depthTensor.shape;
|
||||
result << "_onType=" << param.onValueTensor.type;
|
||||
result << "_onShape=" << param.onValueTensor.shape;
|
||||
result << "_offType=" << param.offValueTensor.type;
|
||||
result << "_offShape=" << param.offValueTensor.shape;
|
||||
result << "_eType=" << param.expectedTensor.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_eShape=" << param.expectedTensor.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const OneHotParams& params) {
|
||||
std::shared_ptr<Function> function;
|
||||
const auto data = std::make_shared<op::v0::Parameter>(params.dataTensor.type, params.dataTensor.shape);
|
||||
const auto depth = std::make_shared<op::v0::Constant>(params.depthTensor.type, params.depthTensor.shape,
|
||||
params.depthTensor.data.data());
|
||||
const auto onValue = std::make_shared<op::v0::Constant>(params.onValueTensor.type, params.onValueTensor.shape,
|
||||
params.onValueTensor.data.data());
|
||||
const auto offValue = std::make_shared<op::v0::Constant>(params.offValueTensor.type, params.offValueTensor.shape,
|
||||
params.offValueTensor.data.data());
|
||||
const auto oneHot = std::make_shared<op::v1::OneHot>(data, depth, onValue, offValue, params.axis);
|
||||
function = std::make_shared<ov::Function>(oneHot, ParameterVector{data});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceOneHotTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> generateExpectedValues(const Shape& input_shape, std::vector<T> input, uint32_t category_count) {
|
||||
// std::vector<T> input{0, 11, 101, 1001, 10001, static_cast<int32_t>(category_count - 1)};
|
||||
std::vector<T> output(shape_size(input_shape), 0);
|
||||
for (size_t i = 0; i < input.size(); ++i) {
|
||||
output[i * category_count + input[i]] = 1;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
template <element::Type_t ET1, element::Type_t ET2>
|
||||
std::vector<OneHotParams> generateParams() {
|
||||
using T1 = typename element_type_traits<ET1>::value_type;
|
||||
using T2 = typename element_type_traits<ET2>::value_type;
|
||||
std::vector<OneHotParams> params {
|
||||
OneHotParams(
|
||||
Tensor(ET1, {}, std::vector<T1>{2}),
|
||||
0,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {3}, std::vector<T2>{0, 0, 1}),
|
||||
"one_hot_scalar_2_in_3"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {}, std::vector<T1>{1}),
|
||||
0,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {3}, std::vector<T2>{0, 1, 0}),
|
||||
"one_hot_scalar_1_in_3"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {}, std::vector<T1>{0}),
|
||||
0,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {3}, std::vector<T2>{1, 0, 0}),
|
||||
"one_hot_scalar_0_in_3"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {8}, std::vector<T1>{2, 1, 0, 0, 2, 2, 1, 0}),
|
||||
0,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {3, 8}, std::vector<T2>{0, 0, 1, 1, 0, 0, 0, 1,
|
||||
0, 1, 0, 0, 0, 0, 1, 0,
|
||||
1, 0, 0, 0, 1, 1, 0, 0}),
|
||||
"one_hot_vector_0"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {8}, std::vector<T1>{2, 1, 0, 0, 2, 2, 1, 0}),
|
||||
1,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {8, 3}, std::vector<T2>{0, 0, 1, 0, 1, 0, 1, 0,
|
||||
0, 1, 0, 0, 0, 0, 1, 0,
|
||||
0, 1, 0, 1, 0, 1, 0, 0}),
|
||||
"one_hot_vector_1"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {8}, std::vector<T1>{2, 1, 0, 0, 3, 2, 1, 0}),
|
||||
1,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {8, 3}, std::vector<T2>{0, 0, 1, 0, 1, 0, 1, 0,
|
||||
0, 1, 0, 0, 0, 0, 0, 0,
|
||||
0, 1, 0, 1, 0, 1, 0, 0}),
|
||||
"one_hot_vector_1_barely_oob"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {3, 3}, std::vector<T1>{0, 1, 1, 2, 1, 0, 0, 2, 1}),
|
||||
0,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {3, 3, 3}, std::vector<T2>{1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1,
|
||||
0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}),
|
||||
"one_hot_matrix_0"),
|
||||
OneHotParams(
|
||||
Tensor(ET1, {6}, std::vector<T1>{0, 11, 101, 1001, 10001, 19999}),
|
||||
1,
|
||||
Tensor(ET1, {}, std::vector<T1>{20000}),
|
||||
Tensor(ET2, {}, std::vector<T2>{1}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0}),
|
||||
Tensor(ET2, {6, 20000}, generateExpectedValues({6, 20000},
|
||||
std::vector<T2>{0, 11, 101, 1001, 10001, 19999},
|
||||
20000)),
|
||||
"one_hot_vector_many_categories"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
template <element::Type_t ET1, element::Type_t ET2>
|
||||
std::vector<OneHotParams> generateParamsFloat() {
|
||||
using T1 = typename element_type_traits<ET1>::value_type;
|
||||
using T2 = typename element_type_traits<ET2>::value_type;
|
||||
std::vector<OneHotParams> params {
|
||||
OneHotParams(
|
||||
Tensor(ET1, {3, 3}, std::vector<T1>{0, 1, 1, 2, 1, 0, 0, 2, 1}),
|
||||
0,
|
||||
Tensor(ET1, {}, std::vector<T1>{3}),
|
||||
Tensor(ET2, {}, std::vector<T2>{2.5}),
|
||||
Tensor(ET2, {}, std::vector<T2>{0.5}),
|
||||
Tensor(ET2, {3, 3, 3}, std::vector<T2>{
|
||||
2.5, 0.5, 0.5, 0.5, 0.5, 2.5, 2.5, 0.5, 0.5, 0.5, 2.5, 2.5, 0.5, 2.5,
|
||||
0.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 2.5, 0.5, 0.5, 0.5, 2.5, 0.5}),
|
||||
"one_hot_on_off_float"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<OneHotParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<OneHotParams>> generatedParams {
|
||||
generateParams<element::Type_t::i32, element::Type_t::i16>(),
|
||||
generateParams<element::Type_t::i32, element::Type_t::i32>(),
|
||||
generateParams<element::Type_t::i32, element::Type_t::i64>(),
|
||||
generateParams<element::Type_t::i32, element::Type_t::u16>(),
|
||||
generateParams<element::Type_t::i32, element::Type_t::u32>(),
|
||||
generateParams<element::Type_t::i32, element::Type_t::u64>(),
|
||||
generateParams<element::Type_t::i64, element::Type_t::i16>(),
|
||||
generateParams<element::Type_t::i64, element::Type_t::i32>(),
|
||||
generateParams<element::Type_t::i64, element::Type_t::i64>(),
|
||||
generateParams<element::Type_t::i64, element::Type_t::u16>(),
|
||||
generateParams<element::Type_t::i64, element::Type_t::u32>(),
|
||||
generateParams<element::Type_t::i64, element::Type_t::u64>(),
|
||||
generateParamsFloat<element::Type_t::i32, element::Type_t::bf16>(),
|
||||
generateParamsFloat<element::Type_t::i32, element::Type_t::f16>(),
|
||||
generateParamsFloat<element::Type_t::i32, element::Type_t::f32>(),
|
||||
generateParamsFloat<element::Type_t::i32, element::Type_t::f64>(),
|
||||
generateParamsFloat<element::Type_t::i64, element::Type_t::f32>(),
|
||||
generateParamsFloat<element::Type_t::i64, element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<OneHotParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_OneHot_With_Hardcoded_Refs, ReferenceOneHotTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceOneHotTest::getTestCaseName);
|
||||
} // namespace
|
||||
304
docs/template_plugin/tests/functional/op_reference/rnn_cell.cpp
Normal file
304
docs/template_plugin/tests/functional/op_reference/rnn_cell.cpp
Normal file
@@ -0,0 +1,304 @@
|
||||
// Copyright (C) 2021 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "openvino/op/rnn_cell.hpp"
|
||||
#include "base_reference_test.hpp"
|
||||
|
||||
using namespace reference_tests;
|
||||
using namespace ov;
|
||||
|
||||
namespace {
|
||||
struct RNNCellParams {
|
||||
RNNCellParams(
|
||||
int32_t batchSize, int32_t inputSize, int32_t hiddenSize,
|
||||
const Tensor& X, const Tensor& H_t, const Tensor& W, const Tensor& R, const Tensor& B,
|
||||
const Tensor& Ho, const std::string& testcaseName = "") :
|
||||
batchSize(batchSize), inputSize(inputSize), hiddenSize(hiddenSize),
|
||||
X(X), H_t(H_t), W(W), R(R), B(B), Ho(Ho), testcaseName(testcaseName) {}
|
||||
|
||||
int32_t batchSize;
|
||||
int32_t inputSize;
|
||||
int32_t hiddenSize;
|
||||
Tensor X;
|
||||
Tensor H_t;
|
||||
Tensor W;
|
||||
Tensor R;
|
||||
Tensor B;
|
||||
Tensor Ho;
|
||||
std::string testcaseName;
|
||||
};
|
||||
|
||||
class ReferenceRNNCellTest : public testing::TestWithParam<RNNCellParams>, public CommonReferenceTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data};
|
||||
}
|
||||
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<RNNCellParams>& obj) {
|
||||
auto param = obj.param;
|
||||
std::ostringstream result;
|
||||
result << "bSize=" << param.batchSize;
|
||||
result << "_iSize=" << param.inputSize;
|
||||
result << "_hSize=" << param.hiddenSize;
|
||||
result << "_xType=" << param.X.type;
|
||||
result << "_xShape=" << param.X.shape;
|
||||
result << "_htType=" << param.H_t.type;
|
||||
result << "_htShape=" << param.H_t.shape;
|
||||
result << "_wType=" << param.W.type;
|
||||
result << "_wShape=" << param.W.shape;
|
||||
result << "_rType=" << param.R.type;
|
||||
result << "_rShape=" << param.R.shape;
|
||||
result << "_hoType=" << param.Ho.type;
|
||||
if (param.testcaseName != "") {
|
||||
result << "_hoShape=" << param.Ho.shape;
|
||||
result << "_=" << param.testcaseName;
|
||||
} else {
|
||||
result << "_hoShape=" << param.Ho.shape;
|
||||
}
|
||||
return result.str();
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const RNNCellParams& params) {
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto rnn_cell = std::make_shared<op::v0::RNNCell>(X, H_t, W, R, B, params.hiddenSize);
|
||||
auto function = std::make_shared<Function>(NodeVector{rnn_cell}, ParameterVector{X, H_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceRNNCellTestBiasClip : public ReferenceRNNCellTest {
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const RNNCellParams& params) {
|
||||
float clip = 2.88f;
|
||||
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto rnn_cell = std::make_shared<op::v0::RNNCell>(
|
||||
X, H_t, W, R, B, params.hiddenSize,
|
||||
std::vector<std::string>{"tanh"}, std::vector<float>{}, std::vector<float>{}, clip);
|
||||
auto function = std::make_shared<Function>(NodeVector{rnn_cell}, ParameterVector{X, H_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceRNNCellTestSigmoidActivationFunction : public ReferenceRNNCellTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto params = GetParam();
|
||||
function = CreateFunction(params);
|
||||
inputData = {params.X.data, params.H_t.data, params.W.data, params.R.data, params.B.data};
|
||||
refOutData = {params.Ho.data};
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Function> CreateFunction(const RNNCellParams& params) {
|
||||
float clip = 2.88f;
|
||||
|
||||
const auto X = std::make_shared<op::v0::Parameter>(params.X.type, params.X.shape);
|
||||
const auto H_t = std::make_shared<op::v0::Parameter>(params.H_t.type, params.H_t.shape);
|
||||
const auto W = std::make_shared<op::v0::Parameter>(params.W.type, params.W.shape);
|
||||
const auto R = std::make_shared<op::v0::Parameter>(params.R.type, params.R.shape);
|
||||
const auto B = std::make_shared<op::v0::Parameter>(params.B.type, params.B.shape);
|
||||
|
||||
const auto rnn_cell = std::make_shared<op::v0::RNNCell>(X,
|
||||
H_t,
|
||||
W,
|
||||
R,
|
||||
B,
|
||||
params.hiddenSize,
|
||||
std::vector<std::string>{"sigmoid"},
|
||||
std::vector<float>{},
|
||||
std::vector<float>{},
|
||||
clip);
|
||||
auto function = std::make_shared<Function>(NodeVector{rnn_cell}, ParameterVector{X, H_t, W, R, B});
|
||||
return function;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(ReferenceRNNCellTest, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceRNNCellTestBiasClip, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
TEST_P(ReferenceRNNCellTestSigmoidActivationFunction, CompareWithRefs) {
|
||||
Exec();
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<RNNCellParams> generateParams() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<RNNCellParams> params {
|
||||
RNNCellParams(
|
||||
2, 3, 3,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.3432185f, 0.612268f, 0.20272376f, 0.9513413f, 0.30585995f, 0.7265472f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.12444675f, 0.52055854f, 0.46489045f, 0.4983964f, 0.7730452f, 0.28439692f}),
|
||||
Tensor(ET, {3, 3}, std::vector<T>{0.41930267f,
|
||||
0.7872176f,
|
||||
0.89940447f,
|
||||
0.23659843f,
|
||||
0.24676207f,
|
||||
0.17101714f,
|
||||
0.3147149f,
|
||||
0.6555601f,
|
||||
0.4559603f}),
|
||||
Tensor(ET, {3, 3}, std::vector<T>{0.8374871f,
|
||||
0.86660194f,
|
||||
0.82114047f,
|
||||
0.71549815f,
|
||||
0.18775631f,
|
||||
0.3182116f,
|
||||
0.25392973f,
|
||||
0.38301638f,
|
||||
0.85531586f}),
|
||||
Tensor(ET, {3}, std::vector<T>{0.0f, 0.0f, 0.0f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{0.9408395f, 0.53823817f, 0.84270686f, 0.98932856f, 0.768665f, 0.90461975f}),
|
||||
"rnn_cell_zero_bias_default_attrs"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<RNNCellParams> generateCombinedParams() {
|
||||
const std::vector<std::vector<RNNCellParams>> generatedParams {
|
||||
generateParams<element::Type_t::bf16>(),
|
||||
generateParams<element::Type_t::f16>(),
|
||||
generateParams<element::Type_t::f32>(),
|
||||
generateParams<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<RNNCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<RNNCellParams> generateParamsBiasClip() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<RNNCellParams> params {
|
||||
RNNCellParams(
|
||||
2, 3, 3,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.3432185f, 0.612268f, 0.20272376f, 0.9513413f, 0.30585995f, 0.7265472f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.12444675f, 0.52055854f, 0.46489045f, 0.4983964f, 0.7730452f, 0.28439692f}),
|
||||
Tensor(ET, {3, 3}, std::vector<T>{0.41930267f,
|
||||
0.7872176f,
|
||||
0.89940447f,
|
||||
0.23659843f,
|
||||
0.24676207f,
|
||||
0.17101714f,
|
||||
0.3147149f,
|
||||
0.6555601f,
|
||||
0.4559603f}),
|
||||
Tensor(ET, {3, 3}, std::vector<T>{0.8374871f,
|
||||
0.86660194f,
|
||||
0.82114047f,
|
||||
0.71549815f,
|
||||
0.18775631f,
|
||||
0.3182116f,
|
||||
0.25392973f,
|
||||
0.38301638f,
|
||||
0.85531586f}),
|
||||
Tensor(ET, {3}, std::vector<T>{1.0289404f, 1.6362579f, 0.4370661f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{0.9922437f, 0.97749525f, 0.9312212f, 0.9937176f, 0.9901317f, 0.95906746f}),
|
||||
"rnn_cell_bias_clip"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<RNNCellParams> generateCombinedParamsBiasClip() {
|
||||
const std::vector<std::vector<RNNCellParams>> generatedParams {
|
||||
generateParamsBiasClip<element::Type_t::bf16>(),
|
||||
generateParamsBiasClip<element::Type_t::f16>(),
|
||||
generateParamsBiasClip<element::Type_t::f32>(),
|
||||
generateParamsBiasClip<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<RNNCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
template <element::Type_t ET>
|
||||
std::vector<RNNCellParams> generateParamsSigmoidActivationFunction() {
|
||||
using T = typename element_type_traits<ET>::value_type;
|
||||
std::vector<RNNCellParams> params {
|
||||
RNNCellParams(
|
||||
2, 3, 3,
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.3432185f, 0.612268f, 0.20272376f, 0.9513413f, 0.30585995f, 0.7265472f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{
|
||||
0.12444675f, 0.52055854f, 0.46489045f, 0.4983964f, 0.7730452f, 0.28439692f}),
|
||||
Tensor(ET, {3, 3}, std::vector<T>{0.41930267f,
|
||||
0.7872176f,
|
||||
0.89940447f,
|
||||
0.23659843f,
|
||||
0.24676207f,
|
||||
0.17101714f,
|
||||
0.3147149f,
|
||||
0.6555601f,
|
||||
0.4559603f}),
|
||||
Tensor(ET, {3, 3}, std::vector<T>{0.8374871f,
|
||||
0.86660194f,
|
||||
0.82114047f,
|
||||
0.71549815f,
|
||||
0.18775631f,
|
||||
0.3182116f,
|
||||
0.25392973f,
|
||||
0.38301638f,
|
||||
0.85531586f}),
|
||||
Tensor(ET, {3}, std::vector<T>{1.0289404f, 1.6362579f, 0.4370661f}),
|
||||
Tensor(ET, {2, 3}, std::vector<T>{0.94126844f, 0.9036043f, 0.841243f, 0.9468489f, 0.934215f, 0.873708f}),
|
||||
"rnn_cell_sigmoid_activation_function"),
|
||||
};
|
||||
return params;
|
||||
}
|
||||
|
||||
std::vector<RNNCellParams> generateCombinedParamsSigmoidActivationFunction() {
|
||||
const std::vector<std::vector<RNNCellParams>> generatedParams {
|
||||
generateParamsSigmoidActivationFunction<element::Type_t::bf16>(),
|
||||
generateParamsSigmoidActivationFunction<element::Type_t::f16>(),
|
||||
generateParamsSigmoidActivationFunction<element::Type_t::f32>(),
|
||||
generateParamsSigmoidActivationFunction<element::Type_t::f64>(),
|
||||
};
|
||||
std::vector<RNNCellParams> combinedParams;
|
||||
|
||||
for (const auto& params : generatedParams) {
|
||||
combinedParams.insert(combinedParams.end(), params.begin(), params.end());
|
||||
}
|
||||
return combinedParams;
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_RNNCell_With_Hardcoded_Refs, ReferenceRNNCellTest,
|
||||
testing::ValuesIn(generateCombinedParams()), ReferenceRNNCellTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_RNNCell_With_Hardcoded_Refs, ReferenceRNNCellTestBiasClip,
|
||||
testing::ValuesIn(generateCombinedParamsBiasClip()), ReferenceRNNCellTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_RNNCell_With_Hardcoded_Refs, ReferenceRNNCellTestSigmoidActivationFunction,
|
||||
testing::ValuesIn(generateCombinedParamsSigmoidActivationFunction()), ReferenceRNNCellTest::getTestCaseName);
|
||||
} // namespace
|
||||
@@ -86,6 +86,8 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
// CVS-64050
|
||||
R"(.*ReferenceSpaceToBatchLayerTest.*dType=i4.*)",
|
||||
R"(.*ReferenceSpaceToBatchLayerTest.*dType=u4.*)",
|
||||
// CVS-64066
|
||||
R"(.*ReferenceGRUCellTestHardsigmoidActivationFunction.*gru_cell_hardsigmoid_activation_function)",
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
Reference in New Issue
Block a user