Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin tests: check Kernel #12

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,29 @@ const std::vector<LayerTestsDefinitions::ConvolutionTransformationParam> params
{ 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } },
false,
{},
false
false,
"jit[0-9a-z_]*FP32"
},
{
{},
false,
{ 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } },
false
false,
"jit[0-9a-z_]*FP32"
},
{
{ 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } },
false,
{ 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } },
false
false,
"jit[0-9a-z_]*I8"
},
{
{ 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.7f }, { 12.8f } },
true,
{ 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } },
false,
"jit[0-9a-z_]*I8"
},
//{
// { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 1.f }, { 25.5f } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ std::vector<MatMulWithConstantTransformationTestValues> testValues = {
{ 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} },
{ 32, 10 },
std::vector<float>(32 * 10, 1.f),
{ 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }
{ 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} },
"jit[0-9a-z_]*I8"
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ConvolutionTransformationParam {
bool asymmetricQuantizationOnData;
ngraph::builder::subgraph::FakeQuantizeOnWeights fakeQuantizeOnWeights;
bool asymmetricQuantizationOnWeights;
std::string kernel;
};

typedef std::tuple<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MatMulWithConstantTransformationTestValues {
ngraph::Shape weightsConstShape;
std::vector<float> weightsConstValues;
ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights;
std::string kernel;
};

typedef std::tuple<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

Expand Down Expand Up @@ -127,6 +127,10 @@ void ConvolutionTransformation::validateNGraph() {

TEST_P(ConvolutionTransformation, CompareWithRefImpl) {
Run();
if (targetDevice == "CPU") {
std::string kernel = std::get<5>(this->GetParam()).kernel;
checkKernel("Convolution", kernel);
}
};

} // namespace LayerTestsDefinitions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

Expand Down Expand Up @@ -143,6 +143,10 @@ void MatMulWithConstantTransformation::validate() {

TEST_P(MatMulWithConstantTransformation, CompareWithRefImpl) {
Run();
if (targetDevice == "CPU") {
std::string kernel = std::get<3>(this->GetParam()).kernel;
checkKernel("FullyConnected", kernel);
}
};

} // namespace LayerTestsDefinitions
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (C) 2019-2020 Intel Corporation
// Copyright (C) 2019-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include <regex>

#include <transformations/convert_batch_to_space.hpp>
#include <transformations/convert_space_to_batch.hpp>

Expand Down Expand Up @@ -209,6 +211,34 @@ void LayerTestsCommon::Validate() {
Compare(expectedOutputs, actualOutputs);
}

void LayerTestsCommon::checkKernel(std::string layerType, std::string permissibleKernel) {
std::vector<std::string> opNames;
auto perfomanceCounters = inferRequest.GetPerformanceCounts();
for (auto& pc : perfomanceCounters) {
if (pc.second.layer_type == layerType) {
opNames.push_back(pc.first);
}
}
ASSERT_TRUE(!opNames.empty())
<< "layer with type " << layerType << " does not exist";

const std::regex expectedKernel(permissibleKernel);
for (auto& targetOperationName : opNames) {
auto targetOperationKernel = getKernel(targetOperationName);
EXPECT_TRUE(std::regex_search(targetOperationKernel.begin(), targetOperationKernel.end(), expectedKernel))
<< "Unexpected kernel. Actual: \"" << targetOperationKernel << "\" Expected: \"" << permissibleKernel << "\""
<< " (Layer type: " << layerType << ", Layer name: " << targetOperationName << ")";
}
}

std::string LayerTestsCommon::getKernel(std::string layerName) {
auto perfomanceCounters = inferRequest.GetPerformanceCounts();
auto it = perfomanceCounters.find(layerName);

return it->second.exec_type;
}


void LayerTestsCommon::SetRefMode(RefMode mode) {
refMode = mode;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2019-2020 Intel Corporation
// Copyright (C) 2019-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

Expand Down Expand Up @@ -60,6 +60,10 @@ class LayerTestsCommon : public CommonTestUtils::TestsCommon {

virtual void SetRefMode(RefMode mode);

void checkKernel(std::string layerType, std::string permissibleKernel);

std::string getKernel(std::string layerName);

protected:
LayerTestsCommon();

Expand Down