2021-09-30 00:03:40 +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.
|
2021-04-20 06:12:29 +08:00
|
|
|
|
|
|
|
# RUN: %PYTHON %s | FileCheck %s
|
|
|
|
|
|
|
|
import torch
|
|
|
|
|
2022-08-30 04:32:18 +08:00
|
|
|
from torch_mlir_e2e_test.framework import run_tests, TestUtils
|
|
|
|
from torch_mlir_e2e_test.reporting import report_results
|
|
|
|
from torch_mlir_e2e_test.registry import register_test_case, GLOBAL_TEST_REGISTRY
|
|
|
|
from torch_mlir_e2e_test.configs import TorchScriptTestConfig
|
2021-04-20 06:12:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
class MmModule(torch.nn.Module):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
def forward(self, lhs, rhs):
|
|
|
|
return torch.mm(lhs, rhs)
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: Refine messages.
|
2021-07-01 05:13:21 +08:00
|
|
|
# CHECK: PASS - "MmModule_basic"
|
2021-04-20 06:12:29 +08:00
|
|
|
@register_test_case(module_factory=lambda: MmModule())
|
|
|
|
def MmModule_basic(module, tu: TestUtils):
|
|
|
|
module.forward(tu.rand(4, 4), tu.rand(4, 4))
|
|
|
|
|
|
|
|
|
2021-07-01 05:13:21 +08:00
|
|
|
# CHECK: PASS - "MmModule_basic2"
|
2021-04-21 05:45:43 +08:00
|
|
|
@register_test_case(module_factory=lambda: MmModule())
|
|
|
|
def MmModule_basic2(module, tu: TestUtils):
|
|
|
|
module.forward(tu.rand(4, 4), tu.rand(4, 4))
|
|
|
|
|
|
|
|
|
2021-04-20 06:12:29 +08:00
|
|
|
def main():
|
|
|
|
config = TorchScriptTestConfig()
|
|
|
|
results = run_tests(GLOBAL_TEST_REGISTRY, config)
|
2021-08-11 07:10:31 +08:00
|
|
|
report_results(results, set(), verbose=True)
|
2021-04-20 06:12:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|