MCPcopy Create free account
hub / github.com/bitsandbytes-foundation/bitsandbytes / int8_linear_matmul

Function int8_linear_matmul

bitsandbytes/functional.py:1536–1559  ·  view source on GitHub ↗

Performs an 8-bit integer matrix multiplication. A linear transformation is applied such that `out = A @ B.T`. When possible, integer tensor core hardware is utilized to accelerate the operation. Args: A (`torch.Tensor`): The first matrix operand with the data type `torch.int8`

(A: torch.Tensor, B: torch.Tensor, out: Optional[torch.Tensor] = None, dtype=torch.int32)

Source from the content-addressed store, hash-verified

1534
1535
1536def int8_linear_matmul(A: torch.Tensor, B: torch.Tensor, out: Optional[torch.Tensor] = None, dtype=torch.int32):
1537 """Performs an 8-bit integer matrix multiplication.
1538
1539 A linear transformation is applied such that `out = A @ B.T`. When possible, integer tensor core hardware is
1540 utilized to accelerate the operation.
1541
1542 Args:
1543 A (`torch.Tensor`): The first matrix operand with the data type `torch.int8`.
1544 B (`torch.Tensor`): The second matrix operand with the data type `torch.int8`.
1545 out (`torch.Tensor`, *optional*): A pre-allocated tensor used to store the result.
1546 dtype (`torch.dtype`, *optional*): The expected data type of the output. Defaults to `torch.int32`.
1547
1548 Raises:
1549 `NotImplementedError`: The operation is not supported in the current environment.
1550 `RuntimeError`: Raised when the cannot be completed for any other reason.
1551
1552 Returns:
1553 `torch.Tensor`: The result of the operation.
1554 """
1555 if out is not None:
1556 torch.ops.bitsandbytes.int8_linear_matmul.out(A, B, out)
1557 return out
1558
1559 return torch.ops.bitsandbytes.int8_linear_matmul.default(A, B)
1560
1561
1562def int8_mm_dequant(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected