From a2164eb742c0f12835e69948a3ce4e1461af5b58 Mon Sep 17 00:00:00 2001 From: hjchen2 Date: Mon, 28 Jan 2019 17:14:11 +0800 Subject: [PATCH] Update conv unit test --- test/operators/test_conv_op.cpp | 82 +++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/test/operators/test_conv_op.cpp b/test/operators/test_conv_op.cpp index ffd4445eab..ecc2455817 100644 --- a/test/operators/test_conv_op.cpp +++ b/test/operators/test_conv_op.cpp @@ -12,6 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#include #include "../test_helper.h" #include "../test_include.h" #include "operators/conv_op.h" @@ -209,10 +210,10 @@ int TestConvOp(int in_channels, int in_height, int in_width, int out_channels, // PADDLE_MOBILE_ENFORCE(std::abs(gap / (output_data[i] + 1e-5)) < 1e-3, // "output[%d] = %d, output_cmp[%d] = %d", i, // output_data[i], i, output_cmp_data[i]); - if (std::abs(gap / (output_data[i] + 1e-5)) > 1e-3) { - LOG(kLOG_INFO) << "output_data[" << i << "] = " << output_data[i] - << ", output_cmp_data[" << i - << "] = " << output_cmp_data[i]; + if (gap > 1e-2 && std::abs(gap / (output_data[i] + 1e-5)) > 1e-3) { + std::cerr << "output_data[" << i << "] = " << output_data[i] + << ", output_cmp_data[" << i << "] = " << output_cmp_data[i] + << std::endl; exit(1); } } @@ -224,73 +225,114 @@ int TestConvOp(int in_channels, int in_height, int in_width, int out_channels, int TestAll(const int in_channels, const int in_height, const int in_width, const int out_channels, const int groups) { + std::cerr << "in_channels=" << in_channels << ", in_height=" << in_height + << ", in_width=" << in_width << ", out_channels=" << out_channels + << ", groups=" << groups << std::endl; // kernel = 3, pad = 0, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=0, stride=1"; + std::cerr << "float, kernel=3, pad=0, stride=1" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + // kernel = 3, pad = 1, stride = 1 + std::cerr << "float, kernel=3, pad=1, stride=1" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + // kernel = 3, pad = 2, stride = 1 + std::cerr << "float, kernel=3, pad=2, stride=1" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + // kernel = 3, pad = 5, stride = 1 + std::cerr << "float, kernel=3, pad=5, stride=1" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + + // kernel = 3, pad = 0, stride = 2 + std::cerr << "float, kernel=3, pad=0, stride=2" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + // kernel = 3, pad = 1, stride = 2 + std::cerr << "float, kernel=3, pad=1, stride=2" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + // kernel = 3, pad = 2, stride = 2 + std::cerr << "float, kernel=3, pad=2, stride=2" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + // kernel = 3, pad = 5, stride = 2 + std::cerr << "float, kernel=3, pad=5, stride=2" << std::endl; + paddle_mobile::TestConvOp( + in_channels, in_height, in_width, out_channels, groups); + +#ifndef __aarch64__ + // kernel = 3, pad = 0, stride = 1 + std::cerr << "int8, kernel=3, pad=0, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 1, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=1, stride=1"; + std::cerr << "int8, kernel=3, pad=1, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 2, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=2, stride=1"; + std::cerr << "int8, kernel=3, pad=2, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 5, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=5, stride=1"; + std::cerr << "int8, kernel=3, pad=5, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 0, stride = 2 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=0, stride=2"; + std::cerr << "int8, kernel=3, pad=0, stride=2" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 1, stride = 2 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=1, stride=2"; + std::cerr << "int8, kernel=3, pad=1, stride=2" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 2, stride = 2 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=2, stride=2"; + std::cerr << "int8, kernel=3, pad=2, stride=2" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 3, pad = 5, stride = 2 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=3, pad=5, stride=2"; + std::cerr << "int8, kernel=3, pad=5, stride=2" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); +#endif // __aarch64__ // kernel = 5, pad = 0, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=5, pad=0, stride=1"; + std::cerr << "float, kernel=5, pad=0, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 5, pad = 1, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=5, pad=1, stride=1"; + std::cerr << "float, kernel=5, pad=1, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 5, pad = 2, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=5, pad=2, stride=1"; + std::cerr << "float, kernel=5, pad=2, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 5, pad = 5, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "float, kernel=5, pad=5, stride=1"; + std::cerr << "float, kernel=5, pad=5, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); +#ifndef __aarch64__ // kernel = 5, pad = 0, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "int8, kernel=5, pad=0, stride=1"; + std::cerr << "int8, kernel=5, pad=0, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 5, pad = 1, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "int8, kernel=5, pad=1, stride=1"; + std::cerr << "int8, kernel=5, pad=1, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 5, pad = 2, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "int8, kernel=5, pad=2, stride=1"; + std::cerr << "int8, kernel=5, pad=2, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); // kernel = 5, pad = 5, stride = 1 - LOG(paddle_mobile::kLOG_INFO) << "int8, kernel=5, pad=5, stride=1"; + std::cerr << "int8, kernel=5, pad=5, stride=1" << std::endl; paddle_mobile::TestConvOp( in_channels, in_height, in_width, out_channels, groups); +#endif // __aarch64__ return 0; } -- GitLab