---
title: 在模型运行时遇到告警“current tensor is running as_strided, don't perform inplace operations on the returned va
description: (待补充)
keywords: 在模型运行时,遇到告警,昇腾社区,问题现象描述,原因分析,解决措施,PyTorch,UserWarning
url: https://www.hiascend.com/document/caselibrary/detail/ptacase_0040
section: (其他)
---

# 在模型运行时遇到告警“current tensor is running as_strided, don't perform inplace operations on the returned va

URL: https://www.hiascend.com/document/caselibrary/detail/ptacase_0040
描述: (待补充)
关键词: 在模型运行时,遇到告警,昇腾社区,问题现象描述,原因分析,解决措施,PyTorch,UserWarning

昇腾文档 [了解详情](https://www.hiascend.com/document)

故障案例 [了解详情](https://www.hiascend.com/document/caselibrary)

在模型运行时遇到告警“current tensor is running as_strided, don't perform inplace operations on the returned value.”

在模型运行时遇到告警“current tensor is running as_strided, don't perform inplace operations on the returned value.”

2025/03/18

671

问题信息

| 问题来源 | 产品大类 | 产品子类 | 关键字 |
| --- | --- | --- | ---|
| 官方 | 模型训练 | PyTorch | -- |

#### 问题现象描述

- 报错截图
- 报错文本

```
2.py:10: UserWarning: current tensor is running as_strided, don't perform inplace operations on the returned value. If you encounter this warning and haveprecision issues, you can try torch.npu.config.allow_internal_format = False to resolve precision issues. (Triggered internally at build/CMakeFiles/torch_npu.dir/compiler_depend.ts:123.)
  b[:, :, :, :, 0] = tmp3
```

#### 原因分析

在Ascend Extension for PyTorch中，一些私有格式不支持as_strided，因此私有格式进行as_strided之后，也不支持inplace操作。 如上图所示，打屏信息中如果出现以上告警信息，说明对返回值不应进行inplace操作。

如果用户不主动调用torch_npu.npu_format_cast对私有格式的tensor进行转化，私有格式的tensor一般由卷积类算子输出产生，如conv1d，conv2d，conv3d，_convolution等。

#### 解决措施

如果看到此告警信息，且存在精度问题时，可通过torch.npu.config.allow_internal_format = False私有格式解决。私有格式后，所有算子将不会产生私有格式的tensor，对性能有一定影响。

本页内容

- 问题信息
- 问题现象描述
- 原因分析
- 解决措施
