Skip to content

Conversation

zhouxiao-coder
Copy link
Contributor

@zhouxiao-coder zhouxiao-coder commented Nov 29, 2017

resolve #5842

  1. As described in issue Support "In place" computation in operator unit test #5842, I was trying to add a small feature to OpTest class to support convenient unit test for in-place computation operators, which is supported by the in_place_map attribute added in base class OpTest.

  2. After reading the original implementation, I find several places that can be improved and start to rewrite some of the methods, which mainly to improve the following aspects:

Unify forward/backward code

In the old implementation, forward test and backward test are implemented in completely different logics, probably due to historical reasons. They use different ways to create operators, to create variable descriptions, feed variables, and execute the program. Check the "#FIXME" comment in the old code.

In this PR, both forward and backward use similar process to do computation:

#1. initialize program, global block
self._init_program()

#2. compile the operator, return input and output descriptions
op, input_var_descs, output_var_descs = self._compile_op(place)

#3. prepare input and output of the operator
feed_map = self._feed_vars(input_var_descs, self.inputs, place)
fetch_list = self._get_fetch_list(output_var_descs, place, filter=self.outputs.keys())

#4. execute
outs = self._execute(feed_map, fetch_list, place)

Scope and Block

The old code uses both block and scope to manage variables. I find it quite confusing, so I completely remove scope related code and replace it with block methods.

I'm actually a little fuzzy about the scope and block concept in PaddlePaddle, even after reading all the design docs in current repo, so Please help to make sure this is ok. I ran all the unit tests, it seems alright.

New batch_norm_op unit test

Due to lack of in-place computation support, the original batch_norm_op unit test rewrites most of the logic in the OpTest base class. Now a simpler version is possible after the enhancement.

@zhouxiao-coder
Copy link
Contributor Author

Currently, CI is blocked by batch_norm_op test failure on GPU case.
It is actually a bug in the c++ batch_norm_op implementation:

@zhouxiao-coder zhouxiao-coder self-assigned this Nov 30, 2017
@luotao1
Copy link
Contributor

luotao1 commented Feb 1, 2019

感谢您给PaddlePaddle贡献代码。由于Paddle V1/V2版本已不再维护,相关代码也已从develop分支上删除,因此关闭您的PR,欢迎您向Paddle最新版-Fluid贡献代码。
Thanks for contributing to PaddlePaddle! Since V1/V2 will not be maintained anymore, and related codes have been deleted from develop branch as well, we close this PR. Welcome to contribute to Fluid——the latest version of PaddlePaddle.

@luotao1 luotao1 closed this Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support "In place" computation in operator unit test

2 participants