Skip to content

Commit ff3e3b2

Browse files
committed
fix: A16MatMul w4a16 no group will switch to group 128
- if w4a16 has no group, will switch to group 128 Change-Id: I4e4357fdf3221489739cae39bc3606e808bd50ad
1 parent 05bf8b3 commit ff3e3b2

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

hooks/pre-commit

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ fi
2626
if [ -n "$c_files" ]; then
2727
echo "Running clang-format on staged files..."
2828
clang-format -i $c_files
29-
if ! git diff --quiet; then
29+
if ! git diff --quiet -- $c_files; then
3030
echo -e "${RED}Warning${NC}: Some cpp files were formatted. Please review the changes and then commit it again."
31-
# git add $files
31+
# git add $c_files
3232
exit 1
3333
fi
3434
fi
@@ -43,9 +43,9 @@ if [ -n "$py_files" ]; then
4343
echo -e "${RED}ERROR${NC}: yapf failed. Please check your code"
4444
exit 1
4545
fi
46-
if ! git diff --quiet; then
46+
if ! git diff --quiet -- $py_files; then
4747
echo -e "${RED}Warning${NC}: Some python files were formatted. Please review the changes and then commit it again."
48-
# git add $files
48+
# git add $py_files
4949
exit 1
5050
fi
5151
fi

lib/Dialect/Tpu/Canonicalize/A16MatMul.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,6 @@ struct A16MatMulToGroup : public OpRewriterPatternEx<tpu::A16MatMulOp> {
403403
if (group_size > 0) {
404404
return failure();
405405
}
406-
if (op.getWeightBits() != 8) {
407-
return failure();
408-
}
409406

410407
auto scaleOp = op.getScale().getDefiningOp<top::WeightOp>();
411408
auto zpOp = op.getZp().getDefiningOp<top::WeightOp>();
@@ -421,7 +418,7 @@ struct A16MatMulToGroup : public OpRewriterPatternEx<tpu::A16MatMulOp> {
421418
return failure();
422419
}
423420
auto weightShape = module::getShape(op.getWeight());
424-
int K = weightShape[1];
421+
int K = weightShape[1] * (8 / op.getWeightBits());
425422
int tile = K / 128;
426423
std::vector<int64_t> scale_shape = module::getShape(scaleOp.getResult());
427424
std::vector<int64_t> zp_shape = module::getShape(zpOp.getResult());

0 commit comments

Comments
 (0)