Problem with conv+depthwise for oneDNN+ACL builds
Benchdnn convolution problems that have a depthwise convolution post-op (there are two variants of this post-op: dw_k3s1p1 and dw_k3s2p1) fail for the oneDNN+ACL build, however this happens although the main convolution primitive is running is a reference implemention.
For example, this fails in the execute code of the ACL-based gemm convolution primitive:
$ ./benchdnn -v10 --conv --attr-post-ops=dw_k3s1p1 ic32ih112oc64oh112kh1ph0
run: --conv --attr-post-ops=dw_k3s1p1 ic32ih112oc64oh112kh1ph0
oneDNN implementation: ref_fused_convolution:any:gemm:acl:gemm:ref
oneDNN implementation: ref_fused_convolution:any:gemm:acl:gemm:ref
Requested: 0.0501108 GB, benchdnn limit: 191.27 GB, CPU RAM capacity: 255.026 GB, GPU RAM capacity: 0 GB
benchdnn: /home/diabit01/oneDNN/src/common/primitive.hpp:239: const T* dnnl::impl::resource_mapper_t::get(dnnl::impl::resource_mapper_t::key_t*) const [with T = dnnl::impl::cpu::aarch64::acl_resource_t; dnnl::impl::resource_mapper_t::key_t = const dnnl::impl::primitive_t]: Assertion `primitive_to_resource_.count(p)' failed.
[1] 44640 abort (core dumped) ./benchdnn -v10 --conv --attr-post-ops=dw_k3s1p1 ic32ih112oc64oh112kh1ph0
But adding the --skip-impl flag to benchdnn results in the test being skipped, which suggests the library selects the reference implementation instead of the ACL one but somehow still ends up calling the gemm:acl::execute_forward.
$ ./benchdnn -v10 --conv --skip-impl=ref --attr-post-ops=dw_k3s1p1 ic32ih112oc64oh112kh1ph0
run: --conv --skip-impl=ref --attr-post-ops=dw_k3s1p1 ic32ih112oc64oh112kh1ph0
SKIPPED: oneDNN implementation: ref_fused_convolution:any:gemm:acl:gemm:ref
0:SKIPPED (SKIP_IMPL_HIT) __REPRO: --conv --skip-impl=ref --attr-post-ops=dw_k3s1p1 ic32ih112oc64oh112kh1ph0
tests:1 passed:0 skipped:1 mistrusted:0 unimplemented:0 failed:0 listed:0
total compute_ref: sum(s):0.00
I noticed the 'oneDNN implementation' name is a concatenation of all the primitives to be executed when running the benchdnn problem. As I currently understand it, this means the ref_fused_convolution primitive will create gemm:acl and gemm:ref and call their execute methods?
The error message Assertion `primitive_to_resource_.count(p)' failed suggests that the resource_mapper for our primitive doesn't exist? I spend some time trying to follow the codepath but am still confused about the flow of conv_dw_fusion::doit and how the acl_gemm_convolution_fwd_t::execute_forward ends up being called.
I was hoping you might have some ideas about what's going wrong here and could point me in the right direction with the debugging of this problem? Thank you!
Stacktrace:
#0 0x0000ffffbacc2c1c in raise () from /lib64/libc.so.6
#1 0x0000ffffbacb07a8 in abort () from /lib64/libc.so.6
#2 0x0000ffffbacbc2e8 in __assert_fail_base () from /lib64/libc.so.6
#3 0x0000ffffbacbc350 in __assert_fail () from /lib64/libc.so.6
#4 0x0000ffffbdd560cc in dnnl::impl::resource_mapper_t::get<dnnl::impl::cpu::aarch64::acl_resource_t> (this=0xaaaaaadd41a8, p=0xaaaaaadd3580) at /home/diabit01/oneDNN/src/common/primitive.hpp:239
#5 0x0000ffffbdd55ef8 in dnnl::impl::cpu::aarch64::acl_gemm_convolution_fwd_t<(dnnl_data_type_t)3, (dnnl_data_type_t)3, (dnnl_data_type_t)3, (dnnl_data_type_t)3>::execute_forward (this=0xaaaaaadd3580, ctx=...) at /home/diabit01/oneDNN/src/cpu/aarch64/acl_gemm_convolution.cpp:34
#6 0x0000ffffbd3b2534 in dnnl::impl::cpu::aarch64::acl_gemm_convolution_fwd_t<(dnnl_data_type_t)3, (dnnl_data_type_t)3, (dnnl_data_type_t)3, (dnnl_data_type_t)3>::execute (this=0xaaaaaadd3580, ctx=...) at /home/diabit01/oneDNN/src/cpu/aarch64/acl_gemm_convolution.hpp:150
#7 0x0000ffffbd34fc50 in dnnl::impl::cpu::ref_fused_convolution_fwd_t::execute (this=0xaaaaaaddbc70, ctx=...) at /home/diabit01/oneDNN/src/cpu/ref_fused_convolution.hpp:358
#8 0x0000ffffbd2bb1ac in dnnl_primitive::execute (this=0xaaaaaadd4180, ctx=...) at /home/diabit01/oneDNN/src/common/primitive.cpp:345
#9 0x0000ffffbd2e58e4 in dnnl_stream::enqueue_primitive (this=0xaaaaab15e7c0, primitive_iface=0xaaaaaadd4180, ctx=...) at /home/diabit01/oneDNN/src/common/stream.cpp:33
#10 0x0000ffffbd2ba4d0 in dnnl::impl::primitive_execute (primitive_iface=0xaaaaaadd4180, ctx=...) at /home/diabit01/oneDNN/src/common/primitive.cpp:140
#11 0x0000ffffbd2ba8b8 in dnnl_primitive_execute (primitive_iface=0xaaaaaadd4180, stream=0xaaaaab15e7c0, nargs=7, c_args=0xaaaaab15fe90) at /home/diabit01/oneDNN/src/common/primitive.cpp:227
#12 0x0000aaaaaab45be0 in primitive_executor (prim=0xaaaaaadd4180, stream=@0xffffffff7a28: 0xaaaaab15e7c0, dnnl_args=std::vector of length 7, capacity 7 = {...}) at /home/diabit01/oneDNN/tests/benchdnn/dnnl_common.cpp:310
#13 0x0000aaaaaab5252c in std::__invoke_impl<dnnl_status_t, dnnl_status_t (*&)(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&), dnnl_primitive*&, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&> (__f=@0xaaaaaadd7260: 0xaaaaaab45b98 <primitive_executor(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)>, __args#0=@0xaaaaaadd7268: 0xaaaaaadd4180, __args#1=@0xffffffff7a28: 0xaaaaab15e7c0, __args#2=std::vector of length 7, capacity 7 = {...}) at /usr/include/c++/8/bits/invoke.h:60
#14 0x0000aaaaaab51c98 in std::__invoke<dnnl_status_t (*&)(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&), dnnl_primitive*&, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&> (__fn=@0xaaaaaadd7260: 0xaaaaaab45b98 <primitive_executor(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)>, __args#0=@0xaaaaaadd7268: 0xaaaaaadd4180, __args#1=@0xffffffff7a28: 0xaaaaab15e7c0, __args#2=std::vector of length 7, capacity 7 = {...}) at /usr/include/c++/8/bits/invoke.h:95
#15 0x0000aaaaaab5110c in std::_Bind<dnnl_status_t (*(dnnl_primitive*, std::_Placeholder<1>, std::_Placeholder<2>))(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)>::__call<dnnl_status_t, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&, 0ul, 1ul, 2ul>(std::tuple<dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&>&&, std::_Index_tuple<0ul, 1ul, 2ul>) (this=0xaaaaaadd7260, __args=...) at /usr/include/c++/8/functional:400
#16 0x0000aaaaaab4fe28 in std::_Bind<dnnl_status_t (*(dnnl_primitive*, std::_Placeholder<1>, std::_Placeholder<2>))(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)>::operator()<dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&, dnnl_status_t>(dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&) (this=0xaaaaaadd7260, __args#0=@0xffffffff7a28: 0xaaaaab15e7c0, __args#1=std::vector of length 7, capacity 7 = {...}) at /usr/include/c++/8/functional:484
#17 0x0000aaaaaab4d8d0 in std::_Function_handler<dnnl_status_t (dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&), std::_Bind<dnnl_status_t (*(dnnl_primitive*, std::_Placeholder<1>, std::_Placeholder<2>))(dnnl_primitive*, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)> >::_M_invoke(std::_Any_data const&, dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&) (__functor=..., __args#0=@0xffffffff7a28: 0xaaaaab15e7c0, __args#1=std::vector of length 7, capacity 7 = {...}) at /usr/include/c++/8/bits/std_function.h:282
#18 0x0000aaaaaab4af34 in std::function<dnnl_status_t (dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)>::operator()(dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&) const (this=0xffffffff7aa8, __args#0=@0xffffffff7a28: 0xaaaaab15e7c0, __args#1=std::vector of length 7, capacity 7 = {...}) at /usr/include/c++/8/bits/std_function.h:687
#19 0x0000aaaaaab458e8 in execute_and_wait(std::function<dnnl_status_t (dnnl_stream* const&, std::vector<dnnl_exec_arg_t, std::allocator<dnnl_exec_arg_t> > const&)>&, dnnl_engine* const&, args_t const&) (exec_func=..., engine=@0xffffffff7a98: 0xaaaaaadb6440, args=...) at /home/diabit01/oneDNN/tests/benchdnn/dnnl_common.cpp:292
#20 0x0000aaaaaab45d70 in execute_and_wait (prim=0xaaaaaadd4180, args=...) at /home/diabit01/oneDNN/tests/benchdnn/dnnl_common.cpp:326
#21 0x0000aaaaaab1c3a0 in conv_dw_fusion::doit (prb=0xffffffff7ee0, res=0xffffffffe2f8) at /home/diabit01/oneDNN/tests/benchdnn/conv/conv_dw_fusion.cpp:516
#22 0x0000aaaaaaaffc50 in conv::check_correctness (s=...) at /home/diabit01/oneDNN/tests/benchdnn/conv/bench_conv.cpp:64
#23 0x0000aaaaaab00a88 in conv::bench (argc=1, argv=0xffffffffec90) at /home/diabit01/oneDNN/tests/benchdnn/conv/bench_conv.cpp:110
#24 0x0000aaaaaaac3c38 in main (argc=2, argv=0xffffffffec88) at /home/diabit01/oneDNN/tests/benchdnn/benchdnn.cpp:91
Hi @diaena, thank you for the question.
This is likely happens because top level implementation doesn't call create_resource(...) function for nested primitives which results in empty resource for nested acl implementation when a resource is actually needed.
It seems that making ref_fused_convolution implementation to call them may help.
This is a preliminary (not tested) patch that can give some pointers:
diff --git a/src/cpu/ref_fused_convolution.hpp b/src/cpu/ref_fused_convolution.hpp
index 26753d4..08a614f 100644
--- a/src/cpu/ref_fused_convolution.hpp
+++ b/src/cpu/ref_fused_convolution.hpp
@@ -321,6 +321,14 @@ struct ref_fused_convolution_fwd_t : public primitive_t {
return status::success;
}
+ status_t create_resource(
+ engine_t *engine, resource_mapper_t &mapper) const override {
+ for (auto &p : primitives_) {
+ CHECK(p->create_resource(engine, mapper));
+ }
+ return status::success;
+ }
+
status_t execute(const exec_ctx_t &ctx) const override {
engine_t *engine = ctx.stream()->engine();
const auto scratchpad = ctx.get_scratchpad_grantor();
It might resolve the issue completely, or open a can of worms. Please keep us posted! Thank you.
Hi @dzarukin, thanks!
The patch seems to fix the problem, thanks again.
Should I create a PR for this?
Hi @diaena, yes, please.
It will be also nice if whole create_resource call is wrapped in DNNL_AARCH64_USE_ACL macro since X64 doesn't need it so far. Thank you.
Closing as the PR with the fix is up now