onnx2tflite icon indicating copy to clipboard operation
onnx2tflite copied to clipboard

Can some outputs remain in NCHW format during the conversion, instead of changing to NHWC?

Open surprise2001 opened this issue 1 year ago • 3 comments

For example, when I convert a model, the original input shape is [1,1,7680], but after conversion, the shape becomes [1,7680,1]. Although I can initialize the data with the corresponding shape when using the model to perform inference without affecting the results, I still want to know if there's a way to avoid modifying the original shape.

surprise2001 avatar Nov 04 '24 03:11 surprise2001

5A2A038B-94F4-4fc2-8431-3B91D2CA9E1D

surprise2001 avatar Nov 04 '24 04:11 surprise2001

我有看到有个issues是说了相关的,说是输出之后再转置,那有没有办法就是在做转换的时候就不做那个变换,仍然保持NCHW

surprise2001 avatar Nov 04 '24 06:11 surprise2001

I think it's completely feasible, you should make some change at file(utils/graph_tools.py#35, function build_tf_inputs), make input's layout to FORCE_CHANNEL_FIRST_OP.

MPolaris avatar Nov 05 '24 01:11 MPolaris