Is there any way that can convert a data format of .pb file from NCHW into NHWC?
I have a CNN model which was trained in Pytorch based on the data format N(batch) x C(channel) x H(height) x W(width). I saved the pre-trained model as model.pth. Afterward, I converted the pre-trained model from model.pth -> model.onnx by using existing function: 

torch.onnx.export(model, dummy_input, "model.onnx")


And then, I converted this model.onnx -> model.pb by the module below:

import onnx
from onnx_tf.backend import prepare 

model_onnx = onnx.load('model.onnx')
tf_rep = prepare(model_onnx)
tf_rep.export_graph('model.pb')


The problem is: I want to utilize this model.pb on a CPU device, which needs a NHWC data format. However, my model is based on NCHW data format. Is there any method that can convert the data format of this model.pb from NCHW into NHWC?

Short answer, you are in a tough spot.
Long answer, it's difficult yet possible. What makes your problem difficult is your graph is already trained. It is inefficient, yet easier to convert NCHW-&gt;NHWC while you create the training graph. See similar answer here and here.
Now to your answer, you'll have to overload conv2D operator with custom convolution operator. Here is a pseudo code to get started.
   tensor Conv2D(X, W, B) {
     int perm[] = {0, 3, 1, 2};
     X = transposeTensor(X, perm);
     W = transposeTensor(W, perm);
     Y = Conv2D_orig(X, W, B, ...) ;
     perm = {0, 2, 3, 1};
     return transposeTensor(Y, perm);
   }

