Skip to content

Commit

Permalink
Remove "torchscript" association from the e2e framework.
Browse files Browse the repository at this point in the history
We use it for more than TorchScript testing now. This is a purely
mechanical change to adjust some file paths to remove "torchscript".

The most perceptible change here is that now e2e tests are run with

```
./tools/e2e_test.sh
instead of:
./tools/torchscript_e2e_test.sh
```
  • Loading branch information
silvasean committed Aug 29, 2022
1 parent f402eb2 commit e16b43e
Show file tree
Hide file tree
Showing 70 changed files with 170 additions and 192 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,29 @@ jobs:
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
run: |
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=refbackend -v
python -m e2e_testing.main --config=refbackend -v
- name: Run eager_mode e2e integration tests
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
run: |
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=eager_mode -v
python -m e2e_testing.main --config=eager_mode -v
- name: Run mhlo e2e integration tests
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
run: |
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=mhlo -v
python -m e2e_testing.main --config=mhlo -v
- name: Run tosa e2e integration tests
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
run: |
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
python -m e2e_testing.torchscript.main --config=tosa -v
python -m e2e_testing.main --config=tosa -v
- name: Run lazy_tensor_core e2e integration tests
if: ${{ matrix.os-arch == 'ubuntu-x86_64' && matrix.llvm-build == 'in-tree' }}
run: |
export PYTHONPATH="$GITHUB_WORKSPACE/build/tools/torch-mlir/python_packages/torch_mlir"
echo "LTC tests disabled temporarily. https://github.com/llvm/torch-mlir/pull/1292"
# python -m e2e_testing.torchscript.main --config=lazy_tensor_core -v
# python -m e2e_testing.main --config=lazy_tensor_core -v
10 changes: 5 additions & 5 deletions build_tools/torchscript_e2e_heavydep_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ self-contained virtual environment. It can be used like so:
# serialized test artifacts in the other specified directory.
# This command is safe to re-run if you have already built the virtual
# environment and just changed the tests.
build_tools/torchscript_e2e_heavydep_tests/generate_serialized_tests.sh \
build_tools/e2e_heavydep_tests/generate_serialized_tests.sh \
path/to/heavydep_venv \
path/to/heavydep_serialized_tests

