3 * Copyright (C) 2018-2019 Intel Corporation.
5 * The source code contained or described herein and all documents
6 * related to the source code ("Material") are owned by Intel Corporation
7 * or its suppliers or licensors. Title to the Material remains with
8 * Intel Corporation or its suppliers and licensors. The Material may
9 * contain trade secrets and proprietary and confidential information
10 * of Intel Corporation and its suppliers and licensors, and is protected
11 * by worldwide copyright and trade secret laws and treaty provisions.
12 * No part of the Material may be used, copied, reproduced, modified,
13 * published, uploaded, posted, transmitted, distributed, or disclosed
14 * in any way without Intel's prior express written permission.
16 * No license under any patent, copyright, trade secret or other
17 * intellectual property right is granted to or conferred upon you by
18 * disclosure or delivery of the Materials, either expressly, by implication,
19 * inducement, estoppel or otherwise. Any license under such intellectual
20 * property rights must be express and approved by Intel in writing.
22 * Include any supplier copyright notices as supplier requires Intel to use.
24 * Include supplier trademarks or logos as supplier requires Intel to use,
25 * preceded by an asterisk. An asterisked footnote can be added as follows:
26 * *Third Party trademarks are the property of their respective owners.
28 * Unless otherwise agreed by Intel in writing, you may not remove or alter
29 * this notice or any other notice embedded in Materials by Intel or Intel's
30 * suppliers or licensors in any way.
35 #include <gtest/gtest.h>
36 #include "gna_matcher.hpp"
38 class PWLAproximationTest : public GNATest {
40 void SetUp() override {
43 using namespace GNATestIRs;
45 // Recursive Algorithm
46 // Precision Threshold
48 TEST_F(PWLAproximationTest, forTanhOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
49 assert_that().onInferModel(TanhActivationModel())
53 .pwl_quantization_activation(DnnActivationType::kActTanh)
54 .pwl_quantization_precision_threshold(0.0053);
57 TEST_F(PWLAproximationTest, forSigmoidOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
58 assert_that().onInferModel(SigmoidActivationModel())
62 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
63 .pwl_quantization_precision_threshold(0.0027);
66 TEST_F(PWLAproximationTest, forReLUonRecursiveAlgoWithPrecisionThresholdIsSuccess) {
67 assert_that().onInferModel(ReLUActivationModel())
71 .pwl_quantization_activation(DnnActivationType::kActRelu)
72 .pwl_quantization_precision_threshold(0.0001);
75 TEST_F(PWLAproximationTest, forLeakyReLUonRecursiveAlgoWithPrecisionThresholdIsSuccess) {
76 assert_that().onInferModel(LeakyReLUActivationModel())
80 .pwl_quantization_activation(DnnActivationType::kActLeakyRelu)
81 .pwl_quantization_precision_threshold(0.0003);
84 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
85 assert_that().onInferModel(IdentityActivationModel())
89 .pwl_quantization_activation(DnnActivationType::kActIdentity)
90 .pwl_quantization_precision_threshold(0.0003);
93 TEST_F(PWLAproximationTest, forClampOnRecursiveAlgoWithPrecisionThresholdIsSuccess) {
94 assert_that().onInferModel(ClampActivationModel())
98 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
99 .pwl_quantization_precision_threshold(0.0001);
103 // Precision Threshold
105 TEST_F(PWLAproximationTest, forTanhOnUniformAlgoWithPrecisionThresholdIsSuccess) {
106 assert_that().onInferModel(TanhActivationModel())
108 .withUniformPWLAlgo()
111 .pwl_quantization_activation(DnnActivationType::kActTanh)
112 .pwl_quantization_precision_threshold(0.0009);
115 TEST_F(PWLAproximationTest, forSigmoidOnUniformAlgoWithPrecisionThresholdIsSuccess) {
116 assert_that().onInferModel(SigmoidActivationModel())
118 .withUniformPWLAlgo()
121 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
122 .pwl_quantization_precision_threshold(0.0004);
125 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnUniformAlgoWithPrecisionThresholdIsSuccess) {
126 assert_that().onInferModel(IdentityActivationModel())
128 .withUniformPWLAlgo()
131 .pwl_quantization_activation(DnnActivationType::kActIdentity)
132 .pwl_quantization_precision_threshold(0.0003);
135 TEST_F(PWLAproximationTest, forClampOnUniformAlgoWithPrecisionThresholdIsSuccess) {
136 assert_that().onInferModel(ClampActivationModel())
138 .withUniformPWLAlgo()
141 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
142 .pwl_quantization_precision_threshold(0.0001);
145 // Recursive Algorithm
148 TEST_F(PWLAproximationTest, forSigmoidonRecursiveAlgoWithSegmentThresholdIsSuccess) {
149 assert_that().onInferModel(SigmoidActivationModel())
153 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
154 .pwl_quantization_segments_threshold(12);
157 TEST_F(PWLAproximationTest, forTanhonRecursiveAlgoWithSegmentThresholdIsSuccess) {
158 assert_that().onInferModel(TanhActivationModel())
162 .pwl_quantization_activation(DnnActivationType::kActTanh)
163 .pwl_quantization_segments_threshold(12);
166 TEST_F(PWLAproximationTest, forReLUonRecursiveAlgoWithSegmentThresholdIsSuccess) {
167 assert_that().onInferModel(ReLUActivationModel())
171 .pwl_quantization_activation(DnnActivationType::kActRelu)
172 .pwl_quantization_segments_threshold(2);
175 TEST_F(PWLAproximationTest, forLeakyReLUonRecursiveAlgoWithSegmentThresholdIsSuccess) {
176 assert_that().onInferModel(LeakyReLUActivationModel())
180 .pwl_quantization_activation(DnnActivationType::kActLeakyRelu)
181 .pwl_quantization_segments_threshold(2);
184 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnRecursiveAlgoWithSegmentThresholdIsSuccess) {
185 assert_that().onInferModel(IdentityActivationModel())
189 .pwl_quantization_activation(DnnActivationType::kActIdentity)
190 .pwl_quantization_segments_threshold(3);
193 TEST_F(PWLAproximationTest, forClampOnRecursiveAlgoWithSegmentThresholdIsSuccess) {
194 assert_that().onInferModel(ClampActivationModel())
198 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
199 .pwl_quantization_segments_threshold(3);
205 TEST_F(PWLAproximationTest, forSigmoidonUniformAlgoWithSegmentThresholdIsSuccess) {
206 assert_that().onInferModel(SigmoidActivationModel())
208 .withUniformPWLAlgo()
211 .pwl_quantization_activation(DnnActivationType::kActSigmoid)
212 .pwl_quantization_segments_threshold(65);
215 TEST_F(PWLAproximationTest, forTanhonUniformAlgoWithSegmentThresholdIsSuccess) {
216 assert_that().onInferModel(TanhActivationModel())
218 .withUniformPWLAlgo()
221 .pwl_quantization_activation(DnnActivationType::kActTanh)
222 .pwl_quantization_segments_threshold(65);
225 TEST_F(PWLAproximationTest, DISABLED_forIdentityOnUniformAlgoWithSegmentThresholdIsSuccess) {
226 assert_that().onInferModel(IdentityActivationModel())
228 .withUniformPWLAlgo()
231 .pwl_quantization_activation(DnnActivationType::kActIdentity)
232 .pwl_quantization_segments_threshold(3);
235 TEST_F(PWLAproximationTest, forClampOnUniformAlgoWithSegmentThresholdIsSuccess) {
236 assert_that().onInferModel(ClampActivationModel())
238 .withUniformPWLAlgo()
241 .pwl_quantization_activation(DnnActivationType::kActKaldiLstmClipping)
242 .pwl_quantization_segments_threshold(3);