Skip to content

Commit

Permalink
Fix string convention
Browse files Browse the repository at this point in the history
  • Loading branch information
sjperkins committed May 2, 2019
1 parent 443cb2d commit a63b2a8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cupy/core/carray.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ cpdef str _get_header_source():

cpdef function.Module compile_with_cache(
str source, tuple options=(), arch=None, cachd_dir=None,
prepend_cupy_headers=True, backend="nvrtc"):
prepend_cupy_headers=True, backend='nvrtc'):
if prepend_cupy_headers:
source = _cupy_header + source
extra_source = _get_header_source()
Expand Down
4 changes: 2 additions & 2 deletions cupy/core/raw.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cdef class RawKernel:
"""

def __init__(self, code, name, options=(), backend="nvrtc"):
def __init__(self, code, name, options=(), backend='nvrtc'):
if isinstance(code, six.binary_type):
code = code.decode('UTF-8')
if isinstance(name, six.binary_type):
Expand Down Expand Up @@ -58,7 +58,7 @@ cdef class RawKernel:


@cupy.util.memoize(for_each_device=True)
def _get_raw_kernel(code, name, options=(), backend="nvrtc"):
def _get_raw_kernel(code, name, options=(), backend='nvrtc'):
module = cupy.core.core.compile_with_cache(
code, options, prepend_cupy_headers=False, backend=backend)
return module.get_function(name)
12 changes: 6 additions & 6 deletions cupy/cuda/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def compile_using_nvcc(source, options=(), arch=None, filename='kern.cu'):
cmd = ['nvcc', '--cubin', arch_str] + list(options)

with TemporaryDirectory() as root_dir:
first_part = filename.split(".")[0]
first_part = filename.split('.')[0]

path = os.path.join(root_dir, first_part)
cu_path = '%s.cu' % path
Expand Down Expand Up @@ -174,7 +174,7 @@ def _preprocess(source, options, arch, backend):
e.dump(sys.stderr)
raise
else:
raise ValueError("Invalid backend %s" % backend)
raise ValueError('Invalid backend %s' % backend)

assert isinstance(result, six.text_type)
return result
Expand All @@ -191,7 +191,7 @@ def get_cache_dir():


def compile_with_cache(source, options=(), arch=None, cache_dir=None,
extra_source=None, backend="nvrtc"):
extra_source=None, backend='nvrtc'):
# NVRTC does not use extra_source. extra_source is used for cache key.
global _empty_file_preprocess_cache
if cache_dir is None:
Expand Down Expand Up @@ -237,15 +237,15 @@ def compile_with_cache(source, options=(), arch=None, cache_dir=None,
mod.load(cubin)
return mod

if backend == "nvrtc":
if backend == 'nvrtc':
ptx = compile_using_nvrtc(source, options, arch, name + '.cu')
ls = function.LinkState()
ls.add_ptr_data(ptx, u'cupy.ptx')
cubin = ls.complete()
elif backend == "nvcc":
elif backend == 'nvcc':
cubin = compile_using_nvcc(source, options, arch, name + '.cu')
else:
raise ValueError("Invalid backend %s" % backend)
raise ValueError('Invalid backend %s' % backend)

cubin_hash = six.b(hashlib.md5(cubin).hexdigest())

Expand Down
2 changes: 1 addition & 1 deletion tests/cupy_tests/core_tests/test_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_basic(self):
assert (y == x1 + x2).all()

def test_backends(self):
for backend in ("nvrtc", "nvcc"):
for backend in ('nvrtc', 'nvcc'):
kern = cupy.RawKernel(_test_source, 'test_sum', backend=backend)
x1 = cupy.arange(100, dtype=cupy.float32).reshape(10, 10)
x2 = cupy.ones((10, 10), dtype=cupy.float32)
Expand Down

0 comments on commit a63b2a8

Please sign in to comment.