MindSpore训练报错TypeError: Invalid Kernel Build Info! Kernel type: AICPU_KERNEL, node: Default/Concat-op1

1. 系统环境

硬件环境(Ascend/GPU/CPU): Ascend 910
MindSpore版本: mindspore=2.2.0
执行模式(PyNative/ Graph):PyNative
Python版本: Python=3.8.15
操作系统平台: linux

2. 报错信息

训练脚本报错:

TypeError: Invalid Kernel Build Info! Kernel type: AICPU_KERNEL, node: Default/Concat-op1

开pynative sync之后,报错信息增加:

(<int64xdefaultformat>, <boolxdefaultformat>, <boolxdefaultformat>, <boolxdefaultformat>, <boolxdefaultformat>, <boolxdefaultformat>, <boolxdefaultformat>, <boolxdefaultformat>, object_type: [Tensor,Tensor,Tensor,Tensor,Tensor,Tensor,Tensor,Tensor]) -> (<boolxdefaultformat>, object_type: [Tensor], kernel_type: AICPU_KERNEL, op_type: UNKNOWN_OP_TYPE)</boolxdefaultformat></boolxdefaultformat></boolxdefaultformat></boolxdefaultformat></boolxdefaultformat></boolxdefaultformat></boolxdefaultformat></boolxdefaultformat></int64xdefaultformat>

3. 根因分析

所有的Concat算子都不支持Bool类型的Tensor。报错不清晰,根据日志内容无法获得类型不支持的根本错因。

4. 解决方案

将需要做concat的数据先转换为int32,然后做Concat处理。例如:

list_int = []  
    for item in list_int :  
    list_int .append(mindspore.ops.Cast()(item, mindspore.int32))  
    print(list_int)