Skip to content
Snippets Groups Projects
Commit 0c40ed63 authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Use import or skip mechanism for cupy

parent ef185b4e
Branches
Tags
1 merge request!438Reduction Support
Pipeline #74177 passed
import pytest import pytest
import numpy as np import numpy as np
try:
import cupy as cp
except ImportError:
pass
import pystencils as ps import pystencils as ps
from pystencils.sympyextensions import reduction_assignment_from_str from pystencils.sympyextensions import reduction_assignment_from_str
...@@ -35,7 +30,6 @@ def get_reduction_assign_ast(dtype, op, config): ...@@ -35,7 +30,6 @@ def get_reduction_assign_ast(dtype, op, config):
@pytest.mark.parametrize('dtype', ["float64", "float32"]) @pytest.mark.parametrize('dtype', ["float64", "float32"])
@pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"]) @pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"])
def test_reduction_cpu(instruction_set, dtype, op): def test_reduction_cpu(instruction_set, dtype, op):
vectorize_info = {'instruction_set': instruction_set, 'assume_inner_stride_one': True} vectorize_info = {'instruction_set': instruction_set, 'assume_inner_stride_one': True}
config = ps.CreateKernelConfig(target=ps.Target.CPU, cpu_openmp=True, cpu_vectorize_info=vectorize_info) config = ps.CreateKernelConfig(target=ps.Target.CPU, cpu_openmp=True, cpu_vectorize_info=vectorize_info)
...@@ -54,6 +48,9 @@ def test_reduction_cpu(instruction_set, dtype, op): ...@@ -54,6 +48,9 @@ def test_reduction_cpu(instruction_set, dtype, op):
@pytest.mark.parametrize('dtype', ["float64", "float32"]) @pytest.mark.parametrize('dtype', ["float64", "float32"])
@pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"]) @pytest.mark.parametrize("op", ["+", "-", "*", "min", "max"])
def test_reduction_gpu(dtype, op): def test_reduction_gpu(dtype, op):
pytest.importorskip('cupy')
import cupy as cp
config = ps.CreateKernelConfig(target=ps.Target.GPU) config = ps.CreateKernelConfig(target=ps.Target.GPU)
ast_reduction = get_reduction_assign_ast(dtype, op, config) ast_reduction = get_reduction_assign_ast(dtype, op, config)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment