-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slice Layer #3126
Slice Layer #3126
Conversation
void SliceProjection::forward() { | ||
size_t offset = 0; | ||
for (auto& slice : slices_) { | ||
auto slice_out = in_->value->subColMatrix(slice.first, slice.second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的first, second能用start(), end()来表示么?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个不行,first, second
是std::pair
的成员变量。
} | ||
} | ||
|
||
void SliceProjection::forward() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是不是少了一个check,output_的size,得和每个slice的大小相加后的值一样。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SliceProjection 585行里面已经保证了,output_.size是所有slices.size的和。
:param slices: An array of slice parameters. | ||
Each slice contains the start and end offsets based | ||
on the input. | ||
:type offset: pair of int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type offset->type slices,笔误
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
# or equal to the end position of the previous slice. | ||
assert slices[i][0] >= start | ||
assert slices[i][1] >= slices[i][0] | ||
start = slices[i][1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里检查了start,end要检查么,可以只检查最后一个end有没有越界。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slices[i][1] >= slices[i][0]
这句检查的是每个slice的end要大于等于start,如果end<start
就直接报错了。
最后一个end有没有越界
,在SliceProjection 580行检查了最后一个end有没有越界,这里还没法判断。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM。可以在https://github.com/PaddlePaddle/Paddle/blob/develop/doc/api/v2/config/layer.rst#mixed-layer 补上slice_projection的信息。
Fix #3037