Skip to content

Commit

Permalink
[GNA] Make PWL unit tests take into account saturation errata
Browse files Browse the repository at this point in the history
  • Loading branch information
sirzabek committed Apr 30, 2021
1 parent f08e6ea commit d742be2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ TEST_F(PWLAproximationTest, forReLUonRecursiveAlgoWithSegmentThresholdIsSuccess)
.propagate_forward()
.called_with()
.pwl_quantization_activation(DnnActivationType::kActRelu)
.pwl_quantization_segments_threshold(2);
.pwl_quantization_segments_threshold(4);
}

TEST_F(PWLAproximationTest, forLeakyReLUonRecursiveAlgoWithSegmentThresholdIsSuccess) {
Expand All @@ -157,7 +157,7 @@ TEST_F(PWLAproximationTest, forLeakyReLUonRecursiveAlgoWithSegmentThresholdIsSuc
.propagate_forward()
.called_with()
.pwl_quantization_activation(DnnActivationType::kActLeakyRelu)
.pwl_quantization_segments_threshold(2);
.pwl_quantization_segments_threshold(4);
}

TEST_F(PWLAproximationTest, DISABLED_forIdentityOnRecursiveAlgoWithSegmentThresholdIsSuccess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@ class PWLMatcher : public ::testing::MatcherInterface<const gna_nnet_type_t*> {
}

switch (slopeChangedTimes) {
case 2 : return kActRelu; // also relu has y=0 segment while identity doenst have
case 3 : return kActIdentity;
case 3 :
if (comp.op.pwl.num_segments == 4) {
// ReLU has y=0 segment while identity doesn't have
// 2 segments are added: one at the begining and one at the end, due to saturation errata
return kActRelu;
} else {
return kActIdentity;
}
default:
// currently cannot determine between sigmoid or tanh etc
if (slopeChangedTimes > 3) {
Expand Down

0 comments on commit d742be2

Please sign in to comment.