Repository navigation
【Infer Symbolic Shape No.127】[BUAA] CrfDecoding op - #67201
Merged
Merged
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
Contributor
Author
Comment on lines
+682
to
+688
| const auto &length_shape_or_data = | ||
| infer_context->GetShapeOrDataForValue(op->operand_source(3)); | ||
| bool has_length = !length_shape_or_data.shape().empty(); | ||
|
|
||
| const auto one = symbol::DimExpr{1}; | ||
|
|
||
| if (has_length) { |
Collaborator
There was a problem hiding this comment.
判断has_length的逻辑需修改,可以使用是否为NullShapeOrDataDimExpr来判断
Comment on lines
+717
to
+724
| if (m.isa<int64_t>() && n.isa<int64_t>()) { | ||
| int m_value = static_cast<int>(m.Get<std::int64_t>()); | ||
| int n_value = static_cast<int>(n.Get<std::int64_t>()); | ||
| if (m_value > 0 && n_value > 0) { | ||
| infer_context->AddEqualCstr(emission_dims[emission_dims.size() - 1], | ||
| transition_dims[transition_dims.size() - 1]); | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
infer meta里需要判断>0是因为-1为动态shape,这里直接添加对应约束即可
Comment on lines
+759
to
+766
| const symbol::DimExpr n1 = label_dims[0]; | ||
| if (m1.isa<int64_t>() && n1.isa<int64_t>()) { | ||
| int m1_value = static_cast<int>(m1.Get<std::int64_t>()); | ||
| int n1_value = static_cast<int>(n1.Get<std::int64_t>()); | ||
| if (m1_value > 0 && n1_value > 0) { | ||
| infer_context->AddEqualCstr(emission_dims[0], label_dims[0]); | ||
| } | ||
| } |
Comment on lines
1353
to
+1355
| // bool LstmOpInferSymbolicShape(pir::Operation *op, | ||
| // pir::InferSymbolicShapeContext *infer_context) | ||
| // pir::InferSymbolicShapeContext | ||
| // *infer_context) |
Collaborator
There was a problem hiding this comment.
自动format的工具注意一下,PR里尽量不要做出无关修改
zyfncg
reviewed
Aug 9, 2024
| pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { | ||
| const auto &emission_shape_or_data = | ||
| infer_context->GetShapeOrDataForValue(op->operand_source(0)); | ||
| std::vector<symbol::DimExpr> emission_dims = emission_shape_or_data.shape(); |
Collaborator
There was a problem hiding this comment.
emission_dims没有修改的话建议使用const std::vectorsymbol::DimExpr&, 以避免vector构建开销
|
|
||
| const auto &label_shape_or_data = | ||
| infer_context->GetShapeOrDataForValue(op->operand_source(2)); | ||
| std::vector<symbol::DimExpr> label_dims = label_shape_or_data.shape(); |
Hongqing-work
approved these changes
Aug 12, 2024
|
|
||
| // bool MoeOpInferSymbolicShape(pir::Operation *op, | ||
| // pir::InferSymbolicShapeContext *infer_context) { | ||
| // pir::InferSymbolicShapeContext *infer_context) |
| if (!length_shape_or_data.isa<symbol::NullShapeOrDataDimExpr>()) { | ||
| viterbi_path_dims.push_back(emission_dims[1]); | ||
| } else { | ||
| viterbi_path_dims.push_back(symbol::DimExpr(1)); |
| pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) { | ||
| const auto &emission_shape_or_data = | ||
| infer_context->GetShapeOrDataForValue(op->operand_source(0)); | ||
| const std::vector<symbol::DimExpr> emission_dims = |
|
|
||
| const auto &label_shape_or_data = | ||
| infer_context->GetShapeOrDataForValue(op->operand_source(2)); | ||
| const std::vector<symbol::DimExpr> label_dims = label_shape_or_data.shape(); |
gongshaotian
approved these changes
Aug 13, 2024
gongshaotian
left a comment
Contributor
There was a problem hiding this comment.
LGTM
规范性问题可以放到下个pr修改,贴出修改pr链接
Contributor
|
Description 描述不完善 |
33 of 35 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

PR Category
CINNPR Types
OthersDescription
添加了CrfDecoding算子,感觉中等难度的比较难,所以先提交了一个。
test/legacy_test/test_crf_decoding_op.py 已经包含 check_test_output