Move the graph fusion before AddInitial() for constant operands#238
Open
lisa0314 wants to merge 1 commit intoshiyi9801:ort_backendfrom
Open
Move the graph fusion before AddInitial() for constant operands#238lisa0314 wants to merge 1 commit intoshiyi9801:ort_backendfrom
lisa0314 wants to merge 1 commit intoshiyi9801:ort_backendfrom
Conversation
huningxin
reviewed
Jun 24, 2025
| @@ -869,6 +873,35 @@ GraphFusionInfo GetGraphFusionInfo(const mojom::GraphInfo& graph_info) { | |||
| graph_fusion_info.matmul_input_b_to_fusible_dequantize_map | |||
| [transpose->get_transpose()->output_operand_id] = operation.get(); | |||
|
|
|||
Collaborator
There was a problem hiding this comment.
Worth adding a comment explaining why it needs to change the data type.
| dequantize_linear->label); | ||
| auto new_input_constant = std::make_unique<WebNNConstantOperand>( | ||
| std::move(new_input_desc), input_constant->TakeData()); | ||
| constant_operands[dequantize_linear->input_operand_id] = |
Collaborator
There was a problem hiding this comment.
You may want to check this constant is only used by dequantizeLinear before replacing it.
| uint32_t blob_bytes = input_shape[2] / 2; | ||
| auto input_constant = std::move( | ||
| constant_operands.at(dequantize_linear->input_operand_id)); | ||
| std::vector<uint32_t> new_input_buffer_shape = {input_feature_size, |
Collaborator
There was a problem hiding this comment.
Move this line right after declaring blob_bytes
| uint32_t input_feature_size = input_shape[0]; | ||
| uint32_t quant_num = input_shape[1]; | ||
| uint32_t blob_bytes = input_shape[2] / 2; | ||
| auto input_constant = std::move( |
Collaborator
There was a problem hiding this comment.
std::move is unnecessary? I guess std::move a reference would result in a copying.
| constant_operands[dequantize_linear->input_operand_id] = | ||
| std::move(new_input_constant); | ||
|
|
||
| auto zero_point_constant = std::move( |
Collaborator
There was a problem hiding this comment.
Same here, std::move seems to be unnecessary.
|
|
||
| auto zero_point_constant = std::move( | ||
| constant_operands.at(dequantize_linear->zero_point_operand_id)); | ||
| std::vector<uint32_t> new_zero_point_buffer_shape = { |
Collaborator
There was a problem hiding this comment.
Suggested change
| std::vector<uint32_t> new_zero_point_buffer_shape = { | |
| std::vector<uint32_t> new_zero_point_shape = { |
Collaborator
|
/cc @wangw-1991 |
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.
@huningxin PTAL.
Fix #237