未验证 提交 49797d85 编写于 作者: W wawltor 提交者: GitHub

Add the extra flag for the some ops (#35442)

* Add the extra flag for the some ops

* fix the compile problem in matmul extra
上级 7ef04da6
...@@ -165,31 +165,39 @@ class ElementwiseOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -165,31 +165,39 @@ class ElementwiseOpMaker : public framework::OpProtoAndCheckerMaker {
"for broadcasting Y onto X. ") "for broadcasting Y onto X. ")
.SetDefault(-1); .SetDefault(-1);
AddAttr<bool>("use_mkldnn", "(bool, default false). Used by MKLDNN.") AddAttr<bool>("use_mkldnn", "(bool, default false). Used by MKLDNN.")
.SetDefault(false); .SetDefault(false)
.AsExtra();
AddAttr<std::string>("x_data_format", "This parameter is no longer used.") AddAttr<std::string>("x_data_format", "This parameter is no longer used.")
.SetDefault(""); .SetDefault("")
.AsExtra();
AddAttr<std::string>("y_data_format", "This parameter is no longer used.") AddAttr<std::string>("y_data_format", "This parameter is no longer used.")
.SetDefault(""); .SetDefault("")
.AsExtra();
AddAttr<bool>( AddAttr<bool>(
"use_quantizer", "use_quantizer",
"(bool, default false) " "(bool, default false) "
"This parameter is no longer used. Use 'mkldnn_data_type' instead.") "This parameter is no longer used. Use 'mkldnn_data_type' instead.")
.SetDefault(false); .SetDefault(false)
.AsExtra();
AddAttr<std::string>( AddAttr<std::string>(
"mkldnn_data_type", "mkldnn_data_type",
"(string, default \"float32\"). Data type of mkldnn kernel") "(string, default \"float32\"). Data type of mkldnn kernel")
.SetDefault("float32") .SetDefault("float32")
.InEnum({"float32", "int8", "bfloat16"}); .InEnum({"float32", "int8", "bfloat16"})
.AsExtra();
/* int8 parameters */ /* int8 parameters */
AddAttr<float>("Scale_x", AddAttr<float>("Scale_x",
"(float, default 1.0f), The quantize scale of X tensor") "(float, default 1.0f), The quantize scale of X tensor")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<float>("Scale_y", AddAttr<float>("Scale_y",
"(float, default 1.0f), The quantize scale of Y tensor") "(float, default 1.0f), The quantize scale of Y tensor")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<float>("Scale_out", AddAttr<float>("Scale_out",
"(float, default 1.0f), The quantize scale of output data") "(float, default 1.0f), The quantize scale of output data")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddOpComment(); AddOpComment();
} }
......
...@@ -715,53 +715,66 @@ class MatMulOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -715,53 +715,66 @@ class MatMulOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr<bool>( AddAttr<bool>(
"use_mkldnn", "use_mkldnn",
"(bool, default false) Indicates if MKL-DNN kernel will be used") "(bool, default false) Indicates if MKL-DNN kernel will be used")
.SetDefault(false); .SetDefault(false)
.AsExtra();
AddAttr<std::vector<int>>("fused_reshape_X", AddAttr<std::vector<int>>("fused_reshape_X",
R"DOC(Shape of fused reshape of `X` input.)DOC") R"DOC(Shape of fused reshape of `X` input.)DOC")
.SetDefault({}); .SetDefault({})
.AsExtra();
AddAttr<std::vector<int>>("fused_reshape_Y", AddAttr<std::vector<int>>("fused_reshape_Y",
R"DOC(Shape of fused reshape of `Y` input.)DOC") R"DOC(Shape of fused reshape of `Y` input.)DOC")
.SetDefault({}); .SetDefault({})
.AsExtra();
AddAttr<std::vector<int>>("fused_transpose_X", AddAttr<std::vector<int>>("fused_transpose_X",
R"DOC(Axis of fused transpose of `X` input.)DOC") R"DOC(Axis of fused transpose of `X` input.)DOC")
.SetDefault({}); .SetDefault({})
.AsExtra();
AddAttr<std::vector<int>>("fused_transpose_Y", AddAttr<std::vector<int>>("fused_transpose_Y",
R"DOC(Axis of fused transpose of `Y` input.)DOC") R"DOC(Axis of fused transpose of `Y` input.)DOC")
.SetDefault({}); .SetDefault({})
.AsExtra();
AddAttr<std::vector<int>>( AddAttr<std::vector<int>>(
"fused_reshape_Out", "fused_reshape_Out",
R"DOC(When MKLDNN MatMul_transpose_reshape fuse activated, " R"DOC(When MKLDNN MatMul_transpose_reshape fuse activated, "
"it's a shape atribute of fused reshape for `Out` output.)DOC") "it's a shape atribute of fused reshape for `Out` output.)DOC")
.SetDefault({}); .SetDefault({})
.AsExtra();
AddAttr<std::vector<int>>( AddAttr<std::vector<int>>(
"fused_transpose_Out", "fused_transpose_Out",
R"DOC(When MKLDNN MatMul_transpose_reshape fuse activated, " R"DOC(When MKLDNN MatMul_transpose_reshape fuse activated, "
"it's a axis atribute of fused transpose for `Out` output.)DOC") "it's a axis atribute of fused transpose for `Out` output.)DOC")
.SetDefault({}); .SetDefault({})
.AsExtra();
AddAttr<bool>( AddAttr<bool>(
"use_quantizer", "use_quantizer",
"(bool, default false) " "(bool, default false) "
"This parameter is no longer used. Use 'mkldnn_data_type' instead.") "This parameter is no longer used. Use 'mkldnn_data_type' instead.")
.SetDefault(false); .SetDefault(false)
.AsExtra();
AddAttr<std::string>( AddAttr<std::string>(
"mkldnn_data_type", "mkldnn_data_type",
"(string, default \"float32\"). Data type of mkldnn kernel") "(string, default \"float32\"). Data type of mkldnn kernel")
.SetDefault("float32") .SetDefault("float32")
.InEnum({"float32", "int8", "bfloat16"}); .InEnum({"float32", "int8", "bfloat16"})
.AsExtra();
/* int8 parameters */ /* int8 parameters */
AddAttr<float>("Scale_x", AddAttr<float>("Scale_x",
"(float, default 1.0f), The quantize scale of X tensor") "(float, default 1.0f), The quantize scale of X tensor")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<float>("Scale_y", AddAttr<float>("Scale_y",
"(float, default 1.0f), The quantize scale of Y tensor") "(float, default 1.0f), The quantize scale of Y tensor")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<float>("Scale_out", AddAttr<float>("Scale_out",
"(float, default 1.0f), The quantize scale of output data") "(float, default 1.0f), The quantize scale of output data")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<bool>("force_fp32_output", AddAttr<bool>("force_fp32_output",
"(bool, default false) Force INT8 kernel output FP32, only " "(bool, default false) Force INT8 kernel output FP32, only "
"used in MKL-DNN INT8") "used in MKL-DNN INT8")
.SetDefault(false); .SetDefault(false)
.AsExtra();
#if defined(PADDLE_WITH_MKLML) && !defined(PADDLE_WITH_CUDA) && \ #if defined(PADDLE_WITH_MKLML) && !defined(PADDLE_WITH_CUDA) && \
!defined(PADDLE_WITH_HIP) !defined(PADDLE_WITH_HIP)
......
...@@ -141,12 +141,14 @@ class MatMulV2OpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -141,12 +141,14 @@ class MatMulV2OpMaker : public framework::OpProtoAndCheckerMaker {
.SetDefault(false); .SetDefault(false);
AddAttr<bool>("use_mkldnn", AddAttr<bool>("use_mkldnn",
"(bool, default false) Only used in mkldnn kernel") "(bool, default false) Only used in mkldnn kernel")
.SetDefault(false); .SetDefault(false)
.AsExtra();
AddAttr<std::string>( AddAttr<std::string>(
"mkldnn_data_type", "mkldnn_data_type",
"(string, default \"float32\"). Data type of mkldnn kernel") "(string, default \"float32\"). Data type of mkldnn kernel")
.SetDefault("float32") .SetDefault("float32")
.InEnum({"float32", "bfloat16"}); .InEnum({"float32", "bfloat16"})
.AsExtra();
AddComment( AddComment(
R"DOC(Matrix multiplication Out = X * Y. A has shape (d0, d1 ... M, K), R"DOC(Matrix multiplication Out = X * Y. A has shape (d0, d1 ... M, K),
B has shape (d0, d1 ... K, N), Out has shape ((d0, d1 ... M, N)). B has shape (d0, d1 ... K, N), Out has shape ((d0, d1 ... M, N)).
......
...@@ -166,22 +166,26 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -166,22 +166,26 @@ class MulOpMaker : public framework::OpProtoAndCheckerMaker {
"scale_x to be used for int8 mul input data x. scale_x has the" "scale_x to be used for int8 mul input data x. scale_x has the"
"same purpose as scale_in in OPs that support quantization." "same purpose as scale_in in OPs that support quantization."
"Only to be used with MKL-DNN INT8") "Only to be used with MKL-DNN INT8")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<std::vector<float>>( AddAttr<std::vector<float>>(
"scale_y", "scale_y",
"scale_y to be used for int8 mul input data y. scale_y has the" "scale_y to be used for int8 mul input data y. scale_y has the"
"same purpose as scale_weights in OPs that support quantization." "same purpose as scale_weights in OPs that support quantization."
"Only to be used with MKL-DNN INT8") "Only to be used with MKL-DNN INT8")
.SetDefault({1.0f}); .SetDefault({1.0f})
.AsExtra();
AddAttr<float>("scale_out", AddAttr<float>("scale_out",
"scale_out to be used for int8 output data." "scale_out to be used for int8 output data."
"Only used with MKL-DNN INT8") "Only used with MKL-DNN INT8")
.SetDefault(1.0f); .SetDefault(1.0f)
.AsExtra();
AddAttr<bool>( AddAttr<bool>(
"force_fp32_output", "force_fp32_output",
"(bool, default false) Force quantize kernel output FP32, only " "(bool, default false) Force quantize kernel output FP32, only "
"used in quantized MKL-DNN.") "used in quantized MKL-DNN.")
.SetDefault(false); .SetDefault(false)
.AsExtra();
AddComment(R"DOC( AddComment(R"DOC(
Mul Operator. Mul Operator.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册