-
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
Should output of sequence_pool be LoDTensor with LoD? #7212
Comments
I think the output of sequence_pool (where input's LoDLevel=1) is Tensor, since the output is not a sequence . |
Since the output is a LoDTensor object, I think adding LoD info has no side effects. In some situation like decoder_boot in seq2seq, adding LoD info makes things easier. |
I agree conceptually, a Tensor (here specifically means a non-sequence) equals to a LoDTensor (here specifically means a sequence) with the LoDTensor fixed to be 1 for each sequence in the batch. This is no obvious side effect. But my concern is this is not a default setting for Fluid operators right now. Will this potentially affect the logic of other operators when they work together? I am not very sure about why not to enhance the
|
In my opinion, Paddle/paddle/operators/reorder_lod_tensor_by_rank_op.cc Lines 92 to 98 in 7508d52
Of course, we can adapt current |
I edit std::vector<AbsoluteRankTableItem> GetAbsoluteOffsetAndLengthByLoDRankTable(
const framework::LoDTensor &x) const {
std::vector<AbsoluteRankTableItem> absolute_table;
if (x.lod().empty()) {
// For Tensor without lod, such as the output of sequence_pool_op
size_t size = x.dims()[0];
absolute_table.reserve(size);
for (size_t i = 0; i < size; ++i) {
absolute_table.emplace_back();
absolute_table.back().length = 1;
absolute_table.back().offset = i;
}
} else {
size_t level = 0;
size_t size = x.lod()[level].size();
for (size_t i = 0; i < size - 1; ++i) {
auto lod_offset =
framework::GetSubLoDAndAbsoluteOffset(x.lod(), i, i + 1, level);
auto &offset = lod_offset.second;
absolute_table.emplace_back();
absolute_table.back().length = offset.second - offset.first;
absolute_table.back().offset = offset.first;
absolute_table.back().lod = lod_offset.first;
}
}
return absolute_table;
} All the changes are nearly completed, and I will push it to accept reviewing. |
@pkuyym This will lead users more confused, and I agree with @guoshengCS to enhance the |
I also agree with @luotao1 and @guoshengCS . |
BTW. There is a related question, Is A LoDTensor without LoD information as same as A LoDTensor with LoD information, the length of sequences are all one. For example, is LoDTensor
as same as
? |
@guoshengCS Please add corresponding test cases. |
@reyoung If we only keep LoDTensor, I think LoD being empty equals all length of sequences being ones makes sense. |
I do not prefer to modify the
Enhance A tensor without LoD information is equal to a batch of the sequences that length of each sequence in the batch is fixed to be 1. |
Already fixed by #7251 |
Currently, output of sequence_pool is a LoDTensor without LoD. However, the input is LoDTensor with LoD. Should we add LoD to output of sequence_pool.
The text was updated successfully, but these errors were encountered: