kendryte / nncase

Open deep learning compiler stack for Kendryte AI accelerators ✨
Apache License 2.0
752 stars 183 forks source link

error: Result too large #575

Closed wendemelb closed 2 years ago

wendemelb commented 2 years ago

When I compile and run the 20class_yolo_example on k210. It gives me an error.

============================================ LCD init system start [..m/runtime_module.cpp:65 (shape_reg)] id < shaperegs.size() = false (bool) error: Result too large

Code: https://github.com/kendryte/nncase/tree/master/examples/20classes_yolo/k210/kpu_20classes_example Model: https://github.com/kendryte/nncase/blob/master/examples/20classes_yolo/model/20classes_yolo.tflite Script: https://github.com/kendryte/nncase/blob/master/docs/USAGE_EN.md#compile-uint8-model-for-tflite I changed the input shape to [1,240,320,3] and added: compile_options.input_type = 'uint8'

Is something I did wrong? Could anyone give me the correct script that can compile this tflite model to kmodel? thanks.

Environment

sunnycase commented 2 years ago

Did you update the runtime?

wendemelb commented 2 years ago

I'm using this runtime https://github.com/kendryte/nncase/releases/download/v1.5.0/nncaseruntime-k210.zip

curioyang commented 2 years ago

@windymelb Did you set compile_option.preprocess is TRUE?

curioyang commented 2 years ago

@windymelb If you want to change input shape, you need to use this compile_options and set ptq options.

compile_options

compile_options = nncase.CompileOptions()
compile_options.target = target
compile_options.input_type = 'uint8'  # or 'uint8' 'int8'
compile_options.preprocess = True # if False, the args below will unworked
compile_options.swapRB = False
compile_options.input_shape = [1,240,320,3] # keep layout same as input layout
compile_options.input_layout = 'NHWC'
compile_options.output_layout = 'NHWC'
compile_options.mean = [0,0,0]
compile_options.std = [1,1,1]
compile_options.input_range = [0,1]
compile_options.letterbox_value = 114. # pad what you want
compile_options.dump_ir = True
compile_options.dump_asm = True
compile_options.dump_dir = 'tmp'

BTW if you change the input_shape, it will use letter_box function rather than Resize.

curioyang commented 2 years ago

If any questions, reopen this issue.