Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Hackathon No.15】为 Paddle 新增 count_nonzero #167

Merged
merged 2 commits into from
Jul 7, 2022

Conversation

thunder95
Copy link
Contributor

为 Paddle 新增 count_nonzero

# 二、飞桨现状
目前paddle缺少相关功能实现。

API方面,已有相关功能的API,[paddle.nansum](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/tensor/math.py#L910), 由于容易实现,所以在Paddle中是一个由其他API组合成的API,没有实现自己的OP,其主要实现逻辑为:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21行和23行不是很通顺,需要再组织下:

  1. “目前paddle缺少相关功能实现”,和“所以在Paddle中是一个由其他API组合成的API,没有实现自己的OP”,不能对应。是否可以明确为:可以由其他API组合成的API,不需要实现自己的OP?
  2. 这里引入nansum是为什么呢?是因为实现方式类似?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luotao1 已修改

# 六、测试和验收的考量
测试考虑的case如下:

- 和numpy结果的数值的一致性, `paddle.nanmean`,和`np.nanmean`结果是否一致;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

``paddle.nanmean,和np.nanmean`结果是否一致`这句是忘记删了?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luotao1 已修改

- 参数`axis`为int,tuple和list时输出的正确性;
- `keepdim`参数的正确性;
- 未输入维度时的输出正确性;
- 测试在进行反向梯度计算时结果的正确性(包含nan值和非nan值位置的梯度);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(包含nan值和非nan值位置的梯度)的原因是什么呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luotao1 已修改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants