Skip to content

Commit

Permalink
Merge pull request #234 from google-ai-edge/pytorchoptional
Browse files Browse the repository at this point in the history
Show pytorch adapter even if torch in not imported.
  • Loading branch information
jinjingforever authored Nov 4, 2024
2 parents 6aa67b6 + d4cb9db commit a48865d
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/server/package/src/model_explorer/extension_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
from importlib import import_module
from typing import Any, Dict, Union

try:
import torch
except ImportError:
torch = None

from .adapter_runner import AdapterRunner
from .consts import MODULE_NAME
from .extension_class_processor import ExtensionClassProcessor
Expand All @@ -34,19 +29,15 @@


class ExtensionManager(object, metaclass=Singleton):
BUILTIN_ADAPTER_MODULES: list[str] = (
[
'.builtin_tflite_flatbuffer_adapter',
'.builtin_tflite_mlir_adapter',
'.builtin_tf_mlir_adapter',
'.builtin_tf_direct_adapter',
'.builtin_graphdef_adapter',
]
+ (['.builtin_pytorch_exportedprogram_adapter'] if torch else [])
+ [
'.builtin_mlir_adapter',
]
)
BUILTIN_ADAPTER_MODULES: list[str] = [
'.builtin_tflite_flatbuffer_adapter',
'.builtin_tflite_mlir_adapter',
'.builtin_tf_mlir_adapter',
'.builtin_tf_direct_adapter',
'.builtin_graphdef_adapter',
'.builtin_pytorch_exportedprogram_adapter',
'.builtin_mlir_adapter',
]

CACHED_REGISTERED_EXTENSIONS: Dict[str, RegisteredExtension] = {}

Expand Down

0 comments on commit a48865d

Please sign in to comment.