1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 #include <gtest/gtest.h>
7 #include "gna_matcher.hpp"
9 class PWLAproximationTest : public GNATest {
11 void SetUp() override {
14 using namespace GNATestIRs;
16 // Recursive Algorithm
17 // Precision Threshold
19 TEST_F(PWLAproximationTest, forTanhOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
20 assert_that().onInferModel(TanhActivationModel())
24 .pwl_quantization_activation(DnnActivationType::kActTanh)
25 .pwl_quantization_precision_threshold(0.0053);
28 TEST_F(PWLAproximationTest, forSigmoidOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
29 assert_that().onInferModel(SigmoidActivationModel())
33 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
34 .pwl_quantization_precision_threshold(0.0027);
37 TEST_F(PWLAproximationTest, forReLUonRecursiveAlgoWithPrecisionThresholdIsSuccess) {
38 assert_that().onInferModel(ReLUActivationModel())
42 .pwl_quantization_activation(DnnActivationType::kActRelu)
43 .pwl_quantization_precision_threshold(0.0001);
46 TEST_F(PWLAproximationTest, forLeakyReLUonRecursiveAlgoWithPrecisionThresholdIsSuccess) {
47 assert_that().onInferModel(LeakyReLUActivationModel())
51 .pwl_quantization_activation(DnnActivationType::kActLeakyRelu)
52 .pwl_quantization_precision_threshold(0.0003);
55 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
56 assert_that().onInferModel(IdentityActivationModel())
60 .pwl_quantization_activation(DnnActivationType::kActIdentity)
61 .pwl_quantization_precision_threshold(0.0003);
64 TEST_F(PWLAproximationTest, forClampOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
65 assert_that().onInferModel(ClampActivationModel())
69 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
70 .pwl_quantization_precision_threshold(0.0001);
74 // Precision Threshold
76 TEST_F(PWLAproximationTest, forTanhOnUniformAlgoWithPrecisionThresholdIsSuccess) {
77 assert_that().onInferModel(TanhActivationModel())
82 .pwl_quantization_activation(DnnActivationType::kActTanh)
83 .pwl_quantization_precision_threshold(0.0009);
86 TEST_F(PWLAproximationTest, forSigmoidOnUniformAlgoWithPrecisionThresholdIsSuccess) {
87 assert_that().onInferModel(SigmoidActivationModel())
92 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
93 .pwl_quantization_precision_threshold(0.0004);
96 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnUniformAlgoWithPrecisionThresholdIsSuccess) {
97 assert_that().onInferModel(IdentityActivationModel())
102 .pwl_quantization_activation(DnnActivationType::kActIdentity)
103 .pwl_quantization_precision_threshold(0.0003);
106 TEST_F(PWLAproximationTest, forClampOnUniformAlgoWithPrecisionThresholdIsSuccess) {
107 assert_that().onInferModel(ClampActivationModel())
109 .withUniformPWLAlgo()
112 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
113 .pwl_quantization_precision_threshold(0.0001);
116 // Recursive Algorithm
119 TEST_F(PWLAproximationTest, forSigmoidonRecursiveAlgoWithSegmentThresholdIsSuccess) {
120 assert_that().onInferModel(SigmoidActivationModel())
124 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
125 .pwl_quantization_segments_threshold(12);
128 TEST_F(PWLAproximationTest, forTanhonRecursiveAlgoWithSegmentThresholdIsSuccess) {
129 assert_that().onInferModel(TanhActivationModel())
133 .pwl_quantization_activation(DnnActivationType::kActTanh)
134 .pwl_quantization_segments_threshold(12);
137 TEST_F(PWLAproximationTest, forReLUonRecursiveAlgoWithSegmentThresholdIsSuccess) {
138 assert_that().onInferModel(ReLUActivationModel())
142 .pwl_quantization_activation(DnnActivationType::kActRelu)
143 .pwl_quantization_segments_threshold(2);
146 TEST_F(PWLAproximationTest, forLeakyReLUonRecursiveAlgoWithSegmentThresholdIsSuccess) {
147 assert_that().onInferModel(LeakyReLUActivationModel())
151 .pwl_quantization_activation(DnnActivationType::kActLeakyRelu)
152 .pwl_quantization_segments_threshold(2);
155 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnRecursiveAlgoWithSegmentThresholdIsSuccess) {
156 assert_that().onInferModel(IdentityActivationModel())
160 .pwl_quantization_activation(DnnActivationType::kActIdentity)
161 .pwl_quantization_segments_threshold(3);
164 TEST_F(PWLAproximationTest, forClampOnRecursiveAlgoWithSegmentThresholdIsSuccess) {
165 assert_that().onInferModel(ClampActivationModel())
169 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
170 .pwl_quantization_segments_threshold(3);
176 TEST_F(PWLAproximationTest, forSigmoidonUniformAlgoWithSegmentThresholdIsSuccess) {
177 assert_that().onInferModel(SigmoidActivationModel())
179 .withUniformPWLAlgo()
182 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
183 .pwl_quantization_segments_threshold(65);
186 TEST_F(PWLAproximationTest, forTanhonUniformAlgoWithSegmentThresholdIsSuccess) {
187 assert_that().onInferModel(TanhActivationModel())
189 .withUniformPWLAlgo()
192 .pwl_quantization_activation(DnnActivationType::kActTanh)
193 .pwl_quantization_segments_threshold(65);
196 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnUniformAlgoWithSegmentThresholdIsSuccess) {
197 assert_that().onInferModel(IdentityActivationModel())
199 .withUniformPWLAlgo()
202 .pwl_quantization_activation(DnnActivationType::kActIdentity)
203 .pwl_quantization_segments_threshold(3);
206 TEST_F(PWLAproximationTest, forClampOnUniformAlgoWithSegmentThresholdIsSuccess) {
207 assert_that().onInferModel(ClampActivationModel())
209 .withUniformPWLAlgo()
212 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
213 .pwl_quantization_segments_threshold(3);