support nc dataformat for lrn
Hi,
Incase of mnist which has fc->lrn->fc we are unable to pass the fc output memory primitive of data format nc to lrn , since the lrn does not have nc implementation it is failing during the setup.
It would be helpful if you could add the nc support for lrn. As of now we have implemented a workaround checking if the format is nc then creating a new primitive with nchw and executing the lrn layer in nchw format.
Thanks
It seems a really specific use case. Is it possible for you to create the fc primitive with output format 'nchw'? then you wouldn't need to create new primitive with nchw,
@shelleygoel, I am afraid the destination memory of fc is always nc...
The only current possible solution is to re-create memory with adjusted memory layout:
auto fc_dst_nc_memory_desc = mkldnn::memory_desc({n, c}, mkldnn::nc, mkldnn::f32);
auto fc_dst_nc = mkldnn::memory(fc_dst_nc_memory_desc); // will allocate memory
fc_dst_nc = fc(src, wei);
auto lrn_src_nchw_memory_desc = mkldnn::memory_desc({n, c, 1, 1}, mkldnn::nchw, mkldnn::f32);
// do not reallocate memory, just use the raw pointer from fc_dst_nc memory
// this is like a reshape -- we don't change/relayout the data
// we just 'rethink' {n, c} memory as {n, c, 1, 1}
auto lrn_src_nchw = mkldnn::memory(lrn_src_nchw_memory_desc, fc_dst_nc.get_data_handle());
// proceed with regular LRN creation and run