diff --git a/mace/kernels/opencl/addn.cc b/mace/kernels/opencl/addn.cc index 837f6cd8d1b5a8ef16ff80020cb2ac2a51c7e7b2..d138aca3bd04248510859d6bd4b4ffc29f83f11d 100644 --- a/mace/kernels/opencl/addn.cc +++ b/mace/kernels/opencl/addn.cc @@ -84,12 +84,14 @@ static void AddN(const std::vector &input_tensors, params_generator, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template diff --git a/mace/kernels/opencl/batch_norm_opencl.cc b/mace/kernels/opencl/batch_norm_opencl.cc index b53ef848556f01279eaf8f62b8e1f1fa24c7ee84..6cd46e76a8490632227457854152adf6da92242a 100644 --- a/mace/kernels/opencl/batch_norm_opencl.cc +++ b/mace/kernels/opencl/batch_norm_opencl.cc @@ -96,12 +96,14 @@ void BatchNormFunctor::operator()( params_generator, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template diff --git a/mace/kernels/opencl/bias_add_opencl.cc b/mace/kernels/opencl/bias_add_opencl.cc index e843e5f3774ca67febc5df1b143f199d7d071139..6d9aa4a95c57489dc639e0df11356ab5ec6f6083 100644 --- a/mace/kernels/opencl/bias_add_opencl.cc +++ b/mace/kernels/opencl/bias_add_opencl.cc @@ -50,12 +50,14 @@ void BiasAddFunctor::operator()( cl::NDRange(lws[0], lws[1], lws[2]), nullptr, &event); MACE_CHECK(error == CL_SUCCESS); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template diff --git a/mace/kernels/opencl/buffer_to_image.cc b/mace/kernels/opencl/buffer_to_image.cc index c0dea3a2dc0e80c76c45b7bd75e02ebd7639791b..b28f113b0b748f0a0eb9ab309a22f45a8d01c866 100644 --- a/mace/kernels/opencl/buffer_to_image.cc +++ b/mace/kernels/opencl/buffer_to_image.cc @@ -73,12 +73,14 @@ void BufferToImageFunctor::operator()(Tensor *buffer, nullptr, &event); MACE_CHECK(error == CL_SUCCESS) << "Error code: " << error; - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template struct BufferToImageFunctor; diff --git a/mace/kernels/opencl/concat.cc b/mace/kernels/opencl/concat.cc index 514d590db94707f4313771ef4421174610d30eeb..bea536b69bd1191c410abaa348b2cf4ca4108c0b 100644 --- a/mace/kernels/opencl/concat.cc +++ b/mace/kernels/opencl/concat.cc @@ -97,12 +97,14 @@ static void Concat2(const Tensor *input0, params_generator, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template diff --git a/mace/kernels/opencl/conv_2d_opencl_1x1.cc b/mace/kernels/opencl/conv_2d_opencl_1x1.cc index 59b933763f1febd23e1f63933816add009b3313e..e2146a2e00dcc9ed0b1425a10bd1ee470e13dbb4 100644 --- a/mace/kernels/opencl/conv_2d_opencl_1x1.cc +++ b/mace/kernels/opencl/conv_2d_opencl_1x1.cc @@ -114,12 +114,14 @@ void Conv1x1(const Tensor *input, params_generator, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } extern void Conv2dOpenclK1x1S1(const Tensor *input, diff --git a/mace/kernels/opencl/conv_2d_opencl_3x3.cc b/mace/kernels/opencl/conv_2d_opencl_3x3.cc index 59b66e4839bd8209e5f8073b0400e2d64da33fb2..6902448a1888e7cec9adea05ed239321a9b5cc15 100644 --- a/mace/kernels/opencl/conv_2d_opencl_3x3.cc +++ b/mace/kernels/opencl/conv_2d_opencl_3x3.cc @@ -107,12 +107,14 @@ static void Conv2d3x3S12(const Tensor *input, const Tensor *filter, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } void Conv2dOpenclK3x3S1(const Tensor *input, const Tensor *filter, diff --git a/mace/kernels/opencl/conv_2d_opencl_general.cc b/mace/kernels/opencl/conv_2d_opencl_general.cc index d3cee60087049340d8119c13ab074348a6dcda8d..1ad8b194eb9428cc473a36bf0a73cb1cf3f09d62 100644 --- a/mace/kernels/opencl/conv_2d_opencl_general.cc +++ b/mace/kernels/opencl/conv_2d_opencl_general.cc @@ -109,12 +109,14 @@ void Conv2dOpencl(const Tensor *input, const Tensor *filter, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } } // namespace kernels diff --git a/mace/kernels/opencl/depthwise_conv_opencl_3x3.cc b/mace/kernels/opencl/depthwise_conv_opencl_3x3.cc index c67382c479199ca45063252448e081e33f26d0a1..2300e0f04c7fa2022464d2ee8cfe8e12f696a219 100644 --- a/mace/kernels/opencl/depthwise_conv_opencl_3x3.cc +++ b/mace/kernels/opencl/depthwise_conv_opencl_3x3.cc @@ -66,12 +66,14 @@ static void InnerDepthwiseConvOpenclK3x3S12(const Tensor *input, nullptr, &event); MACE_CHECK(error == CL_SUCCESS); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } extern void DepthwiseConvOpenclK3x3S1(const Tensor *input, diff --git a/mace/kernels/opencl/pooling_opencl.cc b/mace/kernels/opencl/pooling_opencl.cc index 814159668ec87b5f5afec33667abfc9b531d42a3..991dcac36dd3bd4c6ba24cb899d23e567f1f7bf8 100644 --- a/mace/kernels/opencl/pooling_opencl.cc +++ b/mace/kernels/opencl/pooling_opencl.cc @@ -110,12 +110,14 @@ static void Pooling(const Tensor *input, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template diff --git a/mace/kernels/opencl/relu_opencl.cc b/mace/kernels/opencl/relu_opencl.cc index d74337ecf907828e0fb5905c3f97170cb3b38e84..c9d5a7f18a03f419c0a1686dfa98b070f6ff7597 100644 --- a/mace/kernels/opencl/relu_opencl.cc +++ b/mace/kernels/opencl/relu_opencl.cc @@ -97,12 +97,14 @@ void ReluFunctor::operator()(const Tensor *input, params_generator, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template diff --git a/mace/kernels/opencl/resize_bilinear_opencl.cc b/mace/kernels/opencl/resize_bilinear_opencl.cc index f8c7aa71e91d70bd385fdcf82fc2a13d7a31d2d7..588d83c603426a9e23f9e050bdd6568924e28d6f 100644 --- a/mace/kernels/opencl/resize_bilinear_opencl.cc +++ b/mace/kernels/opencl/resize_bilinear_opencl.cc @@ -102,12 +102,14 @@ void ResizeBilinearFunctor::operator()( params_generator, func, &timer); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } template struct ResizeBilinearFunctor; diff --git a/mace/kernels/opencl/space_to_batch_opecl.cc b/mace/kernels/opencl/space_to_batch_opecl.cc index 395b9235697d9fc63237ac91e63ce77a9a642a2b..32ada21a210091a02033babb8cefd08517b43e4a 100644 --- a/mace/kernels/opencl/space_to_batch_opecl.cc +++ b/mace/kernels/opencl/space_to_batch_opecl.cc @@ -50,12 +50,14 @@ void SpaceToBatchFunctor::operator()(Tensor *space_te cl::NDRange(lws[0], lws[1], lws[2]), nullptr, &event); MACE_CHECK(error == CL_SUCCESS); - future->wait_fn = [runtime, event](CallStats *stats) { - event.wait(); - if (stats != nullptr) { - runtime->GetCallStats(event, stats); - } - }; + if (future != nullptr) { + future->wait_fn = [runtime, event](CallStats *stats) { + event.wait(); + if (stats != nullptr) { + runtime->GetCallStats(event, stats); + } + }; + } } } // namespace kernels diff --git a/tools/bazel-adb-run.sh b/tools/bazel-adb-run.sh index 4926ad2b95197be8772e988d07fddcbac02608fe..e80ecd83122e4322051e42c0f0760f6c94dc297f 100755 --- a/tools/bazel-adb-run.sh +++ b/tools/bazel-adb-run.sh @@ -42,5 +42,5 @@ for device in `adb devices | grep "^[A-Za-z0-9]\+[[:space:]]\+device$"| cut -f1` adb -s ${device} shell "mkdir -p $DEVICE_PATH" adb -s ${device} push $CL_PATH $DEVICE_CL_PATH && \ adb -s ${device} push $BAZEL_BIN_PATH/$BIN_NAME $DEVICE_PATH && \ - adb -s ${device} shell "MACE_KERNEL_PATH=$DEVICE_CL_PATH MACE_CPP_MIN_VLOG_LEVEL=0$VLOG_LEVEL $DEVICE_PATH/$BIN_NAME $@" + adb -s ${device} shell "MACE_KERNEL_PATH=$DEVICE_CL_PATH MACE_CPP_MIN_VLOG_LEVEL=$VLOG_LEVEL $DEVICE_PATH/$BIN_NAME $@" done