Skip to content
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

Merged
merged 8 commits into from
Aug 1, 2017
Merged

Slice Layer #3126

merged 8 commits into from
Aug 1, 2017

Conversation

hedaoyuan
Copy link
Contributor

Fix #3037

@hedaoyuan hedaoyuan requested a review from luotao1 August 1, 2017 03:47
void SliceProjection::forward() {
size_t offset = 0;
for (auto& slice : slices_) {
auto slice_out = in_->value->subColMatrix(slice.first, slice.second);
Copy link
Contributor

Choose a reason for hiding this comment

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

这里的first, second能用start(), end()来表示么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个不行,first, secondstd::pair的成员变量。

}
}

void SliceProjection::forward() {
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是少了一个check,output_的size,得和每个slice的大小相加后的值一样。

Copy link
Contributor Author

@hedaoyuan hedaoyuan Aug 1, 2017

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
Copy link
Contributor

Choose a reason for hiding this comment

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

type offset->type slices,笔误

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.

# 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]
Copy link
Contributor

Choose a reason for hiding this comment

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

这里检查了start,end要检查么,可以只检查最后一个end有没有越界。

Copy link
Contributor Author

@hedaoyuan hedaoyuan Aug 1, 2017

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有没有越界,这里还没法判断。

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

@hedaoyuan hedaoyuan merged commit aaf8401 into PaddlePaddle:develop Aug 1, 2017
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.

2 participants