Add diagflat op, test=develop#33334
Conversation
There was a problem hiding this comment.
框架现在默认是动态图运行,这个应该可以去掉。下面也是
There was a problem hiding this comment.
这个接口和竞品对齐,没有padding_value=0, name=None这2个参数。
There was a problem hiding this comment.
已对齐,并去掉了unittest中涉及padding_value的测试用例。
There was a problem hiding this comment.
为了静态图的便利性,我们的api还是需要加上“name”参数的
There was a problem hiding this comment.
这是做diagflat的检查,如果检查未通过报错,用户看到的报错信息提示的是diag_v2会无法理解的。改为diagflat.下同
There was a problem hiding this comment.
offset的说明上需要增加:Default: 0 (main diagonal).
There was a problem hiding this comment.
现在不推荐用fluid的API,如果要用program_guard换为paddle.static.program_guard
There was a problem hiding this comment.
已将所有涉及fluid的API替换成 paddle2.1 doc中的API。
There was a problem hiding this comment.
这个接口没有对应的OP,你设置的self.op_type = "diagflat"是会报错的。不要用OpTest去检查了,换成unittest.TestCase,自己用numpy写一个函数计算期望值,和paddle.diagflat的实际结果做比较。
There was a problem hiding this comment.
- 上面的这些case太重复了,不同dtype的计算逻辑并没有任何区别。留下float64的即可。单测尽量用最小的测试集合覆盖代码中不同分支。
- 如果计算逻辑中,仅有1-D和N-D的区别,那2-D还是3-D的输入也是重复的测试样例,留一种
There was a problem hiding this comment.
1.已修正,只保留了float64数据类型的测试。
2.已修正,只保留了1-D和2-D的测试样例。
There was a problem hiding this comment.
- 静态图还是动态图,底层调用的c++ op都是一样的,只是前端接口逻辑有差异。这里不必在静态图模式下重复验证计算精确度了。
- 可以留下一个静态图的测试样例,以保证代码覆盖率即可
There was a problem hiding this comment.
静态图和动态图在python前端组装算子(flatten+diag)时,代码实现方式不同。如果不对静态图做全面测试,若静态图组装错误,会检查不到。故最终决定留下了静态图的1-D和2-D两组测试用例。
6f53eed to
6a43321
Compare
PR types
New features
PR changes
OPs
Describe
(1) Add diagflat op.
(2) Add unittest for diagflat.