areusch commented on a change in pull request #9074:
URL: https://github.com/apache/tvm/pull/9074#discussion_r728237125
##########
File path: python/tvm/driver/tvmc/frontends.py
##########
@@ -88,10 +96,54 @@ def import_keras():
from tensorflow import keras
return tf, keras
+ except ImportError:
+ raise TVMCException(create_import_error_string("Tensorflow",
"tensorflow"))
finally:
sys.stderr = stderr
+def import_onnx():
+ """Lazy import function for onnx"""
+ try:
+ # pylint: disable=C0415
+ import onnx as _onnx
+ except ImportError:
+ raise TVMCException(create_import_error_string("ONNX", "onnx"))
+ return _onnx
+
+
+def import_tensorflow():
+ """Lazy import function for tensorflow"""
+ try:
+ # pylint: disable=C0415
+ import tensorflow as tf
+ except ImportError:
+ raise TVMCException(create_import_error_string("Tensorflow",
"tensorflow"))
+ return tf
+
+
+def import_torch():
+ """Lazy import function for torch"""
+ try:
+ # pylint: disable=C0415
+ import torch as tc
+ except ImportError:
+ raise TVMCException(create_import_error_string("Torch", "torch"))
Review comment:
i'd suggest we either say the following or eliminate the first parameter
here.
```suggestion
raise TVMCException(create_import_error_string("PyTorch", "torch"))
```
##########
File path: tests/python/driver/tvmc/test_frontends.py
##########
@@ -211,3 +212,43 @@ def
test_load_model___wrong_language__to_pytorch(tflite_mobilenet_v1_1_quant):
model_format="pytorch",
shape_dict={"input": [1, 3, 224, 224]},
)
+
+
[email protected]("tvm.driver.tvmc.frontends.import_keras")
+def test_import_keras_friendly_message(import_keras_mock, keras_resnet50):
Review comment:
@ophirfrish could you look at this one? i think we don't need
importorskip after all.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]