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

[Core] Add the graph optimization of subblocks for transformer model #3947

Merged

Conversation

hong19860320
Copy link
Collaborator

@hong19860320 hong19860320 commented Jul 14, 2020

  1. Fix the dims of parent idx of the arm kernel of beam_search op
  2. elementwise_mul supports int64_t data type with broadcasting
  3. Add print op and kernel for debugging
  4. Support throwing the exception when the internal error occurs
  5. Refine while and conditional_block op kernel
  6. Support the graph optimization on subblocks
  7. Pass program_desc and block_idx into the kernel of the control flow ops(while/conditional_block/subgraph), and create the RuntimeProgram online, it make it possiable to call the control flow ops recursively
  8. Add unit test for masked transformer model

…_t data type, add print op and kernel, add exeception

test=develop
@hong19860320 hong19860320 changed the title [Core] [Core] Add the graph optimization of subblock for transformer model Jul 14, 2020
@hong19860320 hong19860320 changed the title [Core] Add the graph optimization of subblock for transformer model [Core] Add the graph optimization of subblocks for transformer model Jul 14, 2020
LOG(FATAL)
<< "Getting 'tensor_desc' is not supported by the type of var %s."
<< this->Name();
LOG(WARNING) << "Getting 'tensor_desc' is not supported by the type("
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

while op会带有STEP_SCOPE类型的var,如果使用FATAL会导致模型加载失败,程序挂掉。

lite/core/mir/subgraph/subgraph_detector_test.cc Outdated Show resolved Hide resolved
TARGET(kHost), type.precision(), DATALAYOUT(kNCHW));
}
}

// Update a's kUnk fields from b's fields.
void UpdateTypeFrom(const Type*& a, const Type* b) { // NOLINT
Copy link
Collaborator

Choose a reason for hiding this comment

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

const Type*&a -> const Type* a ?

POD 不需要引用

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

需要修改a的值的,等价于const Type** a

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

为了防止歧义,已修改为const Type** a

lite/core/optimizer.h Outdated Show resolved Hide resolved
lite/core/optimizer.h Outdated Show resolved Hide resolved
lite/core/program.cc Outdated Show resolved Hide resolved
lite/kernels/arm/elementwise_compute.cc Outdated Show resolved Hide resolved
const char kBackward[] = "BACKWARD";
const char kBoth[] = "BOTH";

class TensorFormatter {
Copy link
Collaborator

Choose a reason for hiding this comment

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

TensorReprFormatter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

lite/operators/assign_op.cc Outdated Show resolved Hide resolved
lite/operators/conditional_block_op.cc Outdated Show resolved Hide resolved
if [[ $WITH_EXCEPTION == "ON" && $ARCH == "armv7" && $TOOLCHAIN != "clang" ]]; then
set +x
echo
echo -e "Error: only clang provide C++ exception handling support for 32-bit ARM."
Copy link
Collaborator

Choose a reason for hiding this comment

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

是否需要修改文档?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

是否需要修改文档?
只有在armv7需要支持exception的时候才要求用clang,而支持exception是一个新特性,可以在发版的时候修改文档

Shixiaowei02
Shixiaowei02 previously approved these changes Jul 21, 2020
lite/backends/arm/math/beam_search.cc Outdated Show resolved Hide resolved
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

@hong19860320 hong19860320 merged commit 7af1a25 into PaddlePaddle:develop Jul 22, 2020
@hong19860320 hong19860320 deleted the hongming/support_subblock branch July 22, 2020 15:01
hong19860320 added a commit to hong19860320/Paddle-Lite that referenced this pull request Jul 22, 2020
…former model (PaddlePaddle#3947)

test=develop
* [Core][ARM] Fix beam_search, eltwise_mul supports broadcast and int64_t data type, add print op and kernel, add exeception
test=develop

* Fix the dims of parent idx of the arm kernel of beam_search op

* elementwise_mul supports int64_t data type with broadcasting

* Add print op and kernel for debugging

* Support throwing the exception when the internal error occurs

* Refine while and conditional_block op kernel

* Support the graph optimization on subblocks

* Pass program_desc and block_idx into the kernel of the control flow ops(while/conditional_block/subgraph), and create the RuntimeProgram online, it make it possiable to call the control flow ops recursively

*Add unit test for masked transformer model
hong19860320 added a commit that referenced this pull request Jul 23, 2020
…former model (#3947) (#3979)

* [Cherry-pick][Core] Add the graph optimization of subblocks for transformer model (#3947)
test=develop
* [Core][ARM] Fix beam_search, eltwise_mul supports broadcast and int64_t data type, add print op and kernel, add exeception
test=develop

* Fix the dims of parent idx of the arm kernel of beam_search op

* elementwise_mul supports int64_t data type with broadcasting

* Add print op and kernel for debugging

* Support throwing the exception when the internal error occurs

* Refine while and conditional_block op kernel

* Support the graph optimization on subblocks

* Pass program_desc and block_idx into the kernel of the control flow ops(while/conditional_block/subgraph), and create the RuntimeProgram online, it make it possiable to call the control flow ops recursively

*Add unit test for masked transformer model
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.

None yet

3 participants