2022-11-30 11:19:09 +08:00
|
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
# Also available under a BSD-style license. See LICENSE.
|
|
|
|
|
|
|
|
# RUN: %PYTHON %s | FileCheck %s
|
|
|
|
|
|
|
|
import functorch
|
|
|
|
import torch
|
|
|
|
|
2024-02-07 11:07:59 +08:00
|
|
|
from torch_mlir import torchscript
|
2022-11-30 11:19:09 +08:00
|
|
|
|
2024-04-28 05:16:31 +08:00
|
|
|
|
2022-11-30 11:19:09 +08:00
|
|
|
def simple(x):
|
|
|
|
return x * x
|
|
|
|
|
2024-04-28 05:16:31 +08:00
|
|
|
|
|
|
|
example_input = torch.randn(
|
|
|
|
1,
|
|
|
|
)
|
|
|
|
graph = functorch.make_fx(simple)(
|
|
|
|
torch.randn(
|
|
|
|
1,
|
|
|
|
)
|
|
|
|
)
|
2022-11-30 11:19:09 +08:00
|
|
|
|
|
|
|
# Simplest case: One example argument.
|
2024-02-07 11:07:59 +08:00
|
|
|
print(torchscript.compile(graph, example_input))
|
2022-11-30 11:19:09 +08:00
|
|
|
# CHECK-LABEL: @forward
|
2024-04-28 05:16:31 +08:00
|
|
|
# CHECK: torch.aten.mul.Tensor %{{.*}} : !torch.vtensor<[1],f32>, !torch.vtensor<[1],f32> -> !torch.vtensor<[1],f32>
|