提交 bf8531f2 编写于 作者: L Liangliang He

Fix opencl future nullptr issue

上级 f50ea028
...@@ -84,12 +84,14 @@ static void AddN(const std::vector<const Tensor *> &input_tensors, ...@@ -84,12 +84,14 @@ static void AddN(const std::vector<const Tensor *> &input_tensors,
params_generator, params_generator,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template <typename T> template <typename T>
......
...@@ -96,12 +96,14 @@ void BatchNormFunctor<DeviceType::OPENCL, T>::operator()( ...@@ -96,12 +96,14 @@ void BatchNormFunctor<DeviceType::OPENCL, T>::operator()(
params_generator, params_generator,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template template
......
...@@ -50,12 +50,14 @@ void BiasAddFunctor<DeviceType::OPENCL, T>::operator()( ...@@ -50,12 +50,14 @@ void BiasAddFunctor<DeviceType::OPENCL, T>::operator()(
cl::NDRange(lws[0], lws[1], lws[2]), cl::NDRange(lws[0], lws[1], lws[2]),
nullptr, &event); nullptr, &event);
MACE_CHECK(error == CL_SUCCESS); MACE_CHECK(error == CL_SUCCESS);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template template
......
...@@ -73,12 +73,14 @@ void BufferToImageFunctor<DeviceType::OPENCL, T>::operator()(Tensor *buffer, ...@@ -73,12 +73,14 @@ void BufferToImageFunctor<DeviceType::OPENCL, T>::operator()(Tensor *buffer,
nullptr, &event); nullptr, &event);
MACE_CHECK(error == CL_SUCCESS) << "Error code: " << error; MACE_CHECK(error == CL_SUCCESS) << "Error code: " << error;
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template struct BufferToImageFunctor<DeviceType::OPENCL, float>; template struct BufferToImageFunctor<DeviceType::OPENCL, float>;
......
...@@ -97,12 +97,14 @@ static void Concat2(const Tensor *input0, ...@@ -97,12 +97,14 @@ static void Concat2(const Tensor *input0,
params_generator, params_generator,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template<typename T> template<typename T>
......
...@@ -114,12 +114,14 @@ void Conv1x1(const Tensor *input, ...@@ -114,12 +114,14 @@ void Conv1x1(const Tensor *input,
params_generator, params_generator,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
extern void Conv2dOpenclK1x1S1(const Tensor *input, extern void Conv2dOpenclK1x1S1(const Tensor *input,
......
...@@ -107,12 +107,14 @@ static void Conv2d3x3S12(const Tensor *input, const Tensor *filter, ...@@ -107,12 +107,14 @@ static void Conv2d3x3S12(const Tensor *input, const Tensor *filter,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
void Conv2dOpenclK3x3S1(const Tensor *input, void Conv2dOpenclK3x3S1(const Tensor *input,
const Tensor *filter, const Tensor *filter,
......
...@@ -109,12 +109,14 @@ void Conv2dOpencl(const Tensor *input, const Tensor *filter, ...@@ -109,12 +109,14 @@ void Conv2dOpencl(const Tensor *input, const Tensor *filter,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
} // namespace kernels } // namespace kernels
......
...@@ -66,12 +66,14 @@ static void InnerDepthwiseConvOpenclK3x3S12(const Tensor *input, ...@@ -66,12 +66,14 @@ static void InnerDepthwiseConvOpenclK3x3S12(const Tensor *input,
nullptr, &event); nullptr, &event);
MACE_CHECK(error == CL_SUCCESS); MACE_CHECK(error == CL_SUCCESS);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
extern void DepthwiseConvOpenclK3x3S1(const Tensor *input, extern void DepthwiseConvOpenclK3x3S1(const Tensor *input,
......
...@@ -110,12 +110,14 @@ static void Pooling(const Tensor *input, ...@@ -110,12 +110,14 @@ static void Pooling(const Tensor *input,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template<typename T> template<typename T>
......
...@@ -97,12 +97,14 @@ void ReluFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input, ...@@ -97,12 +97,14 @@ void ReluFunctor<DeviceType::OPENCL, T>::operator()(const Tensor *input,
params_generator, params_generator,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template template
......
...@@ -102,12 +102,14 @@ void ResizeBilinearFunctor<DeviceType::OPENCL, T>::operator()( ...@@ -102,12 +102,14 @@ void ResizeBilinearFunctor<DeviceType::OPENCL, T>::operator()(
params_generator, params_generator,
func, func,
&timer); &timer);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
template struct ResizeBilinearFunctor<DeviceType::OPENCL, float>; template struct ResizeBilinearFunctor<DeviceType::OPENCL, float>;
......
...@@ -50,12 +50,14 @@ void SpaceToBatchFunctor<DeviceType::OPENCL, float>::operator()(Tensor *space_te ...@@ -50,12 +50,14 @@ void SpaceToBatchFunctor<DeviceType::OPENCL, float>::operator()(Tensor *space_te
cl::NDRange(lws[0], lws[1], lws[2]), cl::NDRange(lws[0], lws[1], lws[2]),
nullptr, &event); nullptr, &event);
MACE_CHECK(error == CL_SUCCESS); MACE_CHECK(error == CL_SUCCESS);
future->wait_fn = [runtime, event](CallStats *stats) { if (future != nullptr) {
event.wait(); future->wait_fn = [runtime, event](CallStats *stats) {
if (stats != nullptr) { event.wait();
runtime->GetCallStats(event, stats); if (stats != nullptr) {
} runtime->GetCallStats(event, stats);
}; }
};
}
} }
} // namespace kernels } // namespace kernels
......
...@@ -42,5 +42,5 @@ for device in `adb devices | grep "^[A-Za-z0-9]\+[[:space:]]\+device$"| cut -f1` ...@@ -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} shell "mkdir -p $DEVICE_PATH"
adb -s ${device} push $CL_PATH $DEVICE_CL_PATH && \ adb -s ${device} push $CL_PATH $DEVICE_CL_PATH && \
adb -s ${device} push $BAZEL_BIN_PATH/$BIN_NAME $DEVICE_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 done
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册