-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[IE TESTS] [CPU] extended cpu specific tests to support int8 precision #6546
[IE TESTS] [CPU] extended cpu specific tests to support int8 precision #6546
Conversation
2c95845
to
a3cffa1
Compare
d85f86f
to
22fa239
Compare
@dmitry-gorokhov could you please review? |
aafeae7
to
1cedb93
Compare
64d613f
to
ae2d28e
Compare
ae2d28e
to
549258b
Compare
1. extended cpu specific tests to support int8 presision 2. added int8 deconvolution fusing tests
549258b
to
8741933
Compare
@maxnick could you review please? |
|
||
ngraph::element::Type outElemType = ngraph::element::f32; | ||
// only for int8 testing | ||
int quantizeInHigh = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name is not very descriptive. Can we change the name so that the meaning become more obvious?
if (outElemType == ngraph::element::u8) { | ||
newLastNode = ngraph::builder::makeFakeQuantize(newLastNode, ngPrc, 256, {1, 1, 1, 1}, {0}, {static_cast<float>(quantizeInHigh)}, {0}, {255}); | ||
} else if (outElemType == ngraph::element::i8) { | ||
newLastNode = ngraph::builder::makeFakeQuantize(newLastNode, ngPrc, 255, {1, 1, 1, 1}, {0}, {static_cast<float>(quantizeInHigh)}, {-127}, {127}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like CPUTestsBase::modifyGraph
is better place for this code. Do we have to place the FQ node after the simple operations chain that we add in fusing tests?
if (outPrc == Precision::U8 || outPrc == Precision::I8) { | ||
threshold = 1.001f; | ||
outElemType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrc); | ||
quantizeInHigh = calculateQuantizeInHigh(kernel, inputShape[1]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a code block that could be extracted to the base class method since it is repeated in every test SetUp()
function that tests a quantized layer. Since we do not have a time to properly refactor CPU single layer tests, we can solve it using some functional stuff. For example we can define a functor pointer in the CPUTestBase
that is called in this extracted code, but is initialized in implementations. If it is not initialized - the method throws. So that we define at least some int8 related stages: changing threshold, outElemType, quantizeInHigh calculation in one common place. Unfortunately this method itself should be called from the SetUp function but it insolate some amount of common code.
if (inPrc == Precision::U8 || inPrc == Precision::I8) { | ||
additionalPasses.push_back(std::make_shared<pass::ConvertPrecision<element::i8, element::f32>>()); | ||
additionalPasses.push_back(std::make_shared<pass::ConvertPrecision<element::u8, element::f32>>()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also a good candidate for method extraction. If we had a time for refactoring we would inherit CPUTestsBase
from LayerTestCommon
then using algorithm pattern we could define some mandatory setUp stages and extract such repeated code blocks to the base class methods.
InferenceEngine::SizeVector kernel, stride, dilation; | ||
std::vector<ptrdiff_t> padBegin, padEnd, outPadding; | ||
size_t convOutChannels; | ||
std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, padType, outPadding) = convParams; | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
auto inElementType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrc); | ||
auto outElementType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that this variable is not used.
::testing::Values(Precision::FP32, Precision::U8, Precision::I8), | ||
::testing::Values(InferenceEngine::Layout::ANY), | ||
::testing::Values(InferenceEngine::Layout::ANY), | ||
::testing::Values(std::vector<size_t >({2, 64, 7, 7})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we testing only channels shape evenly divided by the SIMD vector size, that could hide some problems related to tails processing. Suggest adding more shape variations where input and output channels number is a fraction of blocks number. Please check other new tests instances including other layers.
::testing::Values(Precision::FP32, Precision::U8, Precision::I8), | ||
::testing::Values(Layout::ANY), | ||
::testing::Values(Layout::ANY), | ||
::testing::Values(std::vector<size_t >({ 2, 12, 7, 7, 7 })), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 channels does not form a full vector on avx512 VNNI, m.b. it makes sense to have a shape that contains at least one full SIMD vector and some fractional part to cover more possible code paths? Here in in the other new test instances.
InferenceEngine::SizeVector kernel, stride, dilation; | ||
std::vector<ptrdiff_t> padBegin, padEnd, outputPadding; | ||
size_t convOutChannels, numGroups; | ||
std::tie(kernel, stride, padBegin, padEnd, dilation, convOutChannels, numGroups, padType, outputPadding) = groupConvParams; | ||
auto inElementType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inPrc); | ||
auto outElementType = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(outPrc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that the variable is not used.
@antonvor @dmitry-gorokhov is it still valid? |
This PR will be closed in 2 weeks in case of no activity. |
This PR was closed because it has been stalled for 2 week with no activity. |
This PR contains int8 tests for nodes:
TODO