Unable to Build RKNN Model . Getting error AttributeError: 'list' object has no attribute 'dtype'

SO I have a model with input_name = [‘input_ids’, ‘style’,‘speed’] .
For clearly here is the ONNX creation Function

input_ids = torch.randint(1, 100, (48,)).numpy()
    input_ids = torch.LongTensor([[0, *input_ids, 0]])
    style = torch.randn(1, 256)
    speed = torch.randint(1, 10, (1,)).int()

    print("Input Ids = ",input_ids.shape)
    print("Style = ",style.shape)
    print("Speed = ",speed.shape)
    torch.onnx.export(
        model, 
        args = (input_ids, style, speed), 
        f = onnx_file, 
        export_params = True, 
        verbose = True, 
        input_names = [ 'input_ids', 'style', 'speed' ], 
        output_names = [ 'waveform', 'duration' ],
        opset_version = 19, 
        dynamic_axes = {
            'input_ids': { 1: 'input_ids_len' }, 
            'waveform': { 0: 'num_samples' }, 
        }, 
        do_constant_folding = True, 
    )

    print('export kokoro.onnx ok!')

Now here is My RKNN build function

if __name__ == '__main__':
    model_path, platform, do_quant, output_path = "onnx/kokoro.onnx" , "rk3588" , False , "onnx/kokoro.rknn" #parse_arg()

    input_shapes = {
        'input_ids':[1,50],
        'style':[1,256],
        'speed':[1]
    }
    input_name = ['input_ids',  'style','speed']
    input_size_list = [[1,50],[1,256],[1]]

    dynamic_shapes = [
        [[1, 50], [1, 256], [1]],  # First possible combination
        [[1, 100], [1, 256], [1]],  # Second possible combination
        [[1, 512], [1, 256], [1]]  # Third possible combination
    ]



    # Create RKNN object
    rknn = RKNN(verbose=True)

    # Pre-process config
    print('--> Config model')
    rknn.config(target_platform=platform,
                quantized_dtype="w8a8"
    ,dynamic_input = dynamic_shapes
                )

    print('done')

    # Load model
    print('--> Loading model')
    ret = rknn.load_onnx(model=model_path, input_size_list=input_size_list,
                         inputs=input_name,


                         )
    if ret != 0:
        print('Load model failed!')
        exit(ret)
    print('done')

    # Build model
    print('--> Building model')
    ret = rknn.build(do_quantization=do_quant)
    if ret != 0:
        print('Build model failed!')
        exit(ret)
    print('done')

    # Export rknn model
    print('--> Export rknn model')
    ret = rknn.export_rknn(output_path)
    if ret != 0:
        print('Export rknn model failed!')
        exit(ret)
    print('done')

    # Release
    rknn.release()

Still Getting error IN build stage

