Samsung / ONE

On-device Neural Engine
Other
437 stars 157 forks source link

[one-optimize] shape changed <-1x...> to <0x...> after pad op #13573

Open zetwhite opened 3 months ago

zetwhite commented 3 months ago

What?

While converting mobileNetV2 tflite to circle file, ? 0 appeared in the shape of Pad's output.

How to reproduce

seanshpark commented 3 months ago

suddenly ? appeared in output of pad shape

Have you recently updated Netron? Or, do you have circle model without ? ?

zetwhite commented 3 months ago

I also checked circledump log, and the output of pad is <0X113x113x96> in the log. It looks like 0 is expressed as ? in netron.

➜ circledump mv2.opt.circle | grep -A 5 PAD 

O(0:4) PAD 
    I T(0:12) mobilenetv2_1.00_224/block_1_expand_relu/Relu6;mobilenetv2_1.00_224/block_1_expand_BN/FusedBatchNormV3;mobilenetv2_1.00_224/block_12_project/Conv2D;mobilenetv2_1.00_224/block_1_expand/Conv2D
    I T(0:13) mobilenetv2_1.00_224/block_13_pad/Pad/paddings
    O T(0:14) mobilenetv2_1.00_224/block_1_pad/Pad
➜ circledump mv2.opt.circle | grep 'T(0:14) FLOAT32'
T(0:14) FLOAT32 (0, 113, 113, 96) B(15) mobilenetv2_1.00_224/block_1_pad/Pad
zetwhite commented 3 months ago

Have you recently updated Netron?

No, I didn't update Netron, recently.

Or, do you have circle model without ?

Before running one-optimize, the circle model does not have ?.

seanshpark commented 3 months ago

you could download and reproduce it mobile_net.zip

from attached tflite file, I see it begins with unknown

image

I am using Netron 7.8.1, Windows version.

with circle file from tflite2cicle,

circledump gave me

Operands: T(subgraph index : tensor index) TYPE (shape) (shape_signature) B(buffer index) (variable) OperandName
T(0:0) FLOAT32 (1, 224, 224, 3) (-1, 224, 224, 3) B(1) serving_default_input_1:0

where -1 in (-1, 224, 224, 3) is for unknown.

zetwhite commented 3 months ago

Thank you for checking. If you don't mind could you check the shape of mv2.opt.circle (optimized circle)?

I figured out my netron version is old ( I used netron 7.4... ). And when I checked with https://netron.app (netron 7.8.1), -1 changed to 0 after pad op.

(+) I changed this issue's title, because I figured out that the problem is that the shape changed -1 to 0 after pad node. ? or 1 .. is just from netron version. sorry for confusion.

seanshpark commented 3 months ago

-1 changed to 0 after pad op.

Yes, reproduced. I'll analysis the cause...

seanshpark commented 3 months ago

Current implementation has a bug with unknown shape. it doesn't check it's status(unknown/known). Main cause is that circle we are (only) interested with known shapes (for our NPU backend).

I assume there will be other Ops that will have this same error.

Are you urgent with this issue? If not, fix will go with low urgency.

zetwhite commented 3 months ago

Are you urgent with this issue? If not, fix will go with low urgency.

It is NOT urgent. Fixing it slowly doesn't problem at all.

zetwhite commented 3 months ago

This issue might be related - https://github.com/samsung/one/issues/5683

shs-park commented 2 months ago

This issue might be related to #13697