1 报错描述

1.1 系统环境

Hardware Environment(Ascend/GPU/CPU): Ascend

Software Environment:

-- MindSpore version (source or binary): 1.6.0

-- Python version (e.g., Python 3.7.5): 3.7.6

-- OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic

-- GCC/Compiler version (if compiled from source):

1.2 基本信息

1.2.1 脚本

训练脚本是通过构建Pow的单算子网络,对第一个输入的每个值进行幂运算。脚本如下:

 01 class Net(nn.Cell):
 02   def __init__(self):
 03     super(Net, self).__init__()
 04     self.pow = ops.Pow()
 05   def construct(self, x,y):
 06     output = self.pow(x, y)
 07     return output
 08 net = Net()
 09 x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float64) .astype(mindspore.float32)
 10 y = 3.0
 11 output = net(x, y)
 12 print('output', output)
复制

1.2.2 报错

这里报错信息如下:

Traceback (most recent call last):
 File 'demo.py', line 11, in <module>
​    output = net(x, y)
…
TypeError: mindspore/ccsrc/runtime/device/ascend/kernel_select_ascend.cc:788 PrintNotMatchMessage] Can not select a valid kernel info for [Default/Pow-op0] in AI CORE or AI CPU kernel info candidates list:
AI CORE:
(<Int8xDefaultFormat>, <Int8xDefaultFormat>) -> (<Int8xDefaultFormat>)
(<UInt8xDefaultFormat>, <UInt8xDefaultFormat>) -> (<UInt8xDefaultFormat>)
(<Int32xDefaultFormat>, <Int32xDefaultFormat>) -> (<Int32xDefaultFormat>)
(<Float16xDefaultFormat>, <Float16xDefaultFormat>) -> (<Float16xDefaultFormat>)
(<Float32xDefaultFormat>, <Float32xDefaultFormat>) -> (<Float32xDefaultFormat>)
AI CPU:
{}
Please check the given data type or shape:
AI CORE:    : (<Tensor[Float64], (3)>, <Tensor[Float64], (), value=...>) -> (<Tensor[Float64], (3)>)
AI CPU:    : (<Tensor[Float64], (3)>, <Tensor[Float64], (), value=...>) -> (<Tensor[Float64], (3)>)
For more details, please refer to 'Kernel Select Failed' at https://www.mindspore.cn
The function call stack:
In file demo.py(06)/    output = self.pow(x, y)/
复制

原因分析

我们看报错信息,在TypeError中,写到Can not select a valid kernel info for [Default/Pow-op0] in AI CORE or AI CPU kernel info candidates list,结合后边列出的数据类型格式,不难猜出这是在提示传入的数据类型不在支持的类型范围内,支持的数据类型为:int8、uint8、int32、float16、float32,再结合*Please check the given data type or shape:AI CORE : (<tensor[float64], (3)="">*可知,传入的数据类型为float64, 检查代码发现,09行代码传入的数据类型确实为float64,此时需要将该类型转化为其他支持类型。

2 解决方法

基于上面已知的原因,很容易做出如下修改: 

 此时执行成功,输出如下:

output [ 1. 8. 64.]

3 总结

定位报错问题的步骤:

1、 找到报错的用户代码行: output = self.pow(x, y); 2、 根据日志报错信息中的关键字,缩小分析问题的范围; 3、需要重点关注变量定义、初始化的正确性。

4 参考文档

4.1 Pow算子API接口

 

Logo

鲲鹏昇腾开发者社区是面向全社会开放的“联接全球计算开发者,聚合华为+生态”的社区,内容涵盖鲲鹏、昇腾资源,帮助开发者快速获取所需的知识、经验、软件、工具、算力,支撑开发者易学、好用、成功,成为核心开发者。

更多推荐