2.4K Star 8.2K Fork 4.4K

GVPMindSpore / mindspore

 / 详情

mindspore.ops.sum在bool类型时与torch.sum返回结果不一致,有误

DONE
Bug-Report
创建于  
2023-08-26 12:09
name about labels
Bug Report Use this template for reporting a bug kind/bug

Environment

Hardware Environment(Ascend/GPU/CPU):

Uncomment only one /device <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/device gpu

Software Environment:

  • MindSpore version (source or binary): 2.1.0
  • Python version (e.g., Python 3.7.5): 3.7.13
  • OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04.6 LTS
  • GCC/Compiler version (if compiled from source):

Describe the current behavior

mindspore.ops.sum在bool类型时与torch.sum返回结果不一致,有误

Describe the expected behavior

API映射表表明其mindspore.ops.sum与torch.sum返回结果一致,有误导性

Steps to reproduce the issue

测试代码如下:

import numpy as np
import torch
from mindspore import Tensor, ops
from mindspore import dtype as mstype

input = np.array([[True, False, False, True, True], [True, False, False, True, True], [True, False, False, True, True],
               [True, False, False, True, True], [True, False, False, True, True], [True, False, False, True, True],
               [True, False, False, True, True], [True, False, False, True, True], [True, False, False, True, True]])

m_x = Tensor(input, mstype.bool_)
t_x = torch.tensor(input, dtype=torch.bool)

m_out = ops.sum(m_x, dim = 0)
t_out = torch.sum(t_x, dim = 0)

print(m_out, t_out)

m_out = ops.sum(m_x, dim = 1)
t_out = torch.sum(t_x, dim = 1)

print(m_out, t_out)

Related log / screenshot

[ True False False True True] tensor([9, 0, 0, 9, 9])
[ True True True True True True True True True] tensor([3, 3, 3, 3, 3, 3, 3, 3, 3])

Special notes for this issue

请问其不一致是设计算子的本意吗?API映射表注明“功能一致,参数名不同”是否存在误导?

评论 (6)

Runjia Zeng 创建了Bug-Report

Please assign maintainer to check this issue.
请为此issue分配处理人。
@fangwenyi @chengxiaoli @Shawny

感谢您的反馈,您可以评论//mindspore-assistant更快获取帮助,更多标签可以查看标签列表

  1. 如果您刚刚接触MindSpore,或许您可以在教程找到答案
  2. 如果您是资深Pytorch用户,您或许需要:
    与PyTorch典型区别 / PyTorch与MindSpore API映射表
  3. 如果您遇到动态图问题,可以设置mindspore.set_context(pynative_synchronize=True)查看报错栈协助定位
  4. 模型精度调优问题可参考官网调优指南
  5. 如果您反馈的是框架BUG,请确认您在ISSUE中提供了MindSpore版本、使用的后端类型(CPU、GPU、Ascend)、环境、训练的代码官方链接以及可以复现报错的代码的启动方式等必要的定位信息
  6. 如果您已经定位出问题根因,欢迎提交PR参与MindSpore开源社区,我们会尽快review
Shawny 负责人设置为qinzheng
Shawny 关联项目设置为MindSpore Issue Assistant
Shawny 计划开始日期设置为2023-08-26
Shawny 计划截止日期设置为2023-09-26
Shawny 添加了
 
mindspore-assistant
标签
Shawny 添加了
 
sig/ops
标签
Shawny 添加了
 
kind/bug
标签
Shawny 任务状态TODO 修改为WIP
Shawny 优先级设置为次要
Shawny 添加了
 
v2.1.0
标签

你好,问题已复现,目前相关责任人正在分析

Shawny 里程碑设置为B-SIG-MSLite

和相宜沟通影响可控,遗留到2.2版本解决

weiyang 移除了
 
v2.1.0
标签
weiyang 添加了
 
v2.2.0
标签
weiyang 移除了
 
v2.2.0
标签
weiyang 添加了
 
v2.2.0
标签

Appearance & Root Cause

最新master版本已经修复,gpu结果与torch一致

Fix Solution

Fix Description & Test Suggestion

torch.sum与ops.sum api差异说明修改为一致
https://e.gitee.com/mind_spore/repos/mindspore/docs/pulls/12963

Self-test Report & DT Review

输入图片说明

Suggested regression version

9月21日的master版本

i-robot 添加了
 
foruda
标签
qinzheng 移除了
 
foruda
标签
qinzheng 添加了
 
rct/oldrelease
标签
qinzheng 添加了
 
rca/codespec
标签
qinzheng 添加了
 
ctl/componenttest
标签
qinzheng 添加了
 
ctl/componenttest
标签
qinzheng 添加协作者qinzheng
qinzheng 负责人qinzheng 修改为Shawny

您好,该问题已修复,您可以编译master分支代码使用或等待MindSpore发布下一个版本通过官网whl包安装使用,如您仍有疑问可将问题单状态改为WIP,我们会进一步跟踪

Shawny 任务状态WIP 修改为DONE

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(5)
8108889 shawny233 1628167362 9063711 runjiaz 1703062534
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore

搜索帮助