Initial project scaffold
This commit is contained in:
13
reference/torch_matmul.py
Normal file
13
reference/torch_matmul.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import torch
|
||||
|
||||
|
||||
def torch_matmul(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
|
||||
"""Reference matrix multiplication with simple shape validation."""
|
||||
if a.ndim != 2 or b.ndim != 2:
|
||||
raise ValueError("torch_matmul expects two 2D tensors")
|
||||
if a.shape[1] != b.shape[0]:
|
||||
raise ValueError(f"incompatible shapes: {a.shape} and {b.shape}")
|
||||
return a @ b
|
||||
|
||||
Reference in New Issue
Block a user