-
Notifications
You must be signed in to change notification settings - Fork 263
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 7th No.20】为 Paddle 新增 Tensor.set_ / Tensor.resize_ API #968
Conversation
测试case: | ||
|
||
paddle.Tensor.set_ | ||
- 正确性验证:可以与 as_strided 的结果对齐; |
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.
此处要关注as_strided仅动态图支持,set_是否能同时支持动静态图
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.
set_按这样设计只支持动态图,目前是否有支持静态图的inplace 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.
inplace API 只支持动态图没有问题,但需要加上@inplace_apis_in_dygraph_only 的 tag。表明该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.
好的
- old_size > new_size ; | ||
- 验证不同dtype类型:`bfloat16`,`float16`,`float32`,`float64`,`bool`,`int8`,`int16`,`int32`,`int64`,`uint8`,`complex64`,`complex128`; | ||
- 验证不同计算设备:覆盖 CPU 和 GPU 等实现; | ||
|
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.
好的
const std::vector<int64_t>& stride, | ||
int64_t offset, | ||
DenseTensor* out) { | ||
AsStridedKernel<Context>(dev_ctx, source, dims, stride, offset, 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.
如与as_strided 类似,是否还需要新增kernel?
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.
好的
|
||
## 2、功能目标 | ||
- 实现 paddle.Tensor.set_ 做为 Tensor 的方法使用。设置 Tensor 与 source 共享相同的存储空间,且可设置为与 source 相同或不同的 shape,stride,offset。 | ||
- 实现 paddle.Tensor.resize_ 做为 Tensor 的方法使用。重新调整 Tensor 的 size,若新 numel 小于等于原 numel,不改变存储空间大小;若新 numel 大于原 numel,需调整存储空间大小。 |
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.
为什么小于原 numel时,不改变存储空间大小?
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.
是的没错
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.
LGTM
No description provided.