Fix the conflict of Tensorflow1.15 and PyTorch1.8.0
@@ -184,6 +184,10 @@ class TestGraphOptimization(unittest.TestCase):
os.remove('fake_yaml_4.yaml')
def test_not_supported_model(self):
+ import neural_compressor.adaptor.pytorch as nc_torch
+ from neural_compressor.adaptor.pytorch import PyTorchVersionMode
+ PT_VERSION = nc_torch.get_torch_version()
+ if PT_VERSION != PyTorchVersionMode.PT18.value:
import torchvision
model = torchvision.models.resnet18()
from neural_compressor.experimental import Graph_Optimization
@@ -195,8 +199,14 @@ class TestGraphOptimization(unittest.TestCase):
output_graph = graph_optimizer.fit()
except SystemExit:
pass
+ else:
+ pass
def test_not_supported_model_without_yaml(self):
+ import neural_compressor.adaptor.pytorch as nc_torch
+ from neural_compressor.adaptor.pytorch import PyTorchVersionMode
+ PT_VERSION = nc_torch.get_torch_version()
+ if PT_VERSION != PyTorchVersionMode.PT18.value:
import torchvision
model = torchvision.models.resnet18()
from neural_compressor.experimental import Graph_Optimization
@@ -207,8 +217,14 @@ class TestGraphOptimization(unittest.TestCase):
graph_optimizer.model = model
except SystemExit:
pass
+ else:
+ pass
def test_not_supported_model_with_conf(self):
+ import neural_compressor.adaptor.pytorch as nc_torch
+ from neural_compressor.adaptor.pytorch import PyTorchVersionMode
+ PT_VERSION = nc_torch.get_torch_version()
+ if PT_VERSION != PyTorchVersionMode.PT18.value:
from neural_compressor.experimental import Graph_Optimization
from neural_compressor import conf
import torchvision
@@ -222,7 +238,8 @@ class TestGraphOptimization(unittest.TestCase):
graph_optimizer.model = model
except SystemExit:
pass
-
+ else:
+ pass
@disable_random()
