diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index 3f9314661e69937758459ebc0be0364e91e7645b..fda211d4860a32fc3bec56152b06eefb6b3a386f 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -154,6 +154,15 @@ const std::string OpenCLErrorToString(cl_int error) { } } +namespace { +void OpenCLPrintfCallback(const char *buffer, + size_t length, + size_t final, + void *user_data) { + fwrite(buffer, 1, length, stdout); +} +} + void OpenCLProfilingTimer::StartTiming() {} void OpenCLProfilingTimer::StopTiming() { @@ -299,8 +308,19 @@ OpenCLRuntime::OpenCLRuntime(GPUPerfHint gpu_perf_hint, new cl::Context({*device_}, context_properties.data(), nullptr, nullptr, &err)); } else { - context_ = std::shared_ptr( - new cl::Context({*device_}, nullptr, nullptr, nullptr, &err)); + if (is_profiling_enabled_ && gpu_type_ == GPUType::MALI) { + std::vector context_properties = { + CL_CONTEXT_PLATFORM, (cl_context_properties)default_platform(), + CL_PRINTF_CALLBACK_ARM, (cl_context_properties)OpenCLPrintfCallback, + CL_PRINTF_BUFFERSIZE_ARM, 0x1000, 0 + }; + context_ = std::shared_ptr( + new cl::Context({*device_}, context_properties.data(), + nullptr, nullptr, &err)); + } else { + context_ = std::shared_ptr( + new cl::Context({*device_}, nullptr, nullptr, nullptr, &err)); + } } MACE_CHECK_CL_SUCCESS(err); diff --git a/mace/kernels/opencl/cl/pooling.cl b/mace/kernels/opencl/cl/pooling.cl index c76d055ff21dc0bd8dbe689297427db6c66c9ac3..b0faddb021451f834334b1ca84c318011d1cdd9c 100644 --- a/mace/kernels/opencl/cl/pooling.cl +++ b/mace/kernels/opencl/cl/pooling.cl @@ -1,10 +1,6 @@ #include -#ifdef FP16 -#define MIN_VALUE -USHRT_MAX -#else #define MIN_VALUE -FLT_MAX -#endif inline int calculate_avg_block_size(const int pool_size, const int pos_h, diff --git a/mace/ops/conv_2d_test.cc b/mace/ops/conv_2d_test.cc index a9707ab8469174efed16fcc33485b00fa3c2897a..e0edd2a979d465ccfed898c50d375db509b89b67 100644 --- a/mace/ops/conv_2d_test.cc +++ b/mace/ops/conv_2d_test.cc @@ -416,7 +416,7 @@ void TestComplexConvNxNS12(const std::vector &shape, ImageToBuffer(&net, "OutputImage", "OPENCLOutput", kernels::BufferType::IN_OUT_CHANNEL); ExpectTensorNear(expected, - *net.GetOutput("OPENCLOutput"), 1e-5, 1e-4); + *net.GetOutput("OPENCLOutput"), 1e-4, 1e-4); }; for (int kernel_size : {1, 3, 7}) { @@ -644,7 +644,7 @@ void TestDilationConvNxN(const std::vector &shape, ImageToBuffer(&net, "OutputImage", "OPENCLOutput", kernels::BufferType::IN_OUT_CHANNEL); ExpectTensorNear(expected, *net.GetOutput("OPENCLOutput"), - 1e-5, 1e-4); + 1e-4, 1e-4); }; for (int kernel_size : {3}) { @@ -729,7 +729,7 @@ void TestArbitraryPadConvNxN(const std::vector &shape, ImageToBuffer(&net, "OutputImage", "OPENCLOutput", kernels::BufferType::IN_OUT_CHANNEL); ExpectTensorNear(expected, *net.GetOutput("OPENCLOutput"), - 1e-5, 1e-4); + 1e-4, 1e-4); }; for (int kernel_size : {3, 5}) {