Skip to content

Conversation

@tianbingsz
Copy link
Contributor

@tianbingsz tianbingsz commented Dec 25, 2016

added paddle functions for Matrix ContextProjection (#977)
contextProjectionForward
contextProjectionBackwardData
contextProjectionBackwardWeight
contextProjectionBackward

@tianbingsz tianbingsz requested a review from hedaoyuan December 26, 2016 01:46
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateSequenceStartPositions是一个用于paddle test的通用接口,还是把它单独写一个文件,放到utils编成一个单独的lib,add_library(paddle_test ....)。这样add_unittest(context_projection_op_test里面就不需要显示的增加../gserver/tests/TestUtil.cpp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do it in a separate pull request.

Copy link
Contributor Author

@tianbingsz tianbingsz Jan 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hedaoyuan , done, please refer to #1058

@tianbingsz tianbingsz self-assigned this Dec 27, 2016
@tianbingsz tianbingsz changed the title add paddle functions for Matrix APIs add paddle functions for Matrix ContextProjection APIs Dec 29, 2016
@hedaoyuan
Copy link
Contributor

hedaoyuan commented Dec 29, 2016

后续可以一起看一下Projection是否可以去掉了,Projection是在MixedLayer里面用的,MixedLayer会将对InputLayer的计算转换成Projection,然后forward/backward时遍历projections_。应该是可以直接将针对InputLayer的计算转换成Function,这样应该就可以去掉Projection了。

@hedaoyuan ,sure, will do it later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ContextProjectionForward可以去掉is_padding参数,直接根据weight是否为空判断是否padding即可。这样这里也不需要再init一次了。对于is_padding == false的情况,可以构造空的weight作为参数传递(或者通过检查参数个数来判断)。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@emailweixu emailweixu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need more comments and correct use of inouts.


void calc(const Arguments& inputs,
const Arguments& outputs,
const Arguments& inouts) override {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need clear comment about what the function does.
inputs are readonly. outputs are writeonly. inouts are for both read and write. For this function, we should use inouts instead of outputs. Because the result is added to output value.

* \param inputs[1] weight grad.
* \param inputs[2] input sequence.
* \param outputs[0] output value.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment what the function does


void calc(const Arguments& inputs,
const Arguments& outputs,
const Arguments& inouts) override {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use inouts because gradient are accumulated.

* \param inputs[0] input grad.
* \param inputs[1] input sequence.
* \param outputs[0] output grad.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment what the function does


void calc(const Arguments& inputs,
const Arguments& outputs,
const Arguments& inouts) override {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use inouts for accumulate gradient.


void calc(const Arguments& inputs,
const Arguments& outputs,
const Arguments& inouts) override {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use inouts

zhhsplendid pushed a commit to zhhsplendid/Paddle that referenced this pull request Sep 25, 2019
fix dead chain at op_notes fix Sharelod() to ShareLoD()
wangxicoding pushed a commit to wangxicoding/Paddle that referenced this pull request Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants