MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. Hope this tool can help you.
Apache License 2.0
526 stars 42 forks source link

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

Open surprise2001 opened 3 weeks ago

surprise2001 commented 3 weeks ago

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 commented 3 weeks ago

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

surprise2001 commented 3 weeks ago

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

MPolaris commented 3 weeks ago

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.