---
title: Random.InvalidDType问题的解决办法
description: "测试程序onnxruntime_test_all提示Random.InvalidDType用例失败。"
url: https://www.hikunpeng.com/document/detail/zh/SRA/ecosystemEnable/ONNXRuntime/kunpengonnxruntime_02_0016.html
sourcePath: /source/zh/SRA/ecosystemEnable/ONNXRuntime/kunpengonnxruntime_02_0016.html
indexId: 1a17d1fe9d33ad1be21bcb3251c12fe45fc13cd5f03b1462ffe81281705adcd874
---
# Random.InvalidDType问题的解决办法

#### 问题现象描述

测试程序onnxruntime_test_all提示Random.InvalidDType用例失败。


#### 关键过程、根本原因分析

不同环境平台下，错误信息字符串内容不完全一致引发断言失败。

ONNX Runtime预期错误信息：“Attribute dtype does not specify a valid type in .”。

环境给出的实际错误信息：“Attribute dtype does not specify a valid type.”（少了“in .”）。


#### 结论、解决方案及效果

1. 打开“/path/to/ONNX_Runtime/onnxruntime/test/providers/cpu/generator/random_test.cc”文件。

```
vi /path/to/ONNX_Runtime/onnxruntime/test/providers/cpu/generator/random_test.cc
```


2. 按“:”进入命令行模式，并输入显示行数的命令set nu，再按“Enter”。

```
:set nu
```


3. 按“i”进入编辑模式，将第181、197、213、229行的“Attribute dtype does not specify a valid type in .”改为“Attribute dtype does not specify a valid type.”。
4. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
5. 重新编译并验证，请参见编译安装源码与运行和验证。
