Mutiply bug allow non-tensor data input#27690
Merged
zhhsplendid merged 4 commits intoPaddlePaddle:developfrom Oct 12, 2020
Joejiong:mutiply_bug
Merged
Mutiply bug allow non-tensor data input#27690zhhsplendid merged 4 commits intoPaddlePaddle:developfrom Joejiong:mutiply_bug
zhhsplendid merged 4 commits intoPaddlePaddle:developfrom
Joejiong:mutiply_bug
Conversation
|
Thanks for your contribution! |
zhhsplendid
reviewed
Oct 12, 2020
Member
zhhsplendid
left a comment
There was a problem hiding this comment.
代码我觉得没有问题,测试有一些代码我觉得不是很好,已评论,因为ci已经过了,我这边先approve,要这个PR改还是下一个PR改请自己决定。
| return res | ||
|
|
||
| def __run_static_graph_case_with_numpy_input(self, x_data, y_data, axis=-1): | ||
| with program_guard(Program(), Program()): |
Member
There was a problem hiding this comment.
program是静态图才有的,所以最好paddle.enable_static写在with program_guard前面
|
|
||
| def __run_static_graph_case(self, x_data, y_data, axis=-1): | ||
| with program_guard(Program(), Program()): | ||
| paddle.enable_static() |
Member
There was a problem hiding this comment.
program是静态图才有的,所以最好paddle.enable_static写在with program_guard前面
| res = tensor.multiply(x_data, y_data, axis=axis) | ||
| place = fluid.CUDAPlace(0) if fluid.core.is_compiled_with_cuda( | ||
| ) else fluid.CPUPlace() | ||
| exe = fluid.Executor(place) |
Member
There was a problem hiding this comment.
将来可以尽量用2.0 迁移的写法,比如paddle.CPUPlace, paddle.CUDAPlace,paddle.static.Executor
| res = self.__run_static_graph_case(x_data, y_data) | ||
| self.assertTrue(np.allclose(res, np.multiply(x_data, y_data))) | ||
|
|
||
| # test static computation graph: 1-d array |
Member
There was a problem hiding this comment.
像我以前说过,python里面用注释分隔测试并不是最好的方法,你可以直接创建一个测试method:
def test_static_multiply_1d(self) 这类的
zhhsplendid
approved these changes
Oct 12, 2020
chen-zhiyu
pushed a commit
to chen-zhiyu/Paddle
that referenced
this pull request
Oct 15, 2020
Mutiply allows non-tensor data input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
APIs
Describe