mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
[BugFix] Add support for weight shape constraints and group size selection in Machete (#4911)
This commit is contained in:
@@ -35,6 +35,24 @@ if current_platform.is_cuda() and get_sm_version() == 90:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
MACHETE_PREPACKED_BLOCK_SHAPE = [64, 128]
|
||||
|
||||
|
||||
def check_machete_supports_shape(in_features, out_featrues):
|
||||
if in_features and in_features % MACHETE_PREPACKED_BLOCK_SHAPE[0] != 0:
|
||||
return False
|
||||
if out_featrues and out_featrues % MACHETE_PREPACKED_BLOCK_SHAPE[1] != 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def query_machete_supported_group_size(in_features):
|
||||
if in_features % 128 == 0:
|
||||
return 128
|
||||
elif in_features % 64 == 0:
|
||||
return 64
|
||||
return -1
|
||||
|
||||
|
||||
def get_pack_factor(num_bits):
|
||||
assert 32 % num_bits == 0, f"Unsupported num_bits = {num_bits}"
|
||||
|
||||
Reference in New Issue
Block a user