Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

add some reduction PEs and python/C++ tests #180

Merged
merged 1 commit into from
Aug 21, 2020

Conversation

wenming2014
Copy link
Collaborator

add some reduction PEs and python/C++ tests(#138 )

@@ -52,5 +52,14 @@ cinn_buffer_t* BufferBuilder::Build() {
return buffer;
}

cinn_buffer_t* CreateBuffer(const std::vector<int> shape, bool random, int set_value) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

set_value 是 int

是不是可以 template ?

template
cinn_buffer_t* CreateBuffer(const std::vector shape, bool random, T value=0.);

里面的 Type 可以用 type_of() 获取

https://github.com/Superjomn/CINN/blob/develop/cinn/common/type.h#L136

@@ -52,5 +52,14 @@ cinn_buffer_t* BufferBuilder::Build() {
return buffer;
}

cinn_buffer_t* CreateBuffer(const std::vector<int> shape, bool random, int set_value) {
if (random) {
return common::BufferBuilder(Float(32), shape).set_random().Build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里不一定是 Float(32),也可能是 Int(32) 啥的

用上面的 template 可以自动推导

} else if (set_value != 0) {
return common::BufferBuilder(Float(32), shape).set_val(set_value).Build();
}
return common::BufferBuilder(Float(32), shape).set_zero().Build();
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个 helper 感觉不是必须的,BufferBuilder 目前应该也算比较方便了,而且灵活性比较好

Copy link
Collaborator

@Superjomn Superjomn left a comment

Choose a reason for hiding this comment

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

LGTM

@Superjomn Superjomn merged commit da3adbb into PaddlePaddle:develop Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants