CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
pytorch

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: pytorch/tutorials
Path: blob/main/advanced_source/dispatcher/test.py
Views: 713
1
import torch
2
3
torch.ops.load_library("build/libdispatcher.so")
4
print(torch.ops.myops.myadd(torch.randn(32, 32), torch.rand(32, 32)))
5
"""
6
# Doesn't currently work, because Python frontend on torch.ops doesn't
7
# support names (for not a good reason?)
8
x = torch.randn(32, 32, names=('A', 'B'))
9
y = torch.rand(32, 32, names=('A', 'B'))
10
print(torch.ops.myops.myadd(x, y))
11
"""
12
13