CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
pytorch

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: pytorch/tutorials
Path: blob/main/advanced_source/dispatcher/test.py
Views: 494
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