|
|
@ -84,14 +84,13 @@ TEST_F(TestResizeBilinearInt8, Bilinear0) {
|
|
|
|
int8_t output_data[16] = {0};
|
|
|
|
int8_t output_data[16] = {0};
|
|
|
|
std::vector<int> in_shape = {1, 2, 2, 1};
|
|
|
|
std::vector<int> in_shape = {1, 2, 2, 1};
|
|
|
|
std::vector<int> out_shape = {1, 4, 4, 1};
|
|
|
|
std::vector<int> out_shape = {1, 4, 4, 1};
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 2};
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 0};
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.008f, 5};
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.008f, 0};
|
|
|
|
bool align_corners = false;
|
|
|
|
bool align_corners = false;
|
|
|
|
int thread_num = 1;
|
|
|
|
int thread_num = 1;
|
|
|
|
int8_t expect[16] = {4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 5, 5, 6, 6};
|
|
|
|
int8_t expect[16] = {0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2};
|
|
|
|
|
|
|
|
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
kernel_->Init();
|
|
|
|
|
|
|
|
kernel_->Run();
|
|
|
|
kernel_->Run();
|
|
|
|
|
|
|
|
|
|
|
|
CompareOutputInt8(output_data, expect, 16, err_percent_);
|
|
|
|
CompareOutputInt8(output_data, expect, 16, err_percent_);
|
|
|
@ -104,20 +103,19 @@ TEST_F(TestResizeBilinearInt8, Bilinear1) {
|
|
|
|
int8_t input_data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
|
|
|
int8_t input_data[] = {0, 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};
|
|
|
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
|
|
|
|
int8_t output_data[160] = {0};
|
|
|
|
int8_t output_data[160] = {0};
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 2};
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 0};
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.008f, 5};
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.008f, 0};
|
|
|
|
int thread_num = 1;
|
|
|
|
int thread_num = 1;
|
|
|
|
bool align_corners = false;
|
|
|
|
bool align_corners = false;
|
|
|
|
int8_t expect[160] = {4, 4, 5, 6, 6, 5, 6, 7, 7, 8, 7, 8, 8, 9, 9, 7, 8, 8, 9, 9, 7, 8, 8,
|
|
|
|
int8_t expect[160] = {0, 1, 1, 2, 2, 2, 2, 3, 3, 4, 3, 4, 4, 5, 6, 3, 4, 4, 5, 6, 3, 4, 4,
|
|
|
|
9, 9, 8, 9, 10, 10, 11, 10, 11, 11, 12, 13, 10, 11, 11, 12, 13, 10, 11, 11, 12, 13, 12,
|
|
|
|
5, 6, 5, 5, 6, 7, 7, 6, 7, 8, 8, 9, 6, 7, 8, 8, 9, 6, 7, 7, 8, 9, 8,
|
|
|
|
12, 13, 13, 14, 13, 14, 14, 15, 16, 13, 14, 14, 15, 16, 10, 11, 11, 12, 13, 12, 12, 13, 13,
|
|
|
|
8, 9, 10, 10, 9, 10, 11, 11, 12, 9, 10, 11, 11, 12, 6, 7, 7, 8, 9, 8, 8, 9, 10,
|
|
|
|
14, 13, 14, 14, 15, 16, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 18, 18, 19, 20, 20, 19, 20,
|
|
|
|
10, 9, 10, 11, 11, 12, 9, 10, 11, 11, 12, 13, 13, 14, 14, 15, 14, 15, 15, 16, 17, 16, 16,
|
|
|
|
21, 21, 22, 19, 20, 21, 21, 22, 19, 20, 21, 21, 22, 21, 22, 22, 23, 23, 23, 23, 24, 24, 25,
|
|
|
|
17, 18, 18, 16, 16, 17, 18, 18, 16, 16, 17, 18, 18, 17, 18, 18, 19, 20, 19, 19, 20, 21, 21,
|
|
|
|
23, 23, 24, 24, 25, 23, 23, 24, 24, 25, 24, 25, 25, 26, 27, 26, 26, 27, 28, 28, 26, 26, 27,
|
|
|
|
19, 19, 20, 21, 21, 19, 19, 20, 21, 21, 20, 21, 22, 22, 23, 22, 23, 23, 24, 24, 22, 23, 23,
|
|
|
|
28, 28, 23, 23, 24, 24, 25, 24, 25, 25, 26, 27, 26, 26, 27, 28, 28, 26, 26, 27, 28, 28};
|
|
|
|
24, 24, 19, 19, 20, 21, 21, 20, 21, 22, 22, 23, 22, 23, 23, 24, 24, 22, 23, 23, 24, 24};
|
|
|
|
|
|
|
|
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
kernel_->Init();
|
|
|
|
|
|
|
|
kernel_->Run();
|
|
|
|
kernel_->Run();
|
|
|
|
|
|
|
|
|
|
|
|
CompareOutputInt8(output_data, expect, 160, err_percent_);
|
|
|
|
CompareOutputInt8(output_data, expect, 160, err_percent_);
|
|
|
@ -131,22 +129,49 @@ TEST_F(TestResizeBilinearInt8, Bilinear2) {
|
|
|
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
|
|
|
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
|
|
|
|
int8_t output_data[160] = {0};
|
|
|
|
int8_t output_data[160] = {0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 0};
|
|
|
|
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.008f, 0};
|
|
|
|
|
|
|
|
int thread_num = 2;
|
|
|
|
|
|
|
|
bool align_corners = true;
|
|
|
|
|
|
|
|
int8_t expect[160] = {0, 1, 1, 2, 2, 1, 2, 2, 3, 4, 2, 3, 3, 4, 5, 3, 4, 4, 5, 6, 2, 3, 3,
|
|
|
|
|
|
|
|
4, 5, 3, 4, 4, 5, 6, 4, 5, 5, 6, 7, 5, 6, 6, 7, 8, 4, 5, 5, 6, 7, 5,
|
|
|
|
|
|
|
|
6, 6, 7, 8, 6, 7, 8, 8, 9, 7, 8, 9, 9, 10, 6, 7, 7, 8, 9, 7, 8, 9, 9,
|
|
|
|
|
|
|
|
10, 8, 9, 10, 10, 11, 9, 10, 11, 11, 12, 13, 13, 14, 14, 15, 14, 14, 15, 15, 16, 15, 15,
|
|
|
|
|
|
|
|
16, 16, 17, 16, 16, 17, 18, 18, 15, 15, 16, 16, 17, 16, 16, 17, 18, 18, 17, 17, 18, 19, 19,
|
|
|
|
|
|
|
|
18, 18, 19, 20, 20, 17, 17, 18, 19, 19, 18, 18, 19, 20, 20, 19, 19, 20, 21, 21, 20, 20, 21,
|
|
|
|
|
|
|
|
22, 22, 19, 19, 20, 21, 21, 20, 20, 21, 22, 22, 21, 21, 22, 23, 23, 22, 23, 23, 24, 24};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
|
|
|
|
kernel_->Run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CompareOutputInt8(output_data, expect, 160, err_percent_);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2*2*2*5 -> 2*4*4*5 thread num 2, align corners zp -128
|
|
|
|
|
|
|
|
TEST_F(TestResizeBilinearInt8, Bilinear3) {
|
|
|
|
|
|
|
|
std::vector<int> in_shape = {2, 2, 2, 5};
|
|
|
|
|
|
|
|
std::vector<int> out_shape = {2, 4, 4, 5};
|
|
|
|
|
|
|
|
int8_t input_data[] = {0, 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};
|
|
|
|
|
|
|
|
int8_t output_data[160] = {0};
|
|
|
|
|
|
|
|
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 2};
|
|
|
|
const lite::tensor::QuantArg quant_in = {0.005f, 2};
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.008f, 5};
|
|
|
|
const lite::tensor::QuantArg quant_out = {0.005f, 2};
|
|
|
|
int thread_num = 2;
|
|
|
|
int thread_num = 2;
|
|
|
|
bool align_corners = true;
|
|
|
|
bool align_corners = true;
|
|
|
|
int8_t expect[160] = {4, 4, 5, 6, 6, 5, 5, 6, 7, 7, 6, 6, 7, 8, 8, 7, 8, 8, 9, 9, 6, 6, 7,
|
|
|
|
int8_t expect[160] = {0, 1, 2, 3, 4, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 3, 4, 5,
|
|
|
|
8, 8, 7, 8, 8, 9, 9, 8, 9, 9, 10, 10, 9, 10, 10, 11, 11, 8, 9, 9, 10, 10, 9,
|
|
|
|
6, 7, 5, 6, 7, 8, 9, 7, 8, 9, 10, 11, 8, 9, 10, 11, 12, 7, 8, 9, 10, 11, 8,
|
|
|
|
10, 10, 11, 11, 10, 11, 11, 12, 13, 11, 12, 12, 13, 14, 10, 11, 11, 12, 13, 11, 12, 12, 13,
|
|
|
|
9, 10, 11, 12, 10, 11, 12, 13, 14, 12, 13, 14, 15, 16, 10, 11, 12, 13, 14, 12, 13, 14, 15,
|
|
|
|
14, 12, 13, 13, 14, 15, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 17, 18, 19, 19, 20, 18, 19,
|
|
|
|
16, 13, 14, 15, 16, 17, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 22, 23, 24, 25, 26, 23, 24,
|
|
|
|
20, 20, 21, 19, 20, 21, 21, 22, 18, 19, 20, 20, 21, 19, 20, 21, 21, 22, 20, 21, 22, 22, 23,
|
|
|
|
25, 26, 27, 25, 26, 27, 28, 29, 23, 24, 25, 26, 27, 25, 26, 27, 28, 29, 27, 28, 29, 30, 31,
|
|
|
|
21, 22, 23, 23, 24, 20, 21, 22, 22, 23, 21, 22, 23, 23, 24, 23, 23, 24, 24, 25, 24, 24, 25,
|
|
|
|
28, 29, 30, 31, 32, 27, 28, 29, 30, 31, 28, 29, 30, 31, 32, 30, 31, 32, 33, 34, 32, 33, 34,
|
|
|
|
25, 26, 23, 23, 24, 24, 25, 24, 24, 25, 25, 26, 25, 25, 26, 26, 27, 26, 26, 27, 28, 28};
|
|
|
|
35, 36, 30, 31, 32, 33, 34, 32, 33, 34, 35, 36, 33, 34, 35, 36, 37, 35, 36, 37, 38, 39};
|
|
|
|
|
|
|
|
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
Prepare(in_shape, out_shape, input_data, output_data, quant_in, quant_out, align_corners, thread_num);
|
|
|
|
kernel_->Init();
|
|
|
|
|
|
|
|
kernel_->Run();
|
|
|
|
kernel_->Run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err_percent_ = 0.325f;
|
|
|
|
CompareOutputInt8(output_data, expect, 160, err_percent_);
|
|
|
|
CompareOutputInt8(output_data, expect, 160, err_percent_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace mindspore
|
|
|
|
} // namespace mindspore
|
|
|
|