-
Notifications
You must be signed in to change notification settings - Fork 178
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
【Paddle Toolkit Development Competition No.4】 Paddle 适配 torch-scatter #1028
base: develop
Are you sure you want to change the base?
Conversation
Thanks for your contribution! |
这个是否可以提交一个PR到paddle呢?应该只要把这几个类型添加到算子的注册宏里面就行了吧?而且比如 |
) | ||
|
||
index = broadcast(index, src, dim) | ||
eps = paddle.to_tensor(eps, dtype=src.dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
定义常量Tensor,建议使用full代替to_tensor
eps = paddle.to_tensor(eps, dtype=src.dtype) | |
eps = paddle.full([], eps, dtype=src.dtype) |
|
||
mask = ~res.isfinite() | ||
res[mask] = orig_out[mask] | ||
paddle.assign(res, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有个问题,这里如果out为None的话,是不是不正确? paddle.assign(res, out)之后,out应该仍然是None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if out is not None: | ||
paddle.assign(res, out) | ||
return out | ||
else: | ||
return res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里这样写是对的,如果out是None,则返回res
|
||
#include "paddle/extension.h" | ||
|
||
#define MAX_TENSORINFO_DIMS 25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个25应该是torch的维数限制,paddle设置为7维吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
|
||
#include "paddle/extension.h" | ||
|
||
#define MAX_TENSORINFO_DIMS 25 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
#else | ||
#define SHFL_UP_SYNC __shfl_up_sync | ||
#define SHFL_DOWN_SYNC __shfl_down_sync | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文件末尾换行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
from paddle import assign | ||
from paddle import divide | ||
from paddle import floor_divide | ||
from paddle import full | ||
from paddle import full_like | ||
from paddle import ones | ||
from paddle import put_along_axis | ||
from paddle import where | ||
from paddle import zeros |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些函数通过paddle模块访问吧,直接从模块import方法不太好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segment_coo系列的算子是否可以用自定义算子实现?否则for循环效率会不会比较低?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也可以,我再改一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题同coo系列API,是否能用自定义算子实现?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
也可以,我再改一下
version="1.0", | ||
author="NKNaN", | ||
url="https://github.com/PaddlePaddle/PaddleScience/jointContribution/paddle_scatter", | ||
description="Paddle extension of scatter and segment operators with min and max reduction methods", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description可以补充一下原作者的仓库吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的
另外这个PR能单独建立一个私人仓库吗(结构与原项目保持一致即可)?然后权限加我一下,这样我能review,后续移动至PFCCLab仓库在,我会通过submodule的形式把这个添加到PaddleScience的可选安装依赖里 |
也可以现在就移动至PFCCLab仓库下的私人repo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from xx import yy
建议全部改为 import xx
,然后使用 xx.yy
的方式调用,否则非常容易出现循环引用的问题。
] | ||
|
||
|
||
@pytest.mark.skipif(not paddle.cuda.is_available(), reason="CUDA not available") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.skipif(not paddle.cuda.is_available(), reason="CUDA not available") | |
@pytest.mark.skipif(paddle.cuda.device_count() == 0, reason="CUDA not available") |
|
||
|
||
@pytest.mark.skipif(not paddle.cuda.is_available(), reason="CUDA not available") | ||
@pytest.mark.skipif(paddle.cuda.device_count() < 2, reason="No multiple GPUS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.skipif(paddle.cuda.device_count() < 2, reason="No multiple GPUS") | |
@pytest.mark.skipif(paddle.device.cuda.device_count() < 2, reason="No multiple GPUS") |
建好了 |
好的,收到 |
PR types
New features
PR changes
APIs
Describe
scatter_min/scatter_max/segment类/gather类 API 由自定义算子实现,其他由组合API实现。