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

add TensorArray #4459

Merged
merged 5 commits into from
Oct 2, 2017
Merged

Conversation

Superjomn
Copy link
Contributor

No description provided.


namespace detail {

void ta_check_index(size_t index, size_t MAX_SIZE) {
Copy link
Member

Choose a reason for hiding this comment

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

may be just check_index? ta is a litter confusing


namespace detail {

void ta_check_index(size_t index, size_t MAX_SIZE) {
Copy link
Member

Choose a reason for hiding this comment

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

这个大写的 MAX_SIZE 和定义的那个const看起来有点容易混淆

return detail::PackDynamicBatch(values_, meta, lod, level);
}

std::vector<DySeqMeta> TensorArray::Unpack(const LoDTensor& source, int level,
Copy link
Member

Choose a reason for hiding this comment

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

这个函数里面,似乎没有用到 length_desend 这个参数?

* Split LoDTensor in some `level` and write the generated batches to
* `values`, if set `desend`, will sort by length in descending order.
*/
std::vector<DySeqMeta> Unpack(const LoDTensor &source, int level,
Copy link
Member

Choose a reason for hiding this comment

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

what if length_desend is set to false

void Unstack(const LoDTensor &source, bool data_shared) const;

private:
mutable std::vector<LoDTensor> values_;
Copy link
Member

Choose a reason for hiding this comment

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

Is this mutable necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it will be changed in Read(), expand dynamically.

@@ -0,0 +1,114 @@
#include "paddle/framework/tensor_array.h"
Copy link
Member

@jacquesqiao jacquesqiao Sep 30, 2017

Choose a reason for hiding this comment

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

copyright info

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

}

TensorArray ta;
const int batch_size{16};
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

here ~

LoDTensor packed = ta.Pack(0, meta, lod);
}

TEST_F(TensorArrayTester, size) { ASSERT_EQ(ta.size(), (size_t)batch_size); }
Copy link
Member

Choose a reason for hiding this comment

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

use cpp style cast instead of c style cast
https://google.github.io/styleguide/cppguide.html#Casting

using value_type = float;

// max number of values allowed to store.
const size_t MAX_SIZE{100000};
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@jacquesqiao jacquesqiao left a comment

Choose a reason for hiding this comment

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

LGTM! except for some const value name style

@Superjomn Superjomn merged commit c705f06 into PaddlePaddle:develop Oct 2, 2017
@Superjomn Superjomn deleted the feature/tensor_array branch October 2, 2017 20:14
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