Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only import the LTC backend that's used in example models #939

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/ltc_backend_bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
import sys
from typing import List

import ltc_backend.ltc_backend._EXAMPLE_MLIR_BACKEND as ltc_backend
import torch
import torch._C
import torch._lazy
import torch._lazy.ts_backend
from datasets import load_dataset
from datasets.dataset_dict import DatasetDict
from torch.utils.data import DataLoader
Expand Down Expand Up @@ -146,9 +144,11 @@ def main(device='lazy', full_size=False):

if args.device in ("TS", "MLIR_EXAMPLE"):
if args.device == "TS":
import torch._lazy.ts_backend
torch._lazy.ts_backend.init()

elif args.device == "MLIR_EXAMPLE":
import ltc_backend.ltc_backend._EXAMPLE_MLIR_BACKEND as ltc_backend
ltc_backend._initialize()

device = "lazy"
Expand Down
4 changes: 2 additions & 2 deletions examples/ltc_backend_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import argparse
import sys

import ltc_backend.ltc_backend._EXAMPLE_MLIR_BACKEND as ltc_backend
import torch
import torch._lazy
import torch._lazy.ts_backend
import torch.nn.functional as F


Expand Down Expand Up @@ -91,9 +89,11 @@ def forward(self, x):

if args.device in ("TS", "MLIR_EXAMPLE"):
if args.device == "TS":
import torch._lazy.ts_backend
torch._lazy.ts_backend.init()

elif args.device == "MLIR_EXAMPLE":
import ltc_backend.ltc_backend._EXAMPLE_MLIR_BACKEND as ltc_backend
ltc_backend._initialize()

device = "lazy"
Expand Down