|
41 | 41 | from optimum.intel.openvino.utils import _HEAD_TO_AUTOMODELS
|
42 | 42 |
|
43 | 43 |
|
| 44 | +try: |
| 45 | + |
| 46 | + OV_TOKENIZERS_NOT_AVAILABLE = False |
| 47 | +except Exception: |
| 48 | + OV_TOKENIZERS_NOT_AVAILABLE = True |
| 49 | + |
| 50 | + |
44 | 51 | class OVCLIExportTestCase(unittest.TestCase):
|
45 | 52 | """
|
46 | 53 | Integration tests ensuring supported models are correctly exported.
|
@@ -117,18 +124,22 @@ def test_exporters_cli(self, task: str, model_type: str):
|
117 | 124 | for arch in SUPPORTED_ARCHITECTURES
|
118 | 125 | if not arch[0].endswith("-with-past") and not arch[1].endswith("-refiner")
|
119 | 126 | )
|
| 127 | + @unittest.skipIf(OV_TOKENIZERS_NOT_AVAILABLE, reason="OpenVINO Tokenizers not available") |
120 | 128 | def test_exporters_cli_tokenizers(self, task: str, model_type: str):
|
121 | 129 | with TemporaryDirectory() as tmpdir:
|
122 |
| - subprocess.run( |
| 130 | + output = subprocess.check_output( |
123 | 131 | f"optimum-cli export openvino --model {MODEL_NAMES[model_type]} --task {task} {tmpdir}",
|
124 | 132 | shell=True,
|
125 |
| - check=True, |
126 |
| - ) |
| 133 | + stderr=subprocess.STDOUT, |
| 134 | + ).decode() |
127 | 135 | save_dir = Path(tmpdir)
|
128 |
| - self.assertEqual( |
129 |
| - self.EXPECTED_NUMBER_OF_TOKENIZER_MODELS[model_type], |
130 |
| - sum("tokenizer" in file for file in map(str, save_dir.rglob("*.xml"))), |
131 |
| - ) |
| 136 | + number_of_tokenizers = sum("tokenizer" in file for file in map(str, save_dir.rglob("*.xml"))) |
| 137 | + self.assertEqual(self.EXPECTED_NUMBER_OF_TOKENIZER_MODELS[model_type], number_of_tokenizers) |
| 138 | + |
| 139 | + if number_of_tokenizers == 1: |
| 140 | + self.assertFalse("Detokenizer is not supported, convert tokenizer only." in output) |
| 141 | + elif number_of_tokenizers == 0: |
| 142 | + self.assertFalse("OpenVINO Tokenizer export for" in output and "is not supported." in output) |
132 | 143 |
|
133 | 144 | @parameterized.expand(SUPPORTED_ARCHITECTURES)
|
134 | 145 | def test_exporters_cli_fp16(self, task: str, model_type: str):
|
|
0 commit comments