CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
【Operator Mechanism】add fused_stack_transpose_quant api #73228
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
【Operator Mechanism】add fused_stack_transpose_quant api #73228
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
b8eefa1
to
daff73d
Compare
paddle/phi/ops/yaml/ops.yaml
Outdated
@@ -2382,6 +2382,24 @@ | |||
backward: fused_softmax_mask_upper_triangle_grad | |||
interfaces : paddle::dialect::InferSymbolicShapeInterface | |||
|
|||
- op : fused_stack_quant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有一个专门存放融合算子的:paddle/phi/ops/yaml/fused_ops.yaml
#include <iostream> | ||
#include <limits> | ||
|
||
// #include "paddle/extension.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete unused code
} \ | ||
} | ||
|
||
// 对二维坐标进行swizzle变换,提供相对offset,避免bank conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文注释清理一下
daff73d
to
149c8c1
Compare
paddle/phi/infermeta/multiary.cc
Outdated
@@ -6245,6 +6245,108 @@ void FullWithTensorInferMeta(const IntArray& shape, | |||
out->set_dtype(dtype); | |||
} | |||
|
|||
std::tuple<int64_t, int64_t, int64_t> FusedStackQuantCommonCheck( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
放到fusion.h/.cc中
paddle/phi/infermeta/multiary.h
Outdated
std::tuple<int64_t, int64_t, int64_t> FusedStackQuantCommonCheck( | ||
const std::vector<const MetaTensor*>& x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
非InferMeta函数不用把声明加到.h
@@ -0,0 +1,84 @@ | |||
# Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2023 -> 2025
python/paddle/nn/functional/fp8.py
Outdated
|
||
|
||
""" | ||
if in_dynamic_mode(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dynamic or pir mode
python/paddle/nn/functional/fp8.py
Outdated
else: | ||
return _C_ops.fused_stack_quant(x) | ||
|
||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else分支去掉
dev_ctx.template Alloc<phi::dtype::float8_e4m3fn>(out); | ||
dev_ctx.template Alloc<float>(scale); | ||
auto out_dims = out->dims(); | ||
out->Resize(out_dims); | ||
auto scale_dims = scale->dims(); | ||
scale->Resize(scale_dims); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一般是先resize才alloc:
Paddle/paddle/fluid/framework/operator.h
Lines 594 to 597 in c999558
phi::DenseTensor tmp; | |
tmp.Resize(dim); | |
dev_ctx.template Alloc<T>(&tmp); | |
return tmp; |
还有为啥要把一个tensor resize成自己的dims?这样会产生什么变化吗
f6798e5
to
4ddde16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This reverts commit 06ca104.
PR Category
Operator Mechanism
PR Types
New features
Description
新增fused_stack_transpose_quant和fused_stack_quant支持