File tree Expand file tree Collapse file tree 2 files changed +89
-0
lines changed Expand file tree Collapse file tree 2 files changed +89
-0
lines changed File renamed without changes.
Original file line number Diff line number Diff line change 1+ # paddle.incubate.sparse.is_same_shap 设计文档
2+
3+ | API名称 | paddle.incubate.sparse.is_same_shap |
4+ | ---| -------------------------------------------|
5+ | 提交作者<input type =" checkbox " class =" rowselector hidden " > | PeachML |
6+ | 提交时间<input type =" checkbox " class =" rowselector hidden " > | 2022-07-12 |
7+ | 版本号 | V1.0 |
8+ | 依赖飞桨版本<input type =" checkbox " class =" rowselector hidden " > | develop |
9+ | 文件名 | 20220712_api_design_for_is_same_shape.md<br > |
10+
11+ # 一、概述
12+
13+ ## 1、相关背景
14+
15+ 为了提升飞桨API丰富度,is_same_shape 是一个基础的形状比较操作,目前 Paddle 中还没有 is_same_shape 算子。
16+ 本任务的目标是在 Paddle 中添加 paddle.incubate.sparse.is_same_shap 算子, 实现输入是 dense、coo、csr 之间的形状比较。
17+ Paddle需要扩充API,新增 is_same_shape API, 调用路径为:` paddle.incubate.sparse.is_same_shap `
18+
19+ ## 3、意义
20+
21+ 支持稀疏tensor之间和稀疏tensor与稠密tensor之间的形状比较,打通Sparse与Dense领域的操作。
22+
23+ # 二、飞桨现状
24+
25+ 目前paddle缺少相关功能实现。
26+
27+ # 三、业内方案调研
28+
29+ ## Pytorch
30+
31+ Pytorch无此API
32+
33+ ## Numpy
34+ Numpy中一般使用` a.shape()==b.shape() ` 进行判断
35+
36+ # 四、对比分析
37+
38+ paddle中要实现九种交叉比较,故自行实现
39+
40+ # 五、方案设计
41+
42+ ## 命名与参数设计
43+
44+ 在 python/paddle/incubate/sparse/multiary.py 中新增api,
45+
46+
47+ ``` python
48+ def is_same_shape (x , y )
49+ ```
50+
51+
52+ ## 底层OP设计
53+
54+ 新增一个tensor method,python端调用
55+
56+ ## API实现方案
57+
58+ 在 paddle/fluid/pybind/eager_method.cc 中实现,作为TensorObject的类成员函数,对比self.tensor.shape是否一致
59+ 静态图实现:目前sparse系列暂不支持静态图
60+
61+ ``` c
62+ static PyObject* tensor_method_is_same_shape (TensorObject* self,
63+ TensorObject* other,
64+ PyObject* args,
65+ PyObject* kwargs)
66+ ```
67+
68+ # 六、测试和验收的考量
69+
70+ 测试考虑的case如下:
71+
72+ - 数值正确性
73+ - 不同类型tensor比较,dense、coo、csr,两两比较,共九种情况
74+
75+ # 七、可行性分析及规划排期
76+
77+ 经论证可行
78+
79+ # 八、影响面
80+
81+ 为独立新增api,对其他模块没有影响
82+
83+ # 名词解释
84+
85+ 无
86+
87+ # 附件及参考资料
88+
89+ 无
You can’t perform that action at this time.
0 commit comments