Files
SHARK-Studio/amdshark/examples/amdshark_dynamo/basic_examples.py
pdhirajkumarprasad 6d80b43b6b Migration to AMDShark
Signed-off-by: pdhirajkumarprasad <dhirajp@amd.com>
2025-11-20 12:46:36 +05:30

26 lines
358 B
Python

import torch
import amdshark
def foo(x, a):
if x.shape[0] > 3:
return x + a
else:
return x + 3
amdshark_options = {"device": "cpu"}
compiled = torch.compile(foo, backend="amdshark", options=amdshark_options)
input = torch.ones(4)
x = compiled(input, input)
print(x)
input = torch.ones(3)
x = compiled(input, input)
print(x)