oneDNN icon indicating copy to clipboard operation
oneDNN copied to clipboard

Data Format of weights in FCLayer

Open pranathibl opened this issue 6 years ago • 2 comments

Hi,

Weights to the FCLayer are in 'iohw' and i am creating a memory descriptor with Data Format 'any'. When i am comparing data format of weights descriptor expected by FCLayer after configuring the FCLayer with the 'iohw' memory descriptor, For BatchSize 1 it is same and does not need any reordering. But from BatchSize 2, expected is not iohw and is needed to be reordered.

Can you tell me in what format these weights would be expected by layer(other than iohw), and why it is not the same for BatchSize 1?

Thanks, Pranathi.

pranathibl avatar Jul 19 '20 13:07 pranathibl

Hi @pranathibl, In case FC is created with any memory format for src and weights, one should expect formats to be used as written in set_default_params() function defined here: https://github.com/oneapi-src/oneDNN/blob/f47ffe9a549a28537e95fefadbcdb2ceb3e7bcd6/src/cpu/cpu_inner_product_pd.hpp#L162-L196

There is a comment why MB=1 case is different from others:

/* With batch = 1, no transpose to use the faster gemv kernels. Otherwise, we transpose the weights to improve efficiency of no-copy kernels */.

The primary goal of format changing is calling faster GEMM kernels, thus leading for better performance overall.

dzarukin avatar Jul 20 '20 19:07 dzarukin

Closing issue due to lack of activity. Feel free re-open or create a new one.

dzarukin avatar Jul 30 '20 19:07 dzarukin