Created by: wozna
PR types
New features
PR changes
Others
Describe
This PR is the next step of adding bfloat16 support to PaddlePaddle.
This PR presents:
- two passes for enabling mkldnn bfloat16
- tests for those passes
- insertion passes to
CpuPassStrategy
- there is still no support in Numpy for
bfloat16
, so added there inframework.py
conversion from pythonuint16
to C++bfloat16
More about passes: After enabling bfloat16, two passes will be applied to the graph.
- first cpu_bfloat16_placement_pass.cc - this pass first sets to attribute
mkldnn_data_type = bfloat16
to all operators contained in the vectorbfloat16_enabled_op_types
or if user won't set any op types all operators that support bfloat16 will be marked. - second cpu_bfloat16_pass.cc - this pass first adds reorder between
float32
andbfloat16
operators, unlessbfloat16
operator isconv2d
(conv2d can reoder input to bfloat16 inside kernel, so reoder is no needed, what decreases number of reoders). Than adds reorder betweenbfloat16
andfloat32
operators or use attrforce_output_fp32
if the operator has this attribute.