compute forward and backward parallel for MLAS and not use_openmp (#457)

This commit is contained in:
Yufeng Li 2019-02-08 17:20:45 -08:00 committed by GitHub
parent 5d00b8b375
commit 360fc32db4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -383,15 +383,14 @@ Status DeepCpuGruOp::ComputeImpl(OpKernelContext& context) const {
gsl::span<T> hidden_output_2 = hidden_output.subspan(hidden_output_size_per_direction,
hidden_output_size_per_direction);
#ifndef USE_MKLDNN
#if defined(USE_MLAS) && !defined(USE_OPENMP)
#ifdef USE_EIGEN_THREADPOOL
auto fn =
#else
std::packaged_task<void()> task_fw{
#endif
[&]() {
#endif // ! USE_MKLDNN
#endif // USE_MLAS && ! USE_OPENMP
std::unique_ptr<detail::UniDirectionalGru<T>> fw = std::make_unique<detail::UniDirectionalGru<T>>(
alloc, logger,
seq_length, batch_size, input_size, hidden_size_, linear_before_reset_, Direction::kForward,
@ -400,8 +399,8 @@ Status DeepCpuGruOp::ComputeImpl(OpKernelContext& context) const {
activation_funcs_.Entries()[1],
clip_, ttp_);
fw->Compute(input, sequence_lens_span, num_directions_, input_weights_1, recurrent_weights_1, output_1, hidden_output_1);
#ifndef USE_MKLDNN
#if defined(USE_MLAS) && !defined(USE_OPENMP)
#ifndef USE_EIGEN_THREADPOOL
}
};
@ -420,8 +419,7 @@ Status DeepCpuGruOp::ComputeImpl(OpKernelContext& context) const {
cv.notify_one();
});
#endif // USE_EIGEN_THREADPOOL
#endif // ! USE_MKLDNN
#endif // USE_MLAS && ! USE_OPENMP
std::unique_ptr<detail::UniDirectionalGru<T>> bw = std::make_unique<detail::UniDirectionalGru<T>>(
alloc, logger,
@ -432,15 +430,14 @@ Status DeepCpuGruOp::ComputeImpl(OpKernelContext& context) const {
clip_, ttp_);
bw->Compute(input, sequence_lens_span, num_directions_, input_weights_2, recurrent_weights_2, output_2, hidden_output_2);
#ifndef USE_MKLDNN
#if defined(USE_MLAS) && !defined(USE_OPENMP)
#ifdef USE_EIGEN_THREADPOOL
auto ul = std::unique_lock<OrtMutex>(lock);
if (!done) cv.wait(ul);
if (!done) cv.wait(ul);
#else
task_results_fw.get();
#endif
#endif // ! USE_MKLDNN
#endif // USE_MLAS && ! USE_OPENMP
} // namespace onnxruntime
else {
std::unique_ptr<detail::UniDirectionalGru<T>> gru_p = std::make_unique<detail::UniDirectionalGru<T>>(