When format_tag is defined for eltwise primitive descriptor?
Good afternoon.
oneDNN supports eltwise primitive, which has the corresponding primitive descriptor. The latter contains memory descriptor data_md_. May you please comment, can this data_md_ match format_tag::any? Is it acceptable to create eltwise_pd, for example, as follows:
auto src_md = memory::desc(src_dims, memory::data_type::f32, memory::format_tag::any);
auto eltwise_d = eltwise_forward::desc(prop_kind::forward_training,
algorithm::eltwise_relu, src_md, 0.f, 0.f);
or in the case of eltwise primitive descriptor some definite tag has to be chosen for src_md/dst_md?
Best regards, Aleksandr
Hi @alenik01 , In oneDNN primitives like convolution and matmul are the one which can choose tag based on implementation, because they are relatively heavy on model level and their performance depends on memory layouts. Other primitives should take memory from these primitives and compute on it directly to avoid unnecessary reorders in execution flow. Eltwise primitive is considered as a light-weight operation so it is more beneficial to work directly on the memory which comes from previous primitive in a model and to not introduce data reorders (adding any to many primitives also complicates framework integration, because each primitive might choose it's own layout, which is not aligned with the previous and the next primitive in the model).
May I ask what is the reason for adding format_tag::any for eltwise primitive?
Regards, Igor Safonov
Good morning, @igorsafo .
Other primitives should take memory from these primitives and compute on it directly to avoid unnecessary reorders in execution flow.
This is what I wanted to confirm, many thanks for explaining.
May I ask what is the reason for adding format_tag::any for eltwise primitive?
I didn't suggest to do it, just wanted to check that any is not intended for eltwise.
Best wishes, Aleksandr