# Add the --serialized-test-dir flag to point at the directory containing the
# serialized tests. All other functionality is the same as the normal invocation
# of torchscript_e2e_test.sh, but the serialized tests will be available.
tools/torchscript_e2e_test.sh --serialized-test-dir=path/to/heavydep_serialized_tests
# of e2e_test.sh, but the serialized tests will be available.
tools/e2e_test.sh --serialized-test-dir=path/to/heavydep_serialized_tests
```

The tests use the same (pure-Python) test framework as the normal
torchscript_e2e_test.sh, but the tests are added in
`build_tools/torchscript_e2e_heavydep_tests` instead of
e2e_test.sh, but the tests are added in
`build_tools/e2e_heavydep_tests` instead of
`frontends/pytorch/e2e_testing/torchscript`.

We rely critically on serialized TorchScript compatibility across PyTorch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ cd "$torch_mlir_src_root"
export PYTHONPATH=${PYTHONPATH-}
source "$torch_mlir_src_root/.env"

python3 -m build_tools.torchscript_e2e_heavydep_tests.main --output_dir="$serialized_test_dir"
python3 -m build_tools.e2e_heavydep_tests.main --output_dir="$serialized_test_dir"
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

from torch_mlir_e2e_test.torchscript.framework import TestUtils
from torch_mlir_e2e_test.torchscript.registry import register_test_case
from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export
from torch_mlir_e2e_test.framework import TestUtils
from torch_mlir_e2e_test.registry import register_test_case
from torch_mlir_e2e_test.annotations import annotate_args, export

torch.manual_seed(0)

Expand Down
2 changes: 1 addition & 1 deletion build_tools/torchscript_e2e_heavydep_tests/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import argparse

from torch_mlir_e2e_test.torchscript.serialization import serialize_all_tests_to
from torch_mlir_e2e_test.serialization import serialize_all_tests_to

from . import hf_sequence_classification
from . import vision_models
Expand Down
6 changes: 3 additions & 3 deletions build_tools/torchscript_e2e_heavydep_tests/train_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from torch.nn.utils import _stateless
from transformers import AutoTokenizer, AutoModelForSequenceClassification

from torch_mlir_e2e_test.torchscript.framework import TestUtils
from torch_mlir_e2e_test.torchscript.registry import register_test_case
from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export
from torch_mlir_e2e_test.framework import TestUtils
from torch_mlir_e2e_test.registry import register_test_case
from torch_mlir_e2e_test.annotations import annotate_args, export

from torch import fx
import copy
Expand Down
6 changes: 3 additions & 3 deletions build_tools/torchscript_e2e_heavydep_tests/vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import torch
import torchvision.models as models

from torch_mlir_e2e_test.torchscript.framework import TestUtils
from torch_mlir_e2e_test.torchscript.registry import register_test_case
from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export
from torch_mlir_e2e_test.framework import TestUtils
from torch_mlir_e2e_test.registry import register_test_case
from torch_mlir_e2e_test.annotations import annotate_args, export
import timm

torch.manual_seed(0)
Expand Down
10 changes: 5 additions & 5 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ Torch-MLIR has two types of tests:

```shell
# Run all tests on the reference backend
./tools/torchscript_e2e_test.sh
./tools/e2e_test.sh
# Run tests that match the regex `Conv2d`, with verbose errors.
./tools/torchscript_e2e_test.sh --filter Conv2d --verbose
./tools/e2e_test.sh --filter Conv2d --verbose
# Run tests on the TOSA backend.
./tools/torchscript_e2e_test.sh --config tosa
./tools/e2e_test.sh --config tosa
```

## Running unit tests.
Expand Down Expand Up @@ -310,10 +310,10 @@ Here are some examples of PRs updating the LLVM and MLIR-HLO submodules:

To enable ASAN, pass `-DLLVM_USE_SANITIZER=Address` to CMake. This should "just
work" with all C++ tools like `torch-mlir-opt`. When running a Python script
such as through `./tools/torchscript_e2e_test.sh`, you will need to do:
such as through `./tools/e2e_test.sh`, you will need to do:

```
LD_PRELOAD="$(clang -print-file-name=libclang_rt.asan-x86_64.so)" ./tools/torchscript_e2e_test.sh -s
LD_PRELOAD="$(clang -print-file-name=libclang_rt.asan-x86_64.so)" ./tools/e2e_test.sh -s
# See instructions here for how to get the libasan path for GCC:
# https://stackoverflow.com/questions/48833176/get-location-of-libasan-from-gcc-clang
```
Expand Down
12 changes: 6 additions & 6 deletions e2e_testing/torchscript/main.py → e2e_testing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import re
import sys

from torch_mlir_e2e_test.torchscript.framework import run_tests
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.serialization import deserialize_all_tests_from
from torch_mlir_e2e_test.framework import run_tests
from torch_mlir_e2e_test.reporting import report_results
from torch_mlir_e2e_test.registry import GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.serialization import deserialize_all_tests_from


# Available test configs.
from torch_mlir_e2e_test.torchscript.configs import (
from torch_mlir_e2e_test.configs import (
LazyTensorCoreTestConfig,
LinalgOnTensorsBackendTestConfig,
MhloBackendTestConfig,
Expand Down Expand Up @@ -62,7 +62,7 @@ def _get_argparse():
Right now, these are additional tests which require heavy Python dependencies
to generate (or cannot even be generated with the version of PyTorch used by
torch-mlir).
See `build_tools/torchscript_e2e_heavydep_tests/generate_serialized_tests.sh`
See `build_tools/e2e_heavydep_tests/generate_serialized_tests.sh`
for more information on building these artifacts.
''')
parser.add_argument('-s', '--sequential',
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion python/test/annotations-sugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import torch

from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export
from torch_mlir_e2e_test.annotations import annotate_args, export
from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator
from torch_mlir.dialects.torch.importer.jit_ir.torchscript_annotations import extract_annotations

Expand Down
8 changes: 4 additions & 4 deletions python/test/torchscript_e2e_test/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import run_tests, TestUtils
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import register_test_case, GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.configs import TorchScriptTestConfig
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


class MmModule(torch.nn.Module):
Expand Down
8 changes: 4 additions & 4 deletions python/test/torchscript_e2e_test/compilation_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import run_tests, TestUtils
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import register_test_case, GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.configs import TorchScriptTestConfig
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


class MmModule(torch.nn.Module):
Expand Down
8 changes: 4 additions & 4 deletions python/test/torchscript_e2e_test/error_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import run_tests, TestUtils
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import register_test_case, GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.configs import TorchScriptTestConfig
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

# CHECK: Unexpected outcome summary:
# CHECK: FAIL - "ErroneousModule_basic"
Expand Down
8 changes: 4 additions & 4 deletions python/test/torchscript_e2e_test/non_tensor_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import run_tests, TestUtils
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import register_test_case, GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.configs import TorchScriptTestConfig
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


class NonTensorValuesModule(torch.nn.Module):
Expand Down
8 changes: 4 additions & 4 deletions python/test/torchscript_e2e_test/runtime_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import run_tests, TestUtils
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import register_test_case, GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.configs import TorchScriptTestConfig
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


class MmModule(torch.nn.Module):
Expand Down
8 changes: 4 additions & 4 deletions python/test/torchscript_e2e_test/submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import run_tests, TestUtils
from torch_mlir_e2e_test.torchscript.reporting import report_results
from torch_mlir_e2e_test.torchscript.registry import register_test_case, GLOBAL_TEST_REGISTRY
from torch_mlir_e2e_test.torchscript.configs import TorchScriptTestConfig
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

class Submodule2(torch.nn.Module):
def __init__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# to be expressed conveniently and gives clearer error reports when
# the annotations aren't acceptable.

# This module is kept separate from torch_mlir_e2e_test.torchscript.annotations so that
# This module is kept separate from torch_mlir_e2e_test.annotations so that
# we can use that module from code without C++ dependencies, which prevent us
# from interfacing the test framework across environments.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from torch.utils._pytree import tree_map

from torch_mlir.eager_mode.torch_mlir_tensor import TorchMLIRTensor
from torch_mlir_e2e_test.torchscript.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.framework import TestConfig, Trace, TraceItem


def wrap(e):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch
from torch.utils._pytree import tree_map

from torch_mlir_e2e_test.torchscript.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.framework import TestConfig, Trace, TraceItem


def to_device(device):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import torch_mlir

from torch_mlir_e2e_test.linalg_on_tensors_backends.abc import LinalgOnTensorsBackend
from torch_mlir_e2e_test.torchscript.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.utils import convert_annotations_to_placeholders

from .utils import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import torch_mlir

from torch_mlir_e2e_test.mhlo_backends.abc import MhloBackend
from torch_mlir_e2e_test.torchscript.framework import (
from torch_mlir_e2e_test.framework import (
TestConfig,
Trace,
TraceItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.framework import TestConfig, Trace, TraceItem


class NativeTorchTestConfig(TestConfig):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.framework import TestConfig, Trace, TraceItem


class TorchScriptTestConfig(TestConfig):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import torch_mlir

from torch_mlir_e2e_test.tosa_backends.abc import TosaBackend
from torch_mlir_e2e_test.torchscript.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.framework import TestConfig, Trace, TraceItem
from torch_mlir_e2e_test.utils import convert_annotations_to_placeholders
from .utils import (
recursively_convert_to_numpy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Also available under a BSD-style license. See LICENSE.

import sys
from typing import Any
from io import StringIO

import numpy as np
import torch

from torch_mlir.dialects.torch.importer.jit_ir import ClassAnnotator, ModuleBuilder
from torch_mlir.dialects.torch.importer.jit_ir.torchscript_annotations import extract_annotations
from torch_mlir.compiler_utils import run_pipeline_with_repro_report


def recursively_convert_to_numpy(o: Any):
if isinstance(o, torch.Tensor):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions python/torch_mlir_e2e_test/test_suite/arange.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import TestUtils
from torch_mlir_e2e_test.torchscript.registry import register_test_case
from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export
from torch_mlir_e2e_test.framework import TestUtils
from torch_mlir_e2e_test.registry import register_test_case
from torch_mlir_e2e_test.annotations import annotate_args, export

# ==============================================================================

Expand Down
7 changes: 3 additions & 4 deletions python/torch_mlir_e2e_test/test_suite/argmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import torch

from torch_mlir_e2e_test.torchscript.framework import TestUtils
from torch_mlir_e2e_test.torchscript.registry import register_test_case
from torch_mlir_e2e_test.torchscript.annotations import annotate_args, export
from torch_mlir_e2e_test.framework import TestUtils
from torch_mlir_e2e_test.registry import register_test_case
from torch_mlir_e2e_test.annotations import annotate_args, export

# ==============================================================================

Expand Down Expand Up @@ -63,4 +63,3 @@ def forward(self, a):
@register_test_case(module_factory=lambda: ArgmaxKeepDimsModule())
def ArgmaxModule_keepDim(module, tu: TestUtils):
module.forward(tu.rand(4, 6))

Loading

0 comments on commit e16b43e

Please sign in to comment.