-
Notifications
You must be signed in to change notification settings - Fork 24.7k
[MPS] Extend torch.mm
/torch.bmm
to integral types
#145809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/145809
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 49 PendingAs of commit b15f4af with merge base 6b41f31 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Debug script import torch
import os
os.environ["MTL_CAPTURE_ENABLED"]="1"
torch.manual_seed(42)
x = torch.testing.make_tensor([10,], dtype=torch.int16, device="mps")
y = torch.testing.make_tensor([5, 10, 5], dtype=torch.int16, device="mps")
# x = torch.ones((5, 1, 10,), dtype=torch.int16, device="mps")
#x = torch.randint(-1, 3, (10,), dtype=torch.int16, device="mps")
#y = torch.arange(250, dtype=torch.int16, device="mps").reshape(5, 10, 5)
#with torch.device("mps"):
# x=torch.arange(15, dtype=torch.int16).reshape(3, 5, 1)
# y=torch.arange(18, dtype=torch.int16).reshape(3, 1, 6)
# print(x.stride(), y.stride())
#with torch.mps.profiler.metal_capture("bmm"):
# z = torch.matmul(x, y)
print(x)
print(y)
z = torch.matmul(x, y)
print(x.stride(), y.stride())
print(z)
print(torch.matmul(x.cpu(), y.cpu())) |
torch.mm
to integral typestorch.mm
/torch.bmm
to integral types
@pytorchbot merge -f "Lint + MPS are green" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
torch.mm
/torch.bmm
to integral types #145809By using
naive_mm
kernel, but make sure that accumulation is done over int32 for smaller int types (and float for half and bfloat) as well as addingnavie_bmm
that follows the same pattern.Remove stale restriction on
torch.dot
(which works fine on MacOS-14/15)This also enables integer op flavors for:
addmv
einsum
inner
linalg.multi_dot
matmul
mv
tensordot