Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RWKV-6 模型转换报错 The input tensor cannot be reshaped to the requested shape. Input shape:{1,2048,1,1}, requested shape:{1,32,64,64} (rknn-toolkit2 v2.2.0) #169

Open
happyme531 opened this issue Oct 9, 2024 · 2 comments

Comments

@happyme531
Copy link

模型和转换脚本和 #168 中的相同,toolkit2版本升级到v2.2.0之后又开始报另一个错误:

...
D     convert_exmatmul_to_conv: remove node = ['/blocks.23/ffn_key/MatMul'], add node = ['/blocks.23/ffn_key/MatMul']
D     convert_exmatmul_to_conv: remove node = ['/head/MatMul'], add node = ['/head/MatMul']
D     fold_constant ...
I        FoldConstant :   0%|                                              | 0/1885 [00:00<?, ?it/s]2024-10-09 20:55:45.093023561 [E:onnxruntime:, sequential_executor.cc:514 ExecuteKernel] Non-zero status code returned while running Reshape node. Name:'/blocks.0/MatMul_4_output_0_mm-rs' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{1,2048,1,1}, requested shape:{1,32,64,64}

I        FoldConstant :   2%|▊                                   | 40/1885 [00:00<00:04, 429.97it/s]
E build: Traceback (most recent call last):
  File "rknn/api/rknn_log.py", line 309, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
  File "rknn/api/rknn_base.py", line 1936, in rknn.api.rknn_base.RKNNBase.build
  File "rknn/api/graph_optimizer.py", line 2204, in rknn.api.graph_optimizer.GraphOptimizer.fuse_ops
  File "rknn/api/graph_optimizer.py", line 976, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
  File "rknn/api/session.py", line 150, in rknn.api.session.Session.run
  File "/home/zt/.conda/envs/rknn/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 220, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'/blocks.0/MatMul_4_output_0_mm-rs' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{1,2048,1,1}, requested shape:{1,32,64,64}


W build: ===================== WARN(11) =====================
E rknn-toolkit2 version: 2.2.0
Traceback (most recent call last):
  File "rknn/api/rknn_log.py", line 309, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
  File "rknn/api/rknn_base.py", line 1936, in rknn.api.rknn_base.RKNNBase.build
  File "rknn/api/graph_optimizer.py", line 2204, in rknn.api.graph_optimizer.GraphOptimizer.fuse_ops
  File "rknn/api/graph_optimizer.py", line 976, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
  File "rknn/api/session.py", line 150, in rknn.api.session.Session.run
  File "/home/zt/.conda/envs/rknn/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 220, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'/blocks.0/MatMul_4_output_0_mm-rs' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{1,2048,1,1}, requested shape:{1,32,64,64}


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./convert_rknn.py", line 47, in <module>
    ret = rknn.build(do_quantization=QUANTIZE, dataset=DATASET, rknn_batch_size=None)
  File "/home/zt/.conda/envs/rknn/lib/python3.8/site-packages/rknn/api/rknn.py", line 192, in build
    return self.rknn_base.build(do_quantization=do_quantization, dataset=dataset, expand_batch_size=rknn_batch_size)
  File "rknn/api/rknn_log.py", line 314, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
  File "rknn/api/rknn_log.py", line 95, in rknn.api.rknn_log.RKNNLog.e
ValueError: Traceback (most recent call last):
  File "rknn/api/rknn_log.py", line 309, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
  File "rknn/api/rknn_base.py", line 1936, in rknn.api.rknn_base.RKNNBase.build
  File "rknn/api/graph_optimizer.py", line 2204, in rknn.api.graph_optimizer.GraphOptimizer.fuse_ops
  File "rknn/api/graph_optimizer.py", line 976, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
  File "rknn/api/session.py", line 150, in rknn.api.session.Session.run
  File "/home/zt/.conda/envs/rknn/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 220, in run
    return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Reshape node. Name:'/blocks.0/MatMul_4_output_0_mm-rs' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:44 onnxruntime::ReshapeHelper::ReshapeHelper(const onnxruntime::TensorShape&, onnxruntime::TensorShapeVector&, bool) input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{1,2048,1,1}, requested shape:{1,32,64,64}

看起来是图优化器的问题。

@zen-xingle
Copy link

是的,这个问题看起来是图优化导致的异常。从log无法判断具体的错误代码,需要有模型复现才比较好定位修复了

@happyme531
Copy link
Author

是的,这个问题看起来是图优化导致的异常。从log无法判断具体的错误代码,需要有模型复现才比较好定位修复了

拿这个不带权重的模型试试? 权重太大没上传 https://github.com/user-attachments/files/17308486/check0_base_optimize.onnx.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants