From 040e54ae5bebe7cf77ede7642c31aa9724fb8efc Mon Sep 17 00:00:00 2001 From: "Lin, Fanli" Date: Wed, 2 Apr 2025 02:55:41 -0700 Subject: [PATCH 1/5] add xpu part --- .../test_controlnet_hunyuandit.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py index 10be77e3bab4..1eb2d0395f32 100644 --- a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py +++ b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py @@ -153,9 +153,14 @@ def test_controlnet_hunyuandit(self): image_slice = image[0, -3:, -3:, -1] assert image.shape == (1, 16, 16, 3) - expected_slice = np.array( - [0.6953125, 0.89208984, 0.59375, 0.5078125, 0.5786133, 0.6035156, 0.5839844, 0.53564453, 0.52246094] - ) + if torch_device == "xpu": + expected_slice = np.array( + [0.6376953, 0.84375, 0.58691406, 0.48046875, 0.43652344, 0.5517578, 0.54248047, 0.5644531, 0.48217773] + ) + else: + expected_slice = np.array( + [0.6953125, 0.89208984, 0.59375, 0.5078125, 0.5786133, 0.6035156, 0.5839844, 0.53564453, 0.52246094] + ) assert ( np.abs(image_slice.flatten() - expected_slice).max() < 1e-2 From f9a77e479ec5b55d150d7be1aaa64b6c3c222341 Mon Sep 17 00:00:00 2001 From: "Lin, Fanli" Date: Wed, 2 Apr 2025 03:21:19 -0700 Subject: [PATCH 2/5] fix more cases --- .../test_controlnet_hunyuandit.py | 115 ++++++++++++++++-- 1 file changed, 103 insertions(+), 12 deletions(-) diff --git a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py index 1eb2d0395f32..a7a4f6fbd40e 100644 --- a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py +++ b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py @@ -238,9 +238,34 @@ def test_canny(self): original_image = image[-3:, -3:, -1].flatten() - expected_image = np.array( - [0.43652344, 0.4399414, 0.44921875, 0.45043945, 0.45703125, 0.44873047, 0.43579102, 0.44018555, 0.42578125] - ) + if torch_device == "xpu": + expected_image = np.array( + [ + 0.2944336, + 0.30981445, + 0.24389648, + 0.2890625, + 0.32006836, + 0.2578125, + 0.31469727, + 0.34545898, + 0.28515625, + ] + ) + else: + expected_image = np.array( + [ + 0.43652344, + 0.4399414, + 0.44921875, + 0.45043945, + 0.45703125, + 0.44873047, + 0.43579102, + 0.44018555, + 0.42578125, + ] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 @@ -277,9 +302,24 @@ def test_pose(self): original_image = image[-3:, -3:, -1].flatten() - expected_image = np.array( - [0.4091797, 0.4177246, 0.39526367, 0.4194336, 0.40356445, 0.3857422, 0.39208984, 0.40429688, 0.37451172] - ) + if torch_device == "xpu": + expected_image = np.array( + [0.59277344, 0.6640625, 0.75146484, 0.74121094, 0.7636719, 0.7426758, 0.6879883, 0.6455078, 0.6386719] + ) + else: + expected_image = np.array( + [ + 0.4091797, + 0.4177246, + 0.39526367, + 0.4194336, + 0.40356445, + 0.3857422, + 0.39208984, + 0.40429688, + 0.37451172, + ] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 @@ -316,9 +356,34 @@ def test_depth(self): original_image = image[-3:, -3:, -1].flatten() - expected_image = np.array( - [0.31982422, 0.32177734, 0.30126953, 0.3190918, 0.3100586, 0.31396484, 0.3232422, 0.33544922, 0.30810547] - ) + if torch_device == "xpu": + expected_image = np.array( + [ + 0.7529297, + 0.69628906, + 0.62060547, + 0.76708984, + 0.7158203, + 0.65185547, + 0.74853516, + 0.69628906, + 0.6455078, + ] + ) + else: + expected_image = np.array( + [ + 0.31982422, + 0.32177734, + 0.30126953, + 0.3190918, + 0.3100586, + 0.31396484, + 0.3232422, + 0.33544922, + 0.30810547, + ] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 @@ -356,8 +421,34 @@ def test_multi_controlnet(self): assert image.shape == (1024, 1024, 3) original_image = image[-3:, -3:, -1].flatten() - expected_image = np.array( - [0.43652344, 0.44018555, 0.4494629, 0.44995117, 0.45654297, 0.44848633, 0.43603516, 0.4404297, 0.42626953] - ) + + if torch_device == "xpu": + expected_image = np.array( + [ + 0.28320312, + 0.28125, + 0.31347656, + 0.29736328, + 0.29077148, + 0.33740234, + 0.33911133, + 0.35668945, + 0.38452148, + ] + ) + else: + expected_image = np.array( + [ + 0.43652344, + 0.44018555, + 0.4494629, + 0.44995117, + 0.45654297, + 0.44848633, + 0.43603516, + 0.4404297, + 0.42626953, + ] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 From 5b491494ecae35f66a126e5eb659fae325180e85 Mon Sep 17 00:00:00 2001 From: "Lin, Fanli" Date: Wed, 2 Apr 2025 03:45:54 -0700 Subject: [PATCH 3/5] remove some cases --- .../test_controlnet_hunyuandit.py | 83 ++----------------- 1 file changed, 9 insertions(+), 74 deletions(-) diff --git a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py index a7a4f6fbd40e..28497d1b4a0f 100644 --- a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py +++ b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py @@ -302,24 +302,9 @@ def test_pose(self): original_image = image[-3:, -3:, -1].flatten() - if torch_device == "xpu": - expected_image = np.array( - [0.59277344, 0.6640625, 0.75146484, 0.74121094, 0.7636719, 0.7426758, 0.6879883, 0.6455078, 0.6386719] - ) - else: - expected_image = np.array( - [ - 0.4091797, - 0.4177246, - 0.39526367, - 0.4194336, - 0.40356445, - 0.3857422, - 0.39208984, - 0.40429688, - 0.37451172, - ] - ) + expected_image = np.array( + [0.4091797, 0.4177246, 0.39526367, 0.4194336, 0.40356445, 0.3857422, 0.39208984, 0.40429688, 0.37451172] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 @@ -356,34 +341,9 @@ def test_depth(self): original_image = image[-3:, -3:, -1].flatten() - if torch_device == "xpu": - expected_image = np.array( - [ - 0.7529297, - 0.69628906, - 0.62060547, - 0.76708984, - 0.7158203, - 0.65185547, - 0.74853516, - 0.69628906, - 0.6455078, - ] - ) - else: - expected_image = np.array( - [ - 0.31982422, - 0.32177734, - 0.30126953, - 0.3190918, - 0.3100586, - 0.31396484, - 0.3232422, - 0.33544922, - 0.30810547, - ] - ) + expected_image = np.array( + [0.31982422, 0.32177734, 0.30126953, 0.3190918, 0.3100586, 0.31396484, 0.3232422, 0.33544922, 0.30810547] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 @@ -422,33 +382,8 @@ def test_multi_controlnet(self): original_image = image[-3:, -3:, -1].flatten() - if torch_device == "xpu": - expected_image = np.array( - [ - 0.28320312, - 0.28125, - 0.31347656, - 0.29736328, - 0.29077148, - 0.33740234, - 0.33911133, - 0.35668945, - 0.38452148, - ] - ) - else: - expected_image = np.array( - [ - 0.43652344, - 0.44018555, - 0.4494629, - 0.44995117, - 0.45654297, - 0.44848633, - 0.43603516, - 0.4404297, - 0.42626953, - ] - ) + expected_image = np.array( + [0.43652344, 0.44018555, 0.4494629, 0.44995117, 0.45654297, 0.44848633, 0.43603516, 0.4404297, 0.42626953] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 From cb0518a3f81af665021ce3b49903ac1bab40eae4 Mon Sep 17 00:00:00 2001 From: "Lin, Fanli" Date: Wed, 2 Apr 2025 03:48:07 -0700 Subject: [PATCH 4/5] no canny --- .../test_controlnet_hunyuandit.py | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py index 28497d1b4a0f..8c793acb266d 100644 --- a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py +++ b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py @@ -238,34 +238,7 @@ def test_canny(self): original_image = image[-3:, -3:, -1].flatten() - if torch_device == "xpu": - expected_image = np.array( - [ - 0.2944336, - 0.30981445, - 0.24389648, - 0.2890625, - 0.32006836, - 0.2578125, - 0.31469727, - 0.34545898, - 0.28515625, - ] - ) - else: - expected_image = np.array( - [ - 0.43652344, - 0.4399414, - 0.44921875, - 0.45043945, - 0.45703125, - 0.44873047, - 0.43579102, - 0.44018555, - 0.42578125, - ] - ) + expected_image = np.array([0.43652344, 0.4399414, 0.44921875, 0.45043945, 0.45703125, 0.44873047, 0.43579102, 0.44018555, 0.42578125]) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2 From 714b96969679a767a8ab386e0732d410e073b6a7 Mon Sep 17 00:00:00 2001 From: "Lin, Fanli" Date: Wed, 2 Apr 2025 03:48:57 -0700 Subject: [PATCH 5/5] format fix --- .../controlnet_hunyuandit/test_controlnet_hunyuandit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py index 8c793acb266d..f7b3db05c8af 100644 --- a/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py +++ b/tests/pipelines/controlnet_hunyuandit/test_controlnet_hunyuandit.py @@ -238,7 +238,9 @@ def test_canny(self): original_image = image[-3:, -3:, -1].flatten() - expected_image = np.array([0.43652344, 0.4399414, 0.44921875, 0.45043945, 0.45703125, 0.44873047, 0.43579102, 0.44018555, 0.42578125]) + expected_image = np.array( + [0.43652344, 0.4399414, 0.44921875, 0.45043945, 0.45703125, 0.44873047, 0.43579102, 0.44018555, 0.42578125] + ) assert np.abs(original_image.flatten() - expected_image).max() < 1e-2