Skip to content

Convolution Data Layout NHWC vs. NCHW #42

@lgrothh

Description

@lgrothh

Moin,

the tiled_conv_auto function from gemmini.h expects the inputs to be in NHWC and the weights to be in KhKwIO format, but the standard layout in PyTorch is NCHW for input/output tensors and OIKhKw for the weights.
Right now for testing I manually permute my input data to match the format expected by Gemmini which works, but it causes significant overhead so I was wondering how difficult it would be to make this a variable parameter?

I tried modifying the following lines in gemmini.h:

const elem_t * weights_slice = weights + (poch*kernel_dim*in_channels + kch*in_channels + krow_) * out_channels + kcol_;
[...]
const elem_t * in = input + (b*in_dim*in_dim + kch*in_channels  + ((irow+upad)>>input_dilated)) * in_dim  + ((icol+lpad)>>input_dilated);

But it does not work, I would appreciate any input on this
Best Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions