tlopex commented on code in PR #20243:
URL: https://github.com/apache/tvm/pull/20243#discussion_r3909687607
##########
src/relax/transform/combine_parallel_matmul.cc:
##########
@@ -210,6 +217,25 @@ ffi::TypedFunction<ffi::Map<Var, Expr>(ffi::Map<DFPattern,
Var>, ffi::Map<Var, E
continue;
}
+ if (branch_info.bias_dim) {
+ std::vector<ffi::Array<PrimExpr>> bias_shapes;
+ bool bias_shape_unknown = false;
+ for (const auto& bias_var : bias) {
+ auto bias_shape_opt = GetTensorType(bias_var)->GetShape();
+ if (!bias_shape_opt) {
+ bias_shape_unknown = true;
+ break;
+ }
+ bias_shapes.push_back(bias_shape_opt.value());
+ }
+ if (bias_shape_unknown) {
+ return ffi::Map<Var, Expr>{};
+ }
+ if (!shapes_compatible_excluding_trailing_axes(bias_shapes, 1)) {
Review Comment:
Please also require each bias’s last dimension to match the corresponding
`splits[i].split_size`. For weights `[3,4]`/`[3,5]` and biases `[2,1]`/`[2,1]`,
both original adds are valid via broadcasting, but this check passes and
produces a `[2,2]` concatenated bias that cannot broadcast to the combined
`[2,9]` output. This case should skip fusion, with a regression test added.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]