AmpereComputingAI / ampere_model_library

AML's goal is to make benchmarking of various AI architectures on Ampere CPUs a pleasurable experience :)
https://hub.docker.com/u/amperecomputingai
Apache License 2.0
21 stars 6 forks source link

Add NHWC Pytorch torchvision models #154

Open kkontny opened 1 year ago

kkontny commented 1 year ago

Since new version Torchvision supports NHWC version of the models, please add the support to model zoo, they can be enabled with some flag like --nhwc.

Since we don't support it yet in Pytorch-dls, this is lower prio. https://github.com/AmpereComputingAI/pytorch-dls/issues/131

jan-grzybek-ampere commented 1 year ago

@kkontny this might require a lot of effort because of the need to train models ourself. What's available online for torch is largely NCHW as of today - @dkupnicki please estimate the effort needed and we should decide upon that. One suggestion on my side is looking into onnx conversion - we could take nhwc TF models and convert them to torch using ONNX format as intermediary

kkontny commented 1 year ago

@jan-grzybek-ampere Here: https://pytorch.org/blog/accelerating-pytorch-vision-models-with-channels-last-on-cpu/ they say you can convert normal model to NHWC with two liner, converting input and model to NHWC format: # convert input and model to channels last x = x.to(memory_format=torch.channels_last) model = model.to(memory_format=torch.channels_last)

Like I said I'd like this only for Torchvision models where this conversion is available.

jan-grzybek-ampere commented 1 year ago

Ok, thanks. @MarcelWilnicki can you please look into this?