Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions torchao/prototype/tensor_conversion/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,16 @@ def _find_tied_params(model):


def _convert_model_for_aarch64(
model, *, tensor_type="auto", intx_packing_format="opaque_torchao_auto"
model,
*,
tensor_type="auto",
intx_packing_format="opaque_torchao_auto",
convert_tied_embedding=True,
convert_linear=True,
):
module_name_to_tied_param = _find_tied_params(model)
module_name_to_tied_param = (
_find_tied_params(model) if convert_tied_embedding else {}
)

# Iterate through modules in model and convert IntxUnpackedToInt8Tensor tensors to Int8LutTensor
for name, module in model.named_modules():
Expand All @@ -138,7 +145,7 @@ def _convert_model_for_aarch64(
print("Skipping converting nn.Embedding {name} because it is not tied")
continue

if not isinstance(module, nn.Linear):
if not (convert_linear and isinstance(module, nn.Linear)):
continue

weight = module.weight
Expand Down
Loading