-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
【Infer Symbolic Shape No.77】log_softmax #68025
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cb391a7
op test: log softmax
MikhayEeer f90e442
Merge branch 'PaddlePaddle:develop' into feature-mikhay
MikhayEeer a4087e1
add func LogSoftmax
MikhayEeer 4749cf9
Merge branch 'feature-mikhay' of https://github.com/MikhayEeer/Paddle…
MikhayEeer d9880c0
pre-commit
MikhayEeer ac52407
Merge branch 'PaddlePaddle:develop' into feature-mikhay
MikhayEeer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1585,6 +1585,51 @@ bool LogsumexpOpInferSymbolicShape( | |
return details::ReduceInferDim(op, infer_context, axis, keepdim, reduce_all); | ||
} | ||
|
||
bool Log_softmaxOpInferSymbolicShape( | ||
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { | ||
const auto &x_shape_or_data = | ||
infer_context->GetShapeOrDataForValue(op->operand_source(0)); | ||
const std::vector<symbol::DimExpr> &x_shape = x_shape_or_data.shape(); | ||
|
||
int axis = op->attribute<pir::Int32Attribute>("axis").data(); | ||
size_t rank = x_shape.size(); | ||
|
||
if (rank > 0) { | ||
PADDLE_ENFORCE_GE(axis, | ||
-rank, | ||
common::errors::InvalidArgument( | ||
"Attr(axis) value should be in range [-R, R-1], " | ||
"R is the rank of Input(X).")); | ||
PADDLE_ENFORCE_LT(axis, | ||
rank, | ||
common::errors::InvalidArgument( | ||
"Attr(axis) value should be in range [-R, R-1], " | ||
"R is the rank of Input(X).")); | ||
} else if (rank == 0) { | ||
PADDLE_ENFORCE_GE(axis, | ||
-1, | ||
common::errors::InvalidArgument( | ||
"Attr(axis) value should be in range [-1, " | ||
"0] when input is 0D Tensor ")); | ||
PADDLE_ENFORCE_LE(axis, | ||
0, | ||
common::errors::InvalidArgument( | ||
"Attr(axis) value should be in range [-1, " | ||
"0] when input is 0D Tensor ")); | ||
} | ||
|
||
infer_context->SetShapeOrDataForValue( | ||
op->result(0), | ||
symbol::ShapeOrDataDimExprs{symbol::TensorShapeOrDataDimExprs(x_shape)}); | ||
|
||
return true; | ||
Comment on lines
+1589
to
+1625
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 麻烦将这部分逻辑包装成一个推导函数,cumprod 和 log_softmax 都直接调用这个推导函数,参考命名:UnchangedCheckAxisInferSymbolicShape ? |
||
} | ||
|
||
bool LogSoftmaxOpInferSymbolicShape( | ||
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { | ||
return Log_softmaxOpInferSymbolicShape(op, infer_context); | ||
} | ||
|
||
bool LuOpInferSymbolicShape(pir::Operation *op, | ||
pir::InferSymbolicShapeContext *infer_context) { | ||
const auto &x_shape_or_data = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,8 @@ OP_DECLARE_INFER_SYMBOLIC_SHAPE(L1Norm_) | |
OP_DECLARE_INFER_SYMBOLIC_SHAPE(LpPool2d) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Logcumsumexp) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Logsumexp) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Log_softmax) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 删除这个声明,只需使用下面的驼峰命名方式。 |
||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(LogSoftmax) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Lu) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Lu_) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Mode) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule flashattn
updated
9 files
+33 −61 | csrc/capi/flash_attn.cu | |
+6 −12 | csrc/capi/flash_attn.h | |
+2 −16 | csrc/flash_attn/src/flash.h | |
+17 −125 | csrc/flash_attn/src/flash_bwd_kernel.h | |
+3 −6 | csrc/flash_attn/src/flash_bwd_launch_template.h | |
+38 −204 | csrc/flash_attn/src/flash_fwd_kernel.h | |
+4 −5 | csrc/flash_attn/src/flash_fwd_launch_template.h | |
+0 −127 | csrc/flash_attn/src/mask.h | |
+3 −77 | csrc/flash_attn/src/softmax.h |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
参考yaml文件中的评论