Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
2c82e0c4
Unverified
Commit
2c82e0c4
authored
Oct 24, 2022
by
Anton Lozhkov
Committed by
GitHub
Oct 24, 2022
Browse files
Reorganize pipeline tests (#963)
* Reorganize pipeline tests * fix vq
parent
2d35f673
Changes
27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
491 deletions
+49
-491
tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py
...pelines/stable_diffusion/test_stable_diffusion_img2img.py
+6
-3
tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py
...pelines/stable_diffusion/test_stable_diffusion_inpaint.py
+6
-3
tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py
.../stable_diffusion/test_stable_diffusion_inpaint_legacy.py
+6
-3
tests/test_pipelines.py
tests/test_pipelines.py
+6
-481
tests/test_pipelines_common.py
tests/test_pipelines_common.py
+12
-0
tests/test_pipelines_flax.py
tests/test_pipelines_flax.py
+1
-1
tests/test_pipelines_onnx_common.py
tests/test_pipelines_onnx_common.py
+12
-0
No files found.
tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py
View file @
2c82e0c4
...
@@ -30,13 +30,16 @@ from diffusers import (
...
@@ -30,13 +30,16 @@ from diffusers import (
VQModel
,
VQModel
,
)
)
from
diffusers.utils
import
floats_tensor
,
load_image
,
slow
,
torch_device
from
diffusers.utils
import
floats_tensor
,
load_image
,
slow
,
torch_device
from
diffusers.utils.testing_utils
import
require_torch_gpu
from
transformers
import
CLIPTextConfig
,
CLIPTextModel
,
CLIPTokenizer
from
transformers
import
CLIPTextConfig
,
CLIPTextModel
,
CLIPTokenizer
from
...test_pipelines_common
import
PipelineTesterMixin
torch
.
backends
.
cuda
.
matmul
.
allow_tf32
=
False
torch
.
backends
.
cuda
.
matmul
.
allow_tf32
=
False
class
PipelineFastTests
(
unittest
.
TestCase
):
class
StableDiffusionImg2ImgPipelineFastTests
(
PipelineTesterMixin
,
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -461,8 +464,8 @@ class PipelineFastTests(unittest.TestCase):
...
@@ -461,8 +464,8 @@ class PipelineFastTests(unittest.TestCase):
@
slow
@
slow
@
unittest
.
skipIf
(
torch_device
==
"cpu"
,
"Stable diffusion is supposed to run on GPU"
)
@
require_torch_gpu
class
PipelineIntegrationTests
(
unittest
.
TestCase
):
class
StableDiffusionImg2Img
PipelineIntegrationTests
(
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint.py
View file @
2c82e0c4
...
@@ -29,14 +29,17 @@ from diffusers import (
...
@@ -29,14 +29,17 @@ from diffusers import (
VQModel
,
VQModel
,
)
)
from
diffusers.utils
import
floats_tensor
,
load_image
,
slow
,
torch_device
from
diffusers.utils
import
floats_tensor
,
load_image
,
slow
,
torch_device
from
diffusers.utils.testing_utils
import
require_torch_gpu
from
PIL
import
Image
from
PIL
import
Image
from
transformers
import
CLIPTextConfig
,
CLIPTextModel
,
CLIPTokenizer
from
transformers
import
CLIPTextConfig
,
CLIPTextModel
,
CLIPTokenizer
from
...test_pipelines_common
import
PipelineTesterMixin
torch
.
backends
.
cuda
.
matmul
.
allow_tf32
=
False
torch
.
backends
.
cuda
.
matmul
.
allow_tf32
=
False
class
PipelineFastTests
(
unittest
.
TestCase
):
class
StableDiffusionInpaintPipelineFastTests
(
PipelineTesterMixin
,
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -258,8 +261,8 @@ class PipelineFastTests(unittest.TestCase):
...
@@ -258,8 +261,8 @@ class PipelineFastTests(unittest.TestCase):
@
slow
@
slow
@
unittest
.
skipIf
(
torch_device
==
"cpu"
,
"Stable diffusion is supposed to run on GPU"
)
@
require_torch_gpu
class
PipelineIntegrationTests
(
unittest
.
TestCase
):
class
StableDiffusionInpaint
PipelineIntegrationTests
(
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/pipelines/stable_diffusion/test_stable_diffusion_inpaint_legacy.py
View file @
2c82e0c4
...
@@ -31,14 +31,17 @@ from diffusers import (
...
@@ -31,14 +31,17 @@ from diffusers import (
VQModel
,
VQModel
,
)
)
from
diffusers.utils
import
floats_tensor
,
load_image
,
slow
,
torch_device
from
diffusers.utils
import
floats_tensor
,
load_image
,
slow
,
torch_device
from
diffusers.utils.testing_utils
import
require_torch_gpu
from
PIL
import
Image
from
PIL
import
Image
from
transformers
import
CLIPTextConfig
,
CLIPTextModel
,
CLIPTokenizer
from
transformers
import
CLIPTextConfig
,
CLIPTextModel
,
CLIPTokenizer
from
...test_pipelines_common
import
PipelineTesterMixin
torch
.
backends
.
cuda
.
matmul
.
allow_tf32
=
False
torch
.
backends
.
cuda
.
matmul
.
allow_tf32
=
False
class
PipelineFastTests
(
unittest
.
TestCase
):
class
StableDiffusionInpaintLegacyPipelineFastTests
(
PipelineTesterMixin
,
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
@@ -338,8 +341,8 @@ class PipelineFastTests(unittest.TestCase):
...
@@ -338,8 +341,8 @@ class PipelineFastTests(unittest.TestCase):
@
slow
@
slow
@
unittest
.
skipIf
(
torch_device
==
"cpu"
,
"Stable diffusion is supposed to run on GPU"
)
@
require_torch_gpu
class
PipelineIntegrationTests
(
unittest
.
TestCase
):
class
StableDiffusionInpaintLegacy
PipelineIntegrationTests
(
unittest
.
TestCase
):
def
tearDown
(
self
):
def
tearDown
(
self
):
# clean up the VRAM after each test
# clean up the VRAM after each test
super
().
tearDown
()
super
().
tearDown
()
...
...
tests/test_pipelines.py
View file @
2c82e0c4
This diff is collapsed.
Click to expand it.
tests/test_pipelines_common.py
0 → 100644
View file @
2c82e0c4
from
diffusers.utils.testing_utils
import
require_torch
@
require_torch
class
PipelineTesterMixin
:
"""
This mixin is designed to be used with unittest.TestCase classes.
It provides a set of common tests for each PyTorch pipeline, e.g. saving and loading the pipeline,
equivalence of dict and tuple outputs, etc.
"""
pass
tests/test_pipelines_flax.py
View file @
2c82e0c4
...
@@ -30,8 +30,8 @@ if is_flax_available():
...
@@ -30,8 +30,8 @@ if is_flax_available():
from
jax
import
pmap
from
jax
import
pmap
@
require_flax
@
slow
@
slow
@
require_flax
class
FlaxPipelineTests
(
unittest
.
TestCase
):
class
FlaxPipelineTests
(
unittest
.
TestCase
):
def
test_dummy_all_tpus
(
self
):
def
test_dummy_all_tpus
(
self
):
pipeline
,
params
=
FlaxStableDiffusionPipeline
.
from_pretrained
(
pipeline
,
params
=
FlaxStableDiffusionPipeline
.
from_pretrained
(
...
...
tests/test_pipelines_onnx_common.py
0 → 100644
View file @
2c82e0c4
from
diffusers.utils.testing_utils
import
require_onnxruntime
@
require_onnxruntime
class
OnnxPipelineTesterMixin
:
"""
This mixin is designed to be used with unittest.TestCase classes.
It provides a set of common tests for each ONNXRuntime pipeline, e.g. saving and loading the pipeline,
equivalence of dict and tuple outputs, etc.
"""
pass
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment