From 7c8916ddb55364b06c17f062474321a090792194 Mon Sep 17 00:00:00 2001 From: jiqing-feng Date: Tue, 25 Feb 2025 22:01:25 +0800 Subject: [PATCH] fix audio classification pipeline fp16 test on cuda (#36359) * fix audio classification pipeline fp16 test on cuda Signed-off-by: jiqing-feng * fix format Signed-off-by: jiqing-feng * add comments Signed-off-by: jiqing-feng * Update tests/pipelines/test_pipelines_audio_classification.py --------- Signed-off-by: jiqing-feng Co-authored-by: Yih-Dar <2521628+ydshieh@users.noreply.github.com> --- .../test_pipelines_audio_classification.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/pipelines/test_pipelines_audio_classification.py b/tests/pipelines/test_pipelines_audio_classification.py index a552b79634..db2d3b3b59 100644 --- a/tests/pipelines/test_pipelines_audio_classification.py +++ b/tests/pipelines/test_pipelines_audio_classification.py @@ -144,18 +144,21 @@ class AudioClassificationPipelineTests(unittest.TestCase): audio = np.ones((8000,)) output = audio_classifier(audio, top_k=4) + # Expected outputs are collected running the test on torch 2.6 in few scenarios. + # Running on CUDA T4/A100 and on XPU PVC (note: using stock torch xpu, NOT using IPEX): EXPECTED_OUTPUT = [ + {"score": 0.0833, "label": "go"}, + {"score": 0.0833, "label": "off"}, + {"score": 0.0833, "label": "stop"}, + {"score": 0.0833, "label": "on"}, + ] + # Running on CPU: + EXPECTED_OUTPUT_PT_2 = [ {"score": 0.0839, "label": "no"}, {"score": 0.0837, "label": "go"}, {"score": 0.0836, "label": "yes"}, {"score": 0.0835, "label": "right"}, ] - EXPECTED_OUTPUT_PT_2 = [ - {"score": 0.0845, "label": "stop"}, - {"score": 0.0844, "label": "on"}, - {"score": 0.0841, "label": "right"}, - {"score": 0.0834, "label": "left"}, - ] self.assertIn(nested_simplify(output, decimals=4), [EXPECTED_OUTPUT, EXPECTED_OUTPUT_PT_2]) audio_dict = {"array": np.ones((8000,)), "sampling_rate": audio_classifier.feature_extractor.sampling_rate}