forked from uTensor/uTensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NnTests.hpp
50 lines (41 loc) · 1.54 KB
/
NnTests.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef UTENSOR_NN_TESTS
#define UTENSOR_NN_TESTS
#include "NnOps.hpp"
#include "tensorIdxImporter.hpp"
#include "test.hpp"
class NnOpsTest : public Test {
public:
void reluTest(void) {
testStart("quantized_relu");
TensorIdxImporter t_import;
// reference inputs
Tensor<unsigned char> a =
t_import.ubyte_import("/fs/testData/ref_qRelu/in/QuantizeV2_0.idx");
Tensor<float> min =
t_import.float_import("/fs/testData/ref_qRelu/in/QuantizeV2_1.idx");
Tensor<float> max =
t_import.float_import("/fs/testData/ref_qRelu/in/QuantizeV2_2.idx");
// reference outputs
Tensor<unsigned char> ref_out =
t_import.ubyte_import("/fs/testData/ref_qRelu/out/ref_qRelu_0.idx");
Tensor<float> ref_min =
t_import.float_import("/fs/testData/ref_qRelu/out/ref_qRelu_1.idx");
Tensor<float> ref_max =
t_import.float_import("/fs/testData/ref_qRelu/out/ref_qRelu_2.idx");
// modify the checks below:
Tensor<unsigned char> out(ref_out.getShape());
Tensor<float> out_min(ref_out.getShape());
Tensor<float> out_max(ref_out.getShape());
timer_start();
Relu<unsigned char, float, unsigned char>(a, min, max, out, out_min,
out_max);
timer_stop();
double result = meanPercentErr(ref_out, out) +
meanPercentErr(ref_min, out_min) +
meanPercentErr(ref_max, out_max);
// passed(result < 0.0001);
passed(result == 0);
}
void runAll(void) { reluTest(); }
};
#endif // UTENSOR_NN_TESTS