-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
【BUAA】【Infer Symbolic Shape】add set_value_with_tensor, sigmoid_cross_entropy_with_logits,swiglu #67098
【BUAA】【Infer Symbolic Shape】add set_value_with_tensor, sigmoid_cross_entropy_with_logits,swiglu #67098
Changes from 8 commits
e982480
89e6fcd
1feddf4
b12913d
d5ce2bf
26542be
d8bc4ab
c30336f
07ce6b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1346,19 +1346,43 @@ bool StackOpInferSymbolicShape(pir::Operation *op, | |
// return true; | ||
// } | ||
|
||
// bool SigmoidCrossEntropyWithLogitsOpInferSymbolicShape(pir::Operation *op, | ||
// pir::InferSymbolicShapeContext | ||
// *infer_context) { | ||
// // pass | ||
// return true; | ||
// } | ||
bool SigmoidCrossEntropyWithLogitsOpInferSymbolicShape( | ||
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { | ||
const auto &input_shape_or_data = | ||
infer_context->GetShapeOrDataForValue(op->operand_source(0)); | ||
const auto &label_shape_or_data = | ||
infer_context->GetShapeOrDataForValue(op->operand_source(1)); | ||
|
||
// bool SigmoidCrossEntropyWithLogits_OpInferSymbolicShape(pir::Operation *op, | ||
// pir::InferSymbolicShapeContext | ||
// *infer_context) { | ||
// return SigmoidCrossEntropyWithLogitsOpInferSymbolicShape(op, | ||
// infer_context); | ||
// } | ||
size_t rank = input_shape_or_data.shape().size(); | ||
PADDLE_ENFORCE_EQ(rank, | ||
label_shape_or_data.shape().size(), | ||
common::errors::InvalidArgument( | ||
"Input(X) and Input(Label) shall have the same rank." | ||
"But received: the rank of Input(X) is [%d], " | ||
"the rank of Input(Label) is [%d].", | ||
rank, | ||
label_shape_or_data.shape().size())); | ||
|
||
for (size_t i = 0; i < rank; ++i) { | ||
infer_context->AddEqualCstr(input_shape_or_data.shape()[i], | ||
label_shape_or_data.shape()[i]); | ||
} | ||
if (op->operand_source(2)) { | ||
const auto &pos_shape_or_data = | ||
infer_context->GetShapeOrDataForValue(op->operand_source(2)); | ||
for (size_t i = 0; i < rank; ++i) { | ||
infer_context->AddEqualCstr(input_shape_or_data.shape()[i], | ||
pos_shape_or_data.shape()[i]); | ||
} | ||
} | ||
infer_context->SetShapeOrDataForValue(op->result(0), input_shape_or_data); | ||
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. 最好将Shape取出来单独设置,这里输入输出的data区应该不一样吧 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. 已修改 |
||
return true; | ||
} | ||
|
||
bool SigmoidCrossEntropyWithLogits_OpInferSymbolicShape( | ||
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { | ||
return SigmoidCrossEntropyWithLogitsOpInferSymbolicShape(op, infer_context); | ||
} | ||
|
||
// bool SyncBatchNormOpInferSymbolicShape(pir::Operation *op, | ||
// pir::InferSymbolicShapeContext | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,10 @@ OP_DECLARE_INFER_SYMBOLIC_SHAPE(SplitWithNum) | |
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Squeeze) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Squeeze_) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Sum) | ||
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(SetValueWithTensor) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(SetValue) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(SetValue_) | ||
Comment on lines
-102
to
+103
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. 这个PR没有给set_value在yaml中加接口,下一个PR可以顺带加一下(或者给加set_value的同学说一声) |
||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(SetValueWithTensor) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(SetValueWithTensor_) | ||
// OP_DECLARE_INFER_SYMBOLIC_SHAPE(Trace) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Tile) | ||
OP_DECLARE_INFER_SYMBOLIC_SHAPE(Topk) | ||
|
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.
直接对DimExpr添加约束,取int就默认是静态shape了