I rknn-toolkit2 version: 2.3.2
→ Config model
W config: Please make sure the model can be dynamic when enable ‘config.dynamic_input’!
I The ‘dynamic_input’ function has been enabled, the MaxShape is dynamic_input[2] = [[1, 512], [1, 256], [1]]!
The following functions are subject to the MaxShape:
1. The quantified dataset needs to be configured according to MaxShape
2. The eval_perf or eval_memory return the results of MaxShape
done
→ Loading model
W load_onnx: If you don’t need to crop the model, don’t set ‘inputs’/‘input_size_list’/‘outputs’!
I Loading : 0%| | 0/532 [00:00<?, ?I Loading : 92%|███████████████████████████████████████████▎ | 490/532 [00:00<00:00, 4895.22I Loading : 100%|███████████████████████████████████████████████| 532/532 [00:00<00:00, 3357.18it/s]
W load_onnx: The config.mean_values is None, zeros will be set for input 1!
W load_onnx: The config.std_values is None, ones will be set for input 1!
done
→ Building model
D base_optimize …
D base_optimize done.
D
D fold_constant …
I FoldConstant : 0%| | 0/3613 [00:00<?, ?I FoldConstant : 3%|█▎ | 120/3613 [00:00<00:02, 1194.05I FoldConstant : 7%|██▌ | 240/3613 [00:00<00:12, 275.86I FoldConstant : 9%|███▍ | 314/3613 [00:00<00:09, 350.57I FoldConstant : 11%|████ | 380/3613 [00:00<00:08, 393.42I FoldConstant : 12%|████▊ | 442/3613 [00:01<00:07, 412.52I FoldConstant : 14%|█████▍ | 499/3613 [00:01<00:07, 438.04I FoldConstant : 15%|██████ | 558/3613 [00:01<00:06, 472.44I FoldConstant : 17%|██████▋ | 618/3613 [00:01<00:05, 503.06I FoldConstant : 19%|███████▎ | 676/3613 [00:01<00:05, 500.28I FoldConstant : 20%|███████▉ | 731/3613 [00:01<00:05, 498.59I FoldConstant : 22%|████████▍ | 785/3613 [00:01<00:05, 490.61I FoldConstant : 23%|█████████▏ | 846/3613 [00:01<00:05, 506.53I FoldConstant : 25%|█████████▋ | 903/3613 [00:01<00:05, 523.34I FoldConstant : 26%|██████████▎ | 957/3613 [00:02<00:05, 514.94I FoldConstant : 28%|██████████▌ | 1010/3613 [00:02<00:05, 507.97I FoldConstant : 30%|███████████▏ | 1069/3613 [00:02<00:04, 529.02I FoldConstant : 31%|███████████▉ | 1130/3613 [00:02<00:04, 549.96I FoldConstant : 33%|████████████▍ | 1186/3613 [00:02<00:04, 546.27I FoldConstant : 35%|█████████████▏ | 1255/3613 [00:02<00:04, 585.52I FoldConstant : 36%|█████████████▊ | 1314/3613 [00:02<00:04, 540.62I FoldConstant : 38%|██████████████▍ | 1370/3613 [00:02<00:04, 544.32I FoldConstant : 39%|██████████████▉ | 1426/3613 [00:03<00:04, 456.27I FoldConstant : 41%|███████████████▋ | 1488/3613 [00:03<00:04, 486.01I FoldConstant : 43%|████████████████▏ | 1545/3613 [00:03<00:04, 450.84I FoldConstant : 43%|████████████████▎ | 1546/3613 [00:03<00:04, 471.84it/s]
E build: Traceback (most recent call last):
File “rknn/api/rknn_log.py”, line 344, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
File “rknn/api/rknn_base.py”, line 1990, in rknn.api.rknn_base.RKNNBase.build
File “rknn/api/graph_optimizer.py”, line 801, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
AttributeError: ‘list’ object has no attribute ‘dtype’

W build: ===================== WARN(4) =====================
E rknn-toolkit2 version: 2.3.2
Traceback (most recent call last):
File “rknn/api/rknn_log.py”, line 344, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
File “rknn/api/rknn_base.py”, line 1990, in rknn.api.rknn_base.RKNNBase.build
File “rknn/api/graph_optimizer.py”, line 801, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
AttributeError: ‘list’ object has no attribute ‘dtype’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

return self.rknn_base.build(do_quantization=do_quantization, dataset=dataset, expand_batch_size=rknn_batch_size, auto_hybrid=auto_hybrid)

File “rknn/api/rknn_log.py”, line 349, 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 344, in rknn.api.rknn_log.error_catch_decorator.error_catch_wrapper
File “rknn/api/rknn_base.py”, line 1990, in rknn.api.rknn_base.RKNNBase.build
File “rknn/api/graph_optimizer.py”, line 801, in rknn.api.graph_optimizer.GraphOptimizer.fold_constant
AttributeError: ‘list’ object has no attribute ‘dtype’

There are two potential issue that I can see here, one is that your onnx might be a taking a list or tuple of 3 np.ndarray, please export onnx as if it take a single np.ndarray and there it splits the input into 3 separate np.ndarrays for different purposes. Second, I see when you are using dynamic input, the dynamic_shapes contains a list of input sizes, but batch dimension is missing, add one extra list on each possible input shape, like if possible shapes are [1,3,256,256] & [1,3,300,300] then `dynamic_shapes = [ [[1,3,256,256]], [[1,3,300,300]] ]

let me know, if these two changes doesn’t work

The ONNX Model is fine.
Its take 2 inputs .
The issue arises When Onnx Model is BUild

While building rknn model graphs/configurations from onnx model, it requires to check inputs, outputs and data types and operations at each node. so it requires inputs to np.ndarray so that data type can be checked. But somewhere you are using list input. So I mentioned, it would be better to re-export onnx model which takes a single input as np.ndarray and then split and use it correspondingly.
please check input and output type of nodes in onnx graph. I suspected that the initial input only might be creating issue so I mentioned that. Also, I think dynamic parameters’ input should inside a list as I mentioned earlier. please refer to the documention for full guide on dynamic export here

Model takes three distinct INPUTS by Design

can you please first try exporting static onnx model then convert it to rknn model, so that we can check if it is the issue with dynamic export or something else.