mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-10 17:37:14 +00:00
compute forward and backward parallel for MLAS and not use_openmp (#457)
This commit is contained in:
parent
5d00b8b375
commit
360fc32db4
1 changed files with 7 additions and 10 deletions
|
|
@ -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>>(
|
||||
|
|
|
|||
Loading…
Reference in a new issue