From 84592ee4af4dd0f667c18484e7884049010da4f8 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 2 Feb 2022 16:49:14 -0800 Subject: [PATCH 001/212] plumbed but returning zeros --- python/cudf/cudf/core/indexed_frame.py | 7 ++- python/cudf/cudf/core/udf/lowering.py | 3 +- python/cudf/cudf/core/udf/row_function.py | 2 +- python/cudf/cudf/core/udf/strings.py | 58 +++++++++++++++++++++++ python/cudf/cudf/core/udf/typing.py | 50 +++++++++++++++++-- python/cudf/cudf/core/udf/utils.py | 26 +++++++--- 6 files changed, 132 insertions(+), 14 deletions(-) create mode 100644 python/cudf/cudf/core/udf/strings.py diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 8ecab2c7c65..6a5398372c3 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -22,6 +22,7 @@ is_bool_dtype, is_categorical_dtype, is_integer_dtype, + is_string_dtype, is_list_like, ) from cudf.core.column import arange, as_column @@ -32,6 +33,8 @@ from cudf.core.udf.utils import _compile_or_get, _supported_cols_from_frame from cudf.utils.utils import cached_property +from cudf_jit_udf import to_string_view_array + doc_reset_index_template = """ Reset the index of the {klass}, or a level of it. @@ -781,7 +784,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): # if _compile_or_get succeeds, it is safe to create a kernel that only # consumes the columns that are of supported dtype for col in _supported_cols_from_frame(self).values(): - data = col.data + data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(cudf.Series(col)) mask = col.mask if mask is None: launch_args.append(data) @@ -790,7 +793,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): offsets.append(col.offset) launch_args += offsets launch_args += list(args) - + try: kernel.forall(len(self))(*launch_args) except Exception as e: diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 3b6b3b4b831..850ca134ae5 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -16,7 +16,7 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import MaskedType, NAType +from cudf.core.udf.typing import MaskedType, NAType, string_view @cuda_lowering_registry.lower_constant(NAType) @@ -348,6 +348,7 @@ def cast_masked_to_masked(context, builder, fromty, toty, val): @lower_builtin(api.Masked, types.Number, types.boolean) @lower_builtin(api.Masked, types.NPDatetime, types.boolean) @lower_builtin(api.Masked, types.NPTimedelta, types.boolean) +@lower_builtin(api.Masked, string_view, types.boolean) def masked_constructor(context, builder, sig, args): ty = sig.return_type value, valid = args diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 5cda9fb8218..032efa17146 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -23,6 +23,7 @@ _supported_dtypes_from_frame, ) +from cudf.core.udf import strings def _get_frame_row_type(dtype): """ @@ -126,7 +127,6 @@ def _get_row_kernel(frame, func, args): np.dtype(list(_all_dtypes_from_frame(frame).items())) ) scalar_return_type = _get_udf_return_type(row_type, func, args) - # this is the signature for the final full kernel compilation sig = _construct_signature(frame, scalar_return_type, args) diff --git a/python/cudf/cudf/core/udf/strings.py b/python/cudf/cudf/core/udf/strings.py new file mode 100644 index 00000000000..f73bc22fd2a --- /dev/null +++ b/python/cudf/cudf/core/udf/strings.py @@ -0,0 +1,58 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. +from numba import types +from numba.core.extending import typeof_impl +from numba.cuda.models import register_model, models +from cudf.core.buffer import Buffer +from numba.core.typing.templates import ( + AbstractTemplate, +) +from numba.core.typing import signature +from numba.core import cgutils +from cudf.core.udf.typing import MaskedType, StringView, string_view + +from numba.cuda.cudadecl import registry as cuda_decl_registry +from numba.cuda.cudaimpl import ( + lower as cuda_lower, + registry as cuda_lowering_registry) + +from cudf_jit_udf import to_string_view_array +from numba import cuda + +@cuda_decl_registry.register_global(len) +class MaskedStringViewLength(AbstractTemplate): + """ + provide the length of a cudf::string_view like struct + """ + def generic(self, args, kws): + if isinstance(args[0], MaskedType) and isinstance(args[0].value_type, StringView): + return signature(types.int32, args[0]) + +_len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) + +def call_len_string_view(st): + return _len_string_view(st) + +@cuda_lower(len, MaskedType(types.pyobject)) +def string_view_len_impl(context, builder, sig, args): + retty = sig.return_type + maskedty = sig.args[0] + masked_str = cgutils.create_struct_proxy(maskedty)( + context, builder, value=args[0] + ) + + # the first element is the string_view struct + # get a pointer that we will copy the data to + strty = masked_str.value.type + arg = builder.alloca(strty) + + # store + builder.store(masked_str.value, arg) + + result = context.compile_internal( + builder, + call_len_string_view, + signature(retty, types.CPointer(string_view)), + (arg,) + ) + + return result diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index da7ff4c0e32..a3ca463b14b 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -1,5 +1,5 @@ import operator - +from numba import cuda from numba import types from numba.core.extending import ( make_attribute_wrapper, @@ -25,14 +25,53 @@ unary_ops, ) +from cudf.core.buffer import Buffer + SUPPORTED_NUMBA_TYPES = ( types.Number, types.Boolean, types.NPDatetime, types.NPTimedelta, + types.PyObject ) + +class StringView(types.Type): + def __init__(self): + super().__init__(name="string_view") + +string_view = StringView() + +@typeof_impl.register(StringView) +def typeof_stringview(val, c): + return string_view + +@register_model(StringView) +class stringview_model(models.StructModel): + def __init__(self, dmm, fe_type): + # from string_view.hpp: + # private: + # const char* _data{}; ///< Pointer to device memory contain char array for this string + # size_type _bytes{}; ///< Number of bytes in _data for this string + # mutable size_type _length{}; ///< Number of characters in this string (computed) + members = ( + ('data', types.CPointer(types.char)), + ('bytes', types.int32), + ('length', types.int32), + ) + super().__init__(dmm, fe_type, members) + +class StrViewArgHandler: + def prepare_args(self, ty, val, **kwargs): + if isinstance(val, Buffer): + return types.uint64, val.ptr + else: + return ty, val + + +str_view_arg_handler = StrViewArgHandler() + class MaskedType(types.Type): """ A Numba type consisting of a value of some primitive type @@ -42,7 +81,11 @@ class MaskedType(types.Type): def __init__(self, value): # MaskedType in Numba shall be parameterized # with a value type - if isinstance(value, SUPPORTED_NUMBA_TYPES): + + # TODO - replace object with stringview immediately + if isinstance(value, (types.PyObject, StringView)): + self.value_type = string_view + elif isinstance(value, SUPPORTED_NUMBA_TYPES): self.value_type = value else: # Unsupported Dtype. Numba tends to print out the type info @@ -54,7 +97,7 @@ def __init__(self, value): "attempting to use a column of unsupported dtype in a UDF. " f"Supported dtypes are {SUPPORTED_NUMBA_TYPES}" ) - super().__init__(name=f"Masked{self.value_type}") + super().__init__(name=f"Masked({self.value_type})") def __hash__(self): """ @@ -143,6 +186,7 @@ class MaskedConstructor(ConcreteTemplate): | datetime_cases | timedelta_cases | {types.boolean} + | {types.pyobject, string_view} ) ] diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index a98ee40274e..82551275939 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -5,21 +5,23 @@ from numba import cuda, typeof from numba.core.errors import TypingError from numba.np import numpy_support -from numba.types import Poison, Tuple, boolean, int64, void +from numba.types import Poison, Tuple, boolean, int64, void, CPointer from nvtx import annotate from cudf.core.dtypes import CategoricalDtype -from cudf.core.udf.typing import MaskedType +from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler from cudf.utils import cudautils from cudf.utils.dtypes import ( BOOL_TYPES, DATETIME_TYPES, NUMERIC_TYPES, TIMEDELTA_TYPES, + STRING_TYPES, ) +from cudf.api.types import is_string_dtype JIT_SUPPORTED_TYPES = ( - NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES + NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES ) libcudf_bitmask_type = numpy_support.from_dtype(np.dtype("int32")) @@ -114,11 +116,20 @@ def _masked_array_type_from_col(col): corresponding to `dtype`, and the second an array of bools representing a mask. """ - nb_scalar_ty = numpy_support.from_dtype(col.dtype) + if is_string_dtype(col.dtype): + # strings_udf library provides a pointer directly to the data + col_type = CPointer(string_view) + else: + nb_scalar_ty = numpy_support.from_dtype(col.dtype) + col_type = nb_scalar_ty[::1] + if col.mask is None: - return nb_scalar_ty[::1] + return col_type else: - return Tuple((nb_scalar_ty[::1], libcudf_bitmask_type[::1])) + return Tuple( + col_type, + libcudf_bitmask_type[::1] + ) def _construct_signature(frame, return_type, args): @@ -211,6 +222,7 @@ def _get_kernel(kernel_string, globals_, sig, func): globals_["f_"] = f_ exec(kernel_string, globals_) _kernel = globals_["_kernel"] - kernel = cuda.jit(sig)(_kernel) + breakpoint() + kernel = cuda.jit(sig, link=['/home/nfs/brmiller/ipynb/strings_udf/len.ptx'], extensions=[str_view_arg_handler])(_kernel) return kernel From f18f03a57b1e38e6e410dcae01a84766c46c26d3 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 3 Feb 2022 17:42:26 -0800 Subject: [PATCH 002/212] up and running --- python/cudf/cudf/core/udf/row_function.py | 15 +++++++++++++-- python/cudf/cudf/core/udf/utils.py | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 032efa17146..d0cd364cf61 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -45,7 +45,14 @@ def _get_frame_row_type(dtype): fields = [] offset = 0 - sizes = [val[0].itemsize for val in dtype.fields.values()] + sizes = [] + for field in dtype.fields.values(): + if field[0] == np.dtype('object'): + sizes.append(24) + else: + sizes.append(field[0].itemsize) + + #sizes = [val[0].itemsize for val in dtype.fields.values()] for i, (name, info) in enumerate(dtype.fields.items()): # *info* consists of the element dtype, its offset from the beginning # of the record, and an optional "title" containing metadata. @@ -62,7 +69,11 @@ def _get_frame_row_type(dtype): fields.append((name, infos)) # increment offset by itemsize plus one byte for validity - offset += elemdtype.itemsize + 1 + if elemdtype == np.dtype('object'): + itemsize = 24 + else: + itemsize = elemdtype.itemsize + offset += itemsize + 1 # Align the next member of the struct to be a multiple of the # memory access size, per PTX ISA 7.4/5.4.5 diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 82551275939..a96a19fef02 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -222,7 +222,6 @@ def _get_kernel(kernel_string, globals_, sig, func): globals_["f_"] = f_ exec(kernel_string, globals_) _kernel = globals_["_kernel"] - breakpoint() kernel = cuda.jit(sig, link=['/home/nfs/brmiller/ipynb/strings_udf/len.ptx'], extensions=[str_view_arg_handler])(_kernel) return kernel From 0921c8f68f6a931985dbefadcb561aa8a8198f62 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 10 Feb 2022 08:55:03 -0800 Subject: [PATCH 003/212] move code around --- python/cudf/cudf/core/udf/lowering.py | 31 +++++++++++++- python/cudf/cudf/core/udf/strings.py | 58 --------------------------- python/cudf/cudf/core/udf/typing.py | 17 +++++++- 3 files changed, 46 insertions(+), 60 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 850ca134ae5..bc78f3e1fe8 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -16,7 +16,7 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import MaskedType, NAType, string_view +from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view @cuda_lowering_registry.lower_constant(NAType) @@ -366,3 +366,32 @@ def lower_constant_masked(context, builder, ty, val): masked.value = context.get_constant(ty.value_type, val.value) masked.valid = context.get_constant(types.boolean, val.valid) return masked._getvalue() + +# String function implementations +def call_len_string_view(st): + return _len_string_view(st) + +@cuda_lower(len, MaskedType(types.pyobject)) +def string_view_len_impl(context, builder, sig, args): + retty = sig.return_type + maskedty = sig.args[0] + masked_str = cgutils.create_struct_proxy(maskedty)( + context, builder, value=args[0] + ) + + # the first element is the string_view struct + # get a pointer that we will copy the data to + strty = masked_str.value.type + arg = builder.alloca(strty) + + # store + builder.store(masked_str.value, arg) + + result = context.compile_internal( + builder, + call_len_string_view, + nb_signature(retty, types.CPointer(string_view)), + (arg,) + ) + + return result diff --git a/python/cudf/cudf/core/udf/strings.py b/python/cudf/cudf/core/udf/strings.py index f73bc22fd2a..e69de29bb2d 100644 --- a/python/cudf/cudf/core/udf/strings.py +++ b/python/cudf/cudf/core/udf/strings.py @@ -1,58 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. -from numba import types -from numba.core.extending import typeof_impl -from numba.cuda.models import register_model, models -from cudf.core.buffer import Buffer -from numba.core.typing.templates import ( - AbstractTemplate, -) -from numba.core.typing import signature -from numba.core import cgutils -from cudf.core.udf.typing import MaskedType, StringView, string_view - -from numba.cuda.cudadecl import registry as cuda_decl_registry -from numba.cuda.cudaimpl import ( - lower as cuda_lower, - registry as cuda_lowering_registry) - -from cudf_jit_udf import to_string_view_array -from numba import cuda - -@cuda_decl_registry.register_global(len) -class MaskedStringViewLength(AbstractTemplate): - """ - provide the length of a cudf::string_view like struct - """ - def generic(self, args, kws): - if isinstance(args[0], MaskedType) and isinstance(args[0].value_type, StringView): - return signature(types.int32, args[0]) - -_len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) - -def call_len_string_view(st): - return _len_string_view(st) - -@cuda_lower(len, MaskedType(types.pyobject)) -def string_view_len_impl(context, builder, sig, args): - retty = sig.return_type - maskedty = sig.args[0] - masked_str = cgutils.create_struct_proxy(maskedty)( - context, builder, value=args[0] - ) - - # the first element is the string_view struct - # get a pointer that we will copy the data to - strty = masked_str.value.type - arg = builder.alloca(strty) - - # store - builder.store(masked_str.value, arg) - - result = context.compile_internal( - builder, - call_len_string_view, - signature(retty, types.CPointer(string_view)), - (arg,) - ) - - return result diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index a3ca463b14b..f8f584247f2 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -36,7 +36,7 @@ ) - +# String object definitions class StringView(types.Type): def __init__(self): super().__init__(name="string_view") @@ -72,6 +72,7 @@ def prepare_args(self, ty, val, **kwargs): str_view_arg_handler = StrViewArgHandler() +# Masked scalars of all types class MaskedType(types.Type): """ A Numba type consisting of a value of some primitive type @@ -390,6 +391,20 @@ def generic(self, args, kws): return nb_signature(return_type, args[0]) +# String functions +@cuda_decl_registry.register_global(len) +class MaskedStringViewLength(AbstractTemplate): + """ + provide the length of a cudf::string_view like struct + """ + def generic(self, args, kws): + if isinstance(args[0], MaskedType) and isinstance(args[0].value_type, StringView): + return nb_signature(types.int32, args[0]) + +_len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) + + + for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) From 2aa6299e3de659bffa18003673a5f18be52e3312 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 10 Feb 2022 08:55:25 -0800 Subject: [PATCH 004/212] remove old file --- python/cudf/cudf/core/udf/strings.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 python/cudf/cudf/core/udf/strings.py diff --git a/python/cudf/cudf/core/udf/strings.py b/python/cudf/cudf/core/udf/strings.py deleted file mode 100644 index e69de29bb2d..00000000000 From 38a1c4444edd3abeb40af8072c5b2da9c8fb0b74 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 11 Feb 2022 10:01:56 -0800 Subject: [PATCH 005/212] bugfixes and a temporary workaround --- python/cudf/cudf/core/buffer.py | 3 +++ python/cudf/cudf/core/indexed_frame.py | 2 +- python/cudf/cudf/core/udf/row_function.py | 1 - python/cudf/cudf/core/udf/typing.py | 4 ++-- python/cudf/cudf/core/udf/utils.py | 6 ++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/python/cudf/cudf/core/buffer.py b/python/cudf/cudf/core/buffer.py index 0658927975f..e7368865e8b 100644 --- a/python/cudf/cudf/core/buffer.py +++ b/python/cudf/cudf/core/buffer.py @@ -199,3 +199,6 @@ def get_c_contiguity(shape, strides, itemsize): if this_stride != this_dim * itemsize: return False return True + +class StringViewBuffer(Buffer): + pass diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 6a5398372c3..808dba74e32 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -784,7 +784,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): # if _compile_or_get succeeds, it is safe to create a kernel that only # consumes the columns that are of supported dtype for col in _supported_cols_from_frame(self).values(): - data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(cudf.Series(col)) + data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(col) mask = col.mask if mask is None: launch_args.append(data) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index d0cd364cf61..d08d5e359fd 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -23,7 +23,6 @@ _supported_dtypes_from_frame, ) -from cudf.core.udf import strings def _get_frame_row_type(dtype): """ diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index f8f584247f2..b4fded83f94 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -25,7 +25,7 @@ unary_ops, ) -from cudf.core.buffer import Buffer +from cudf.core.buffer import Buffer, StringViewBuffer SUPPORTED_NUMBA_TYPES = ( types.Number, @@ -64,7 +64,7 @@ def __init__(self, dmm, fe_type): class StrViewArgHandler: def prepare_args(self, ty, val, **kwargs): - if isinstance(val, Buffer): + if isinstance(val, StringViewBuffer): return types.uint64, val.ptr else: return ty, val diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index a96a19fef02..e794f322c6c 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -127,8 +127,10 @@ def _masked_array_type_from_col(col): return col_type else: return Tuple( - col_type, - libcudf_bitmask_type[::1] + ( + col_type, + libcudf_bitmask_type[::1] + ) ) From 2d0b50597f9a22a36b167717bb18ad926e3df8db Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 23 Feb 2022 12:03:36 -0800 Subject: [PATCH 006/212] successfully casting literal->masked string --- python/cudf/cudf/core/udf/lowering.py | 32 ++++++++++++++++++++++++++- python/cudf/cudf/core/udf/typing.py | 29 +++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index bc78f3e1fe8..ab0edc16a28 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -8,7 +8,7 @@ registry as cuda_lowering_registry, ) from numba.extending import lower_builtin, types - +from numba.cuda.cudadrv import nvvm from cudf.core.udf import api from cudf.core.udf._ops import ( arith_ops, @@ -395,3 +395,33 @@ def string_view_len_impl(context, builder, sig, args): ) return result + +@cuda_lower(len, types.literal('abcde')) +def string_literal_len_impl(context, builder, sig, args): + # todo- should be able to compile out the length of literals... + pass + +@cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) +def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val): + """ + cast a literal to a Masked(string_view) + """ + # create an empty string_view + str_view = cgutils.create_struct_proxy(toty.value_type)(context, builder) + + # set the empty strview data pointer to point to the literal value + s = context.insert_const_string(builder.module, fromty.literal_value) + str_view.data = context.insert_addrspace_conv(builder, s, nvvm.ADDRSPACE_CONSTANT) + + # create an empty MaskedType + to_return = cgutils.create_struct_proxy(toty)( + context, builder + ) + + # make it valid + to_return.valid = context.get_constant(types.boolean, 1) + + # set the value to be the string view + to_return.value = str_view._getvalue() + + return to_return._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 919467e3e33..7db043a84b9 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -35,6 +35,9 @@ types.PyObject ) +from numba.extending import type_callable + + # String object definitions class StringView(types.Type): @@ -163,6 +166,8 @@ def __eq__(self, other): # Require a cast for another masked with a different value type return self.value_type == other.value_type + def startswith(self, other): + pass # For typing a Masked constant value defined outside a kernel (e.g. captured in # a closure). @@ -195,7 +200,7 @@ class MaskedConstructor(ConcreteTemplate): # Provide access to `m.value` and `m.valid` in a kernel for a Masked `m`. make_attribute_wrapper(MaskedType, "value", "value") make_attribute_wrapper(MaskedType, "valid", "valid") - +make_attribute_wrapper(StringView, "data", "data") # Typing for `api.Masked` @cuda_decl_registry.register_attr @@ -403,6 +408,15 @@ def generic(self, args, kws): _len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) +@cuda_decl_registry.register_global(len) +class StringLiteralLength(AbstractTemplate): + """ + provide the length of a python string literal by first + converting to a cudf::string_view first + """ + def generic(self, args, kws): + if isinstance(args[0], types.StringLiteral) and len(args) == 1: + return nb_signature(types.int32, args[0]) for binary_op in arith_ops + bitwise_ops + comparison_ops: @@ -413,3 +427,16 @@ def generic(self, args, kws): for unary_op in unary_ops: cuda_decl_registry.register_global(unary_op)(MaskedScalarUnaryOp) + +class MaskedStringStartsWith(AbstractTemplate): + key = "MaskedType.startswith" + + def generic(self, args, kws): + return nb_signature(types.boolean, MaskedType(string_view), recvr=self.this) + +@cuda_decl_registry.register_attr +class MaskedStringAttrs(AttributeTemplate): + key = MaskedType(string_view) + + def resolve_startswith(self, mod): + return types.BoundFunction(MaskedStringStartsWith, MaskedType(string_view)) From a3e0b7f23ce75d3c3182029bed161ce80d37e49b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 23 Feb 2022 12:54:53 -0800 Subject: [PATCH 007/212] startswith lowering --- python/cudf/cudf/core/udf/lowering.py | 39 +++++++++++++++++++++++---- python/cudf/cudf/core/udf/typing.py | 1 + 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index ab0edc16a28..63a2961bc01 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -16,7 +16,7 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view +from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view, _string_view_startswith @cuda_lowering_registry.lower_constant(NAType) @@ -396,10 +396,10 @@ def string_view_len_impl(context, builder, sig, args): return result -@cuda_lower(len, types.literal('abcde')) -def string_literal_len_impl(context, builder, sig, args): - # todo- should be able to compile out the length of literals... - pass +#@cuda_lower(len, types.literal('abcde')) +#def string_literal_len_impl(context, builder, sig, args): +# # todo- should be able to compile out the length of literals... +# pass @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val): @@ -425,3 +425,32 @@ def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val) to_return.value = str_view._getvalue() return to_return._getvalue() + + +def call_string_view_startswith(st, tgt): + return _string_view_startswith(st, tgt) + +@cuda_lower("MaskedType.startswith", MaskedType(string_view), MaskedType(string_view)) +def masked_stringview_startswith(context, builder, sig, args): + retty = sig.return_type + + maskedty = sig.args[0] + + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) + tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + + strty = st.value.type + + st_ptr = builder.alloca(strty) + tgt_ptr = builder.alloca(strty) + + builder.store(st.value, st_ptr) + builder.store(tgt.value, tgt_ptr) + + result = context.compile_internal( + builder, + call_string_view_startswith, + nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), + (st_ptr, tgt_ptr) + ) + return result diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 7db043a84b9..6c0ca13272e 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -407,6 +407,7 @@ def generic(self, args, kws): return nb_signature(types.int32, args[0]) _len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) +_string_view_startswith = cuda.declare_device("startswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): From 087a9f2d2e9df395dd346fd3cdaa0abfd14bd73c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 28 Feb 2022 08:16:25 -0800 Subject: [PATCH 008/212] fix bugs in startswith, which now works --- python/cudf/cudf/core/udf/lowering.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 63a2961bc01..63706e11654 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -412,6 +412,8 @@ def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val) # set the empty strview data pointer to point to the literal value s = context.insert_const_string(builder.module, fromty.literal_value) str_view.data = context.insert_addrspace_conv(builder, s, nvvm.ADDRSPACE_CONSTANT) + str_view.length = context.get_constant(types.int32, len(fromty.literal_value)) + str_view.bytes = context.get_constant(types.int32, len(fromty.literal_value.encode('UTF-8'))) # create an empty MaskedType to_return = cgutils.create_struct_proxy(toty)( @@ -433,7 +435,6 @@ def call_string_view_startswith(st, tgt): @cuda_lower("MaskedType.startswith", MaskedType(string_view), MaskedType(string_view)) def masked_stringview_startswith(context, builder, sig, args): retty = sig.return_type - maskedty = sig.args[0] st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) From 2930e75f793f234648d65cfdd91e5122a9b0bc2c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 8 Mar 2022 08:19:14 -0800 Subject: [PATCH 009/212] add typing and lowering for ends_with --- python/cudf/cudf/core/udf/lowering.py | 31 ++++++++++++++++++++++++++- python/cudf/cudf/core/udf/typing.py | 20 ++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 63706e11654..33b0a6a4c00 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -16,7 +16,7 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view, _string_view_startswith +from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view, _string_view_startswith, _string_view_endswith @cuda_lowering_registry.lower_constant(NAType) @@ -455,3 +455,32 @@ def masked_stringview_startswith(context, builder, sig, args): (st_ptr, tgt_ptr) ) return result + + +def call_string_view_endswith(st, tgt): + return _string_view_endswith(st, tgt) + + +@cuda_lower("MaskedType.endswith", MaskedType(string_view), MaskedType(string_view)) +def masked_stringview_endswith(context, builder, sig, args): + retty = sig.return_type + maskedty = sig.args[0] + + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) + tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + + strty = st.value.type + + st_ptr = builder.alloca(strty) + tgt_ptr = builder.alloca(strty) + + builder.store(st.value, st_ptr) + builder.store(tgt.value, tgt_ptr) + + result = context.compile_internal( + builder, + call_string_view_endswith, + nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), + (st_ptr, tgt_ptr) + ) + return result diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 6c0ca13272e..8fc594dac5f 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -169,6 +169,9 @@ def __eq__(self, other): def startswith(self, other): pass + def endswith(self, other): + pass + # For typing a Masked constant value defined outside a kernel (e.g. captured in # a closure). @typeof_impl.register(api.Masked) @@ -406,9 +409,6 @@ def generic(self, args, kws): if isinstance(args[0], MaskedType) and isinstance(args[0].value_type, StringView): return nb_signature(types.int32, args[0]) -_len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) -_string_view_startswith = cuda.declare_device("startswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) - @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): """ @@ -435,9 +435,23 @@ class MaskedStringStartsWith(AbstractTemplate): def generic(self, args, kws): return nb_signature(types.boolean, MaskedType(string_view), recvr=self.this) + +class MaskedStringEndsWith(AbstractTemplate): + key = "MaskedType.endswith" + + def generic(self, args, kws): + return nb_signature(types.boolean, MaskedType(string_view), recvr=self.this) + @cuda_decl_registry.register_attr class MaskedStringAttrs(AttributeTemplate): key = MaskedType(string_view) def resolve_startswith(self, mod): return types.BoundFunction(MaskedStringStartsWith, MaskedType(string_view)) + + def resolve_endswith(self, mod): + return types.BoundFunction(MaskedStringEndsWith, MaskedType(string_view)) + +_len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) +_string_view_startswith = cuda.declare_device("startswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) +_string_view_endswith = cuda.declare_device("endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) From f190d43f3e4fe7c4629a3cbd11ec5029790e6729 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 8 Mar 2022 12:07:46 -0800 Subject: [PATCH 010/212] implement rfind --- python/cudf/cudf/core/udf/lowering.py | 59 ++++++++++++++++++++++++++- python/cudf/cudf/core/udf/typing.py | 21 ++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 33b0a6a4c00..d0648e1a456 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -16,7 +16,7 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view, _string_view_startswith, _string_view_endswith +from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view, _string_view_startswith, _string_view_endswith, _string_view_find, _string_view_rfind @cuda_lowering_registry.lower_constant(NAType) @@ -484,3 +484,60 @@ def masked_stringview_endswith(context, builder, sig, args): (st_ptr, tgt_ptr) ) return result + +def call_string_view_find(st, tgt): + return _string_view_find(st, tgt) + + +@cuda_lower("MaskedType.find", MaskedType(string_view), MaskedType(string_view)) +def masked_stringview_find(context, builder, sig, args): + retty = sig.return_type + maskedty = sig.args[0] + + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) + tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + + strty = st.value.type + + st_ptr = builder.alloca(strty) + tgt_ptr = builder.alloca(strty) + + builder.store(st.value, st_ptr) + builder.store(tgt.value, tgt_ptr) + + result = context.compile_internal( + builder, + call_string_view_find, + nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), + (st_ptr, tgt_ptr) + ) + return result + + +def call_string_view_rfind(st, tgt): + return _string_view_rfind(st, tgt) + + +@cuda_lower("MaskedType.rfind", MaskedType(string_view), MaskedType(string_view)) +def masked_stringview_rfind(context, builder, sig, args): + retty = sig.return_type + maskedty = sig.args[0] + + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) + tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + + strty = st.value.type + + st_ptr = builder.alloca(strty) + tgt_ptr = builder.alloca(strty) + + builder.store(st.value, st_ptr) + builder.store(tgt.value, tgt_ptr) + + result = context.compile_internal( + builder, + call_string_view_rfind, + nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), + (st_ptr, tgt_ptr) + ) + return result diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 8fc594dac5f..31da4852474 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -442,6 +442,19 @@ class MaskedStringEndsWith(AbstractTemplate): def generic(self, args, kws): return nb_signature(types.boolean, MaskedType(string_view), recvr=self.this) + +class MaskedStringFind(AbstractTemplate): + key = "MaskedType.find" + + def generic(self, args, kws): + return nb_signature(types.int32, MaskedType(string_view), recvr=self.this) + +class MaskedStringRFind(AbstractTemplate): + key = "MaskedType.rfind" + + def generic(self, args, kws): + return nb_signature(types.int32, MaskedType(string_view), recvr=self.this) + @cuda_decl_registry.register_attr class MaskedStringAttrs(AttributeTemplate): key = MaskedType(string_view) @@ -452,6 +465,14 @@ def resolve_startswith(self, mod): def resolve_endswith(self, mod): return types.BoundFunction(MaskedStringEndsWith, MaskedType(string_view)) + def resolve_find(self, mod): + return types.BoundFunction(MaskedStringFind, MaskedType(string_view)) + + def resolve_rfind(self, mod): + return types.BoundFunction(MaskedStringFind, MaskedType(string_view)) + _len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) _string_view_startswith = cuda.declare_device("startswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) _string_view_endswith = cuda.declare_device("endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) +_string_view_find = cuda.declare_device("find", types.int32(types.CPointer(string_view), types.CPointer(string_view))) +_string_view_rfind = cuda.declare_device("rfind", types.int32(types.CPointer(string_view), types.CPointer(string_view))) From b056f4168668f075c5854586367a0abf79bf9536 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 8 Mar 2022 12:58:35 -0800 Subject: [PATCH 011/212] add some basic testing --- python/cudf/cudf/tests/test_udf_masked_ops.py | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index faaea6eec08..9c65111cd2b 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -668,3 +668,116 @@ def f(x): data.apply(f) assert precompiled.currsize == 1 + + +@pytest.mark.parametrize( + "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022"]}] +) +def test_string_udf_len(data): + # tests the `len` function in string udfs + data = cudf.DataFrame(data) + + def func(row): + st = row["str_col"] + return len(st) + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022", "cuDF"]}] +) +@pytest.mark.parametrize("substr", ["a", "cu", "2"]) +def test_string_udf_startswith(data, substr): + # tests the `startswith` method of strings + data = cudf.DataFrame(data) + + def func(row): + st = row["str_col"] + return st.startswith(substr) + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "gpu", + "2022", + "cuDF", + "again_gpu", + ] + } + ], +) +@pytest.mark.parametrize("substr", ["a", "gpu", "2"]) +def test_string_udf_endswith(data, substr): + # tests the `endswith` method of strings + data = cudf.DataFrame(data) + + def func(row): + st = row["str_col"] + return st.endswith(substr) + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "gpu", + "2022", + "cuDF", + "again_gpu", + ] + } + ], +) +@pytest.mark.parametrize("substr", ["u", "gpu", "a"]) +def test_string_udf_find(data, substr): + # tests the `find` method of strings + data = cudf.DataFrame(data) + + def func(row): + st = row["str_col"] + return st.find(substr) + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "gpu", + "2022", + "cuDF", + "again_gpu", + ] + } + ], +) +@pytest.mark.parametrize("substr", ["u", "gpu", "a"]) +def test_string_udf_rfind(data, substr): + # tests the `find` method of strings + data = cudf.DataFrame(data) + + def func(row): + st = row["str_col"] + return st.rfind(substr) + + run_masked_udf_test(func, data, check_dtype=False) From 06596c0f448e2cc36e9d5e5f95ef8545c68838f7 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 8 Mar 2022 12:58:52 -0800 Subject: [PATCH 012/212] fix bug --- python/cudf/cudf/core/udf/typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 31da4852474..37c1e7b7a3d 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -469,7 +469,7 @@ def resolve_find(self, mod): return types.BoundFunction(MaskedStringFind, MaskedType(string_view)) def resolve_rfind(self, mod): - return types.BoundFunction(MaskedStringFind, MaskedType(string_view)) + return types.BoundFunction(MaskedStringRFind, MaskedType(string_view)) _len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) _string_view_startswith = cuda.declare_device("startswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) From ad983f8c1fdba063aa912973ffb2fca1547953e6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 8 Mar 2022 12:59:41 -0800 Subject: [PATCH 013/212] run black --- python/cudf/cudf/core/udf/lowering.py | 114 ++++++++++++++++++-------- python/cudf/cudf/core/udf/typing.py | 84 +++++++++++++------ 2 files changed, 141 insertions(+), 57 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index d0648e1a456..e1e074615d4 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -3,12 +3,13 @@ from llvmlite import ir from numba.core import cgutils from numba.core.typing import signature as nb_signature +from numba.cuda.cudadrv import nvvm from numba.cuda.cudaimpl import ( lower as cuda_lower, registry as cuda_lowering_registry, ) from numba.extending import lower_builtin, types -from numba.cuda.cudadrv import nvvm + from cudf.core.udf import api from cudf.core.udf._ops import ( arith_ops, @@ -16,7 +17,16 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import MaskedType, NAType, string_view, _len_string_view, _string_view_startswith, _string_view_endswith, _string_view_find, _string_view_rfind +from cudf.core.udf.typing import ( + MaskedType, + NAType, + _len_string_view, + _string_view_endswith, + _string_view_find, + _string_view_rfind, + _string_view_startswith, + string_view, +) @cuda_lowering_registry.lower_constant(NAType) @@ -367,10 +377,12 @@ def lower_constant_masked(context, builder, ty, val): masked.valid = context.get_constant(types.boolean, val.valid) return masked._getvalue() + # String function implementations def call_len_string_view(st): return _len_string_view(st) + @cuda_lower(len, MaskedType(types.pyobject)) def string_view_len_impl(context, builder, sig, args): retty = sig.return_type @@ -386,23 +398,27 @@ def string_view_len_impl(context, builder, sig, args): # store builder.store(masked_str.value, arg) - + result = context.compile_internal( builder, call_len_string_view, nb_signature(retty, types.CPointer(string_view)), - (arg,) + (arg,), ) - + return result -#@cuda_lower(len, types.literal('abcde')) -#def string_literal_len_impl(context, builder, sig, args): + +# @cuda_lower(len, types.literal('abcde')) +# def string_literal_len_impl(context, builder, sig, args): # # todo- should be able to compile out the length of literals... # pass + @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) -def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val): +def cast_stringliteral_to_masked_stringview( + context, builder, fromty, toty, val +): """ cast a literal to a Masked(string_view) """ @@ -411,14 +427,18 @@ def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val) # set the empty strview data pointer to point to the literal value s = context.insert_const_string(builder.module, fromty.literal_value) - str_view.data = context.insert_addrspace_conv(builder, s, nvvm.ADDRSPACE_CONSTANT) - str_view.length = context.get_constant(types.int32, len(fromty.literal_value)) - str_view.bytes = context.get_constant(types.int32, len(fromty.literal_value.encode('UTF-8'))) + str_view.data = context.insert_addrspace_conv( + builder, s, nvvm.ADDRSPACE_CONSTANT + ) + str_view.length = context.get_constant( + types.int32, len(fromty.literal_value) + ) + str_view.bytes = context.get_constant( + types.int32, len(fromty.literal_value.encode("UTF-8")) + ) # create an empty MaskedType - to_return = cgutils.create_struct_proxy(toty)( - context, builder - ) + to_return = cgutils.create_struct_proxy(toty)(context, builder) # make it valid to_return.valid = context.get_constant(types.boolean, 1) @@ -432,13 +452,18 @@ def cast_stringliteral_to_masked_stringview(context, builder, fromty, toty, val) def call_string_view_startswith(st, tgt): return _string_view_startswith(st, tgt) -@cuda_lower("MaskedType.startswith", MaskedType(string_view), MaskedType(string_view)) + +@cuda_lower( + "MaskedType.startswith", MaskedType(string_view), MaskedType(string_view) +) def masked_stringview_startswith(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] - + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + tgt = cgutils.create_struct_proxy(maskedty)( + context, builder, value=args[1] + ) strty = st.value.type @@ -451,8 +476,10 @@ def masked_stringview_startswith(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_startswith, - nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), - (st_ptr, tgt_ptr) + nb_signature( + retty, types.CPointer(string_view), types.CPointer(string_view) + ), + (st_ptr, tgt_ptr), ) return result @@ -461,13 +488,17 @@ def call_string_view_endswith(st, tgt): return _string_view_endswith(st, tgt) -@cuda_lower("MaskedType.endswith", MaskedType(string_view), MaskedType(string_view)) +@cuda_lower( + "MaskedType.endswith", MaskedType(string_view), MaskedType(string_view) +) def masked_stringview_endswith(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] - + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + tgt = cgutils.create_struct_proxy(maskedty)( + context, builder, value=args[1] + ) strty = st.value.type @@ -480,22 +511,29 @@ def masked_stringview_endswith(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_endswith, - nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), - (st_ptr, tgt_ptr) + nb_signature( + retty, types.CPointer(string_view), types.CPointer(string_view) + ), + (st_ptr, tgt_ptr), ) return result + def call_string_view_find(st, tgt): return _string_view_find(st, tgt) -@cuda_lower("MaskedType.find", MaskedType(string_view), MaskedType(string_view)) +@cuda_lower( + "MaskedType.find", MaskedType(string_view), MaskedType(string_view) +) def masked_stringview_find(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] - + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + tgt = cgutils.create_struct_proxy(maskedty)( + context, builder, value=args[1] + ) strty = st.value.type @@ -508,8 +546,10 @@ def masked_stringview_find(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_find, - nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), - (st_ptr, tgt_ptr) + nb_signature( + retty, types.CPointer(string_view), types.CPointer(string_view) + ), + (st_ptr, tgt_ptr), ) return result @@ -518,13 +558,17 @@ def call_string_view_rfind(st, tgt): return _string_view_rfind(st, tgt) -@cuda_lower("MaskedType.rfind", MaskedType(string_view), MaskedType(string_view)) +@cuda_lower( + "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) +) def masked_stringview_rfind(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] - + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[1]) + tgt = cgutils.create_struct_proxy(maskedty)( + context, builder, value=args[1] + ) strty = st.value.type @@ -537,7 +581,9 @@ def masked_stringview_rfind(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_rfind, - nb_signature(retty, types.CPointer(string_view), types.CPointer(string_view)), - (st_ptr, tgt_ptr) + nb_signature( + retty, types.CPointer(string_view), types.CPointer(string_view) + ), + (st_ptr, tgt_ptr), ) return result diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 37c1e7b7a3d..8bfa0a865e4 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -1,6 +1,6 @@ import operator -from numba import cuda -from numba import types + +from numba import cuda, types from numba.core.extending import ( make_attribute_wrapper, models, @@ -17,6 +17,7 @@ from numba.cuda.cudadecl import registry as cuda_decl_registry from pandas._libs.missing import NAType as _NAType +from cudf.core.buffer import Buffer, StringViewBuffer from cudf.core.udf import api from cudf.core.udf._ops import ( arith_ops, @@ -25,31 +26,31 @@ unary_ops, ) -from cudf.core.buffer import Buffer, StringViewBuffer - SUPPORTED_NUMBA_TYPES = ( types.Number, types.Boolean, types.NPDatetime, types.NPTimedelta, - types.PyObject + types.PyObject, ) from numba.extending import type_callable - # String object definitions class StringView(types.Type): def __init__(self): - super().__init__(name="string_view") + super().__init__(name="string_view") + string_view = StringView() + @typeof_impl.register(StringView) def typeof_stringview(val, c): return string_view + @register_model(StringView) class stringview_model(models.StructModel): def __init__(self, dmm, fe_type): @@ -59,12 +60,13 @@ def __init__(self, dmm, fe_type): # size_type _bytes{}; ///< Number of bytes in _data for this string # mutable size_type _length{}; ///< Number of characters in this string (computed) members = ( - ('data', types.CPointer(types.char)), - ('bytes', types.int32), - ('length', types.int32), + ("data", types.CPointer(types.char)), + ("bytes", types.int32), + ("length", types.int32), ) super().__init__(dmm, fe_type, members) - + + class StrViewArgHandler: def prepare_args(self, ty, val, **kwargs): if isinstance(val, StringViewBuffer): @@ -172,6 +174,7 @@ def startswith(self, other): def endswith(self, other): pass + # For typing a Masked constant value defined outside a kernel (e.g. captured in # a closure). @typeof_impl.register(api.Masked) @@ -405,16 +408,21 @@ class MaskedStringViewLength(AbstractTemplate): """ provide the length of a cudf::string_view like struct """ + def generic(self, args, kws): - if isinstance(args[0], MaskedType) and isinstance(args[0].value_type, StringView): + if isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ): return nb_signature(types.int32, args[0]) + @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): """ provide the length of a python string literal by first converting to a cudf::string_view first """ + def generic(self, args, kws): if isinstance(args[0], types.StringLiteral) and len(args) == 1: return nb_signature(types.int32, args[0]) @@ -429,41 +437,56 @@ def generic(self, args, kws): for unary_op in unary_ops: cuda_decl_registry.register_global(unary_op)(MaskedScalarUnaryOp) + class MaskedStringStartsWith(AbstractTemplate): key = "MaskedType.startswith" def generic(self, args, kws): - return nb_signature(types.boolean, MaskedType(string_view), recvr=self.this) + return nb_signature( + types.boolean, MaskedType(string_view), recvr=self.this + ) class MaskedStringEndsWith(AbstractTemplate): key = "MaskedType.endswith" def generic(self, args, kws): - return nb_signature(types.boolean, MaskedType(string_view), recvr=self.this) + return nb_signature( + types.boolean, MaskedType(string_view), recvr=self.this + ) class MaskedStringFind(AbstractTemplate): key = "MaskedType.find" def generic(self, args, kws): - return nb_signature(types.int32, MaskedType(string_view), recvr=self.this) + return nb_signature( + types.int32, MaskedType(string_view), recvr=self.this + ) + class MaskedStringRFind(AbstractTemplate): key = "MaskedType.rfind" def generic(self, args, kws): - return nb_signature(types.int32, MaskedType(string_view), recvr=self.this) + return nb_signature( + types.int32, MaskedType(string_view), recvr=self.this + ) + @cuda_decl_registry.register_attr class MaskedStringAttrs(AttributeTemplate): key = MaskedType(string_view) def resolve_startswith(self, mod): - return types.BoundFunction(MaskedStringStartsWith, MaskedType(string_view)) + return types.BoundFunction( + MaskedStringStartsWith, MaskedType(string_view) + ) def resolve_endswith(self, mod): - return types.BoundFunction(MaskedStringEndsWith, MaskedType(string_view)) + return types.BoundFunction( + MaskedStringEndsWith, MaskedType(string_view) + ) def resolve_find(self, mod): return types.BoundFunction(MaskedStringFind, MaskedType(string_view)) @@ -471,8 +494,23 @@ def resolve_find(self, mod): def resolve_rfind(self, mod): return types.BoundFunction(MaskedStringRFind, MaskedType(string_view)) -_len_string_view = cuda.declare_device('len_2', types.int32(types.CPointer(string_view))) -_string_view_startswith = cuda.declare_device("startswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) -_string_view_endswith = cuda.declare_device("endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view))) -_string_view_find = cuda.declare_device("find", types.int32(types.CPointer(string_view), types.CPointer(string_view))) -_string_view_rfind = cuda.declare_device("rfind", types.int32(types.CPointer(string_view), types.CPointer(string_view))) + +_len_string_view = cuda.declare_device( + "len_2", types.int32(types.CPointer(string_view)) +) +_string_view_startswith = cuda.declare_device( + "startswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) +_string_view_endswith = cuda.declare_device( + "endswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) +_string_view_find = cuda.declare_device( + "find", + types.int32(types.CPointer(string_view), types.CPointer(string_view)), +) +_string_view_rfind = cuda.declare_device( + "rfind", + types.int32(types.CPointer(string_view), types.CPointer(string_view)), +) From 9eda4369e7239d391dd039f4cb36fdb16c734fc3 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 08:54:08 -0800 Subject: [PATCH 014/212] adjust and document StringViewArgHandler --- python/cudf/cudf/core/buffer.py | 3 --- python/cudf/cudf/core/udf/typing.py | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/python/cudf/cudf/core/buffer.py b/python/cudf/cudf/core/buffer.py index e7368865e8b..0658927975f 100644 --- a/python/cudf/cudf/core/buffer.py +++ b/python/cudf/cudf/core/buffer.py @@ -199,6 +199,3 @@ def get_c_contiguity(shape, strides, itemsize): if this_stride != this_dim * itemsize: return False return True - -class StringViewBuffer(Buffer): - pass diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 8bfa0a865e4..b6a89f2489e 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -17,7 +17,6 @@ from numba.cuda.cudadecl import registry as cuda_decl_registry from pandas._libs.missing import NAType as _NAType -from cudf.core.buffer import Buffer, StringViewBuffer from cudf.core.udf import api from cudf.core.udf._ops import ( arith_ops, @@ -34,8 +33,6 @@ types.PyObject, ) -from numba.extending import type_callable - # String object definitions class StringView(types.Type): @@ -68,8 +65,19 @@ def __init__(self, dmm, fe_type): class StrViewArgHandler: + """ + As part of Numbas preprocessing step incoming function arguments are + modified based on the associated type for that argument that was used + to JIT the kernel. However it only knows how to handle built in array + types natively. With string UDFs, the jitted type is string_view*, + which numba does not know how to handle. + + This small piece of code implements the necessary handling. Really all + it does is says is funnel the handling of string_view* to the handling + of raw pointer arguments, which numba knows what to do with. + """ def prepare_args(self, ty, val, **kwargs): - if isinstance(val, StringViewBuffer): + if isinstance(ty, types.CPointer) and isinstance(ty.dtype, StringView): return types.uint64, val.ptr else: return ty, val From bd56aaa6c23a93863bec4a16bc086799db681a52 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 08:55:21 -0800 Subject: [PATCH 015/212] adjust doc --- python/cudf/cudf/core/udf/typing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index b6a89f2489e..065a8d9ac62 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -75,6 +75,8 @@ class StrViewArgHandler: This small piece of code implements the necessary handling. Really all it does is says is funnel the handling of string_view* to the handling of raw pointer arguments, which numba knows what to do with. + + See numba.cuda.compiler._prepare_args for details. """ def prepare_args(self, ty, val, **kwargs): if isinstance(ty, types.CPointer) and isinstance(ty.dtype, StringView): From d12b6da26788cb33ed8c7943cc3d8caf837f7fba Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 09:27:02 -0800 Subject: [PATCH 016/212] move things around --- python/cudf/cudf/core/indexed_frame.py | 11 ++--------- python/cudf/cudf/core/udf/utils.py | 12 ++++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 1 - 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 4aa98f15d98..3c861d56acb 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -23,16 +23,14 @@ is_bool_dtype, is_categorical_dtype, is_integer_dtype, - is_string_dtype, is_list_like, ) from cudf.core.column_accessor import ColumnAccessor from cudf.core.frame import Frame from cudf.core.index import Index, RangeIndex, _index_from_columns from cudf.core.multiindex import MultiIndex -from cudf.core.udf.utils import _compile_or_get, _supported_cols_from_frame +from cudf.core.udf.utils import _compile_or_get, _launch_arg_from_col, _supported_cols_from_frame -from cudf_jit_udf import to_string_view_array doc_reset_index_template = """ Reset the index of the {klass}, or a level of it. @@ -844,12 +842,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): # if _compile_or_get succeeds, it is safe to create a kernel that only # consumes the columns that are of supported dtype for col in _supported_cols_from_frame(self).values(): - data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(col) - mask = col.mask - if mask is None: - launch_args.append(data) - else: - launch_args.append((data, mask)) + launch_args.append(_launch_arg_from_col(col)) offsets.append(col.offset) launch_args += offsets launch_args += list(args) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index e794f322c6c..c1b16a77835 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -8,6 +8,8 @@ from numba.types import Poison, Tuple, boolean, int64, void, CPointer from nvtx import annotate +from cudf.core.buffer import Buffer + from cudf.core.dtypes import CategoricalDtype from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler from cudf.utils import cudautils @@ -20,6 +22,8 @@ ) from cudf.api.types import is_string_dtype +from cudf_jit_udf import to_string_view_array + JIT_SUPPORTED_TYPES = ( NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES ) @@ -227,3 +231,11 @@ def _get_kernel(kernel_string, globals_, sig, func): kernel = cuda.jit(sig, link=['/home/nfs/brmiller/ipynb/strings_udf/len.ptx'], extensions=[str_view_arg_handler])(_kernel) return kernel + +def _launch_arg_from_col(col): + data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(col) + mask = col.mask + if mask is None: + return data + else: + return data, mask diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 9c65111cd2b..45c129a85b7 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -525,7 +525,6 @@ def func(row): @pytest.mark.parametrize( "unsupported_col", [ - ["a", "b", "c"], _decimal_series( ["1.0", "2.0", "3.0"], dtype=cudf.Decimal64Dtype(2, 1) ), From f2a72f04dd4c4a59dd2002aecf38023e6c811225 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 12:51:22 -0800 Subject: [PATCH 017/212] improvements to struct modeling logic --- python/cudf/cudf/core/udf/row_function.py | 6 ++-- python/cudf/cudf/core/udf/typing.py | 43 +++++++++++++---------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index d08d5e359fd..2519b9e3772 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -23,6 +23,8 @@ _supported_dtypes_from_frame, ) +from cudf.core.udf.typing import stringview_model + def _get_frame_row_type(dtype): """ @@ -47,7 +49,7 @@ def _get_frame_row_type(dtype): sizes = [] for field in dtype.fields.values(): if field[0] == np.dtype('object'): - sizes.append(24) + sizes.append(stringview_model.size_bytes) else: sizes.append(field[0].itemsize) @@ -69,7 +71,7 @@ def _get_frame_row_type(dtype): # increment offset by itemsize plus one byte for validity if elemdtype == np.dtype('object'): - itemsize = 24 + itemsize = stringview_model.size_bytes else: itemsize = elemdtype.itemsize offset += itemsize + 1 diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 065a8d9ac62..2c4c4e99606 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -50,18 +50,32 @@ def typeof_stringview(val, c): @register_model(StringView) class stringview_model(models.StructModel): + # from string_view.hpp: + # private: + # const char* _data{}; ///< Pointer to device memory contain char array for this string + # size_type _bytes{}; ///< Number of bytes in _data for this string + # mutable size_type _length{}; ///< Number of characters in this string (computed) + + _members = ( + ("data", types.CPointer(types.char)), + ("bytes", types.int32), + ("length", types.int32), + ) + + bytes = 0 + for member_ty in (t[1] for t in _members): + if isinstance(member_ty, types.CPointer): + bytes += 8 + else: + bytes += max(member_ty.bitwidth / 8, 8) + + size_bytes = bytes + + def __init__(self, dmm, fe_type): - # from string_view.hpp: - # private: - # const char* _data{}; ///< Pointer to device memory contain char array for this string - # size_type _bytes{}; ///< Number of bytes in _data for this string - # mutable size_type _length{}; ///< Number of characters in this string (computed) - members = ( - ("data", types.CPointer(types.char)), - ("bytes", types.int32), - ("length", types.int32), - ) - super().__init__(dmm, fe_type, members) + super().__init__(dmm, fe_type, self._members) + + class StrViewArgHandler: @@ -178,13 +192,6 @@ def __eq__(self, other): # Require a cast for another masked with a different value type return self.value_type == other.value_type - def startswith(self, other): - pass - - def endswith(self, other): - pass - - # For typing a Masked constant value defined outside a kernel (e.g. captured in # a closure). @typeof_impl.register(api.Masked) From 426820f86c2b3701a5b0489b9056016273dabeb1 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 12:51:41 -0800 Subject: [PATCH 018/212] fix caching issue --- python/cudf/cudf/utils/cudautils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/utils/cudautils.py b/python/cudf/cudf/utils/cudautils.py index 742c747ab69..44456c29cc3 100755 --- a/python/cudf/cudf/utils/cudautils.py +++ b/python/cudf/cudf/utils/cudautils.py @@ -217,13 +217,15 @@ def make_cache_key(udf, sig): """ codebytes = udf.__code__.co_code constants = udf.__code__.co_consts + names = udf.__code__.co_names + if udf.__closure__ is not None: cvars = tuple(x.cell_contents for x in udf.__closure__) cvarbytes = dumps(cvars) else: cvarbytes = b"" - return constants, codebytes, cvarbytes, sig + return names, constants, codebytes, cvarbytes, sig def compile_udf(udf, type_signature): From 132e6b8fd9e3acad1d12144d4c153ccccd4aac0a Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 13:13:18 -0800 Subject: [PATCH 019/212] struct size is only 16? --- python/cudf/cudf/core/udf/typing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 2c4c4e99606..0ee13862e52 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -65,9 +65,10 @@ class stringview_model(models.StructModel): bytes = 0 for member_ty in (t[1] for t in _members): if isinstance(member_ty, types.CPointer): + # TODO: is this always right? bytes += 8 else: - bytes += max(member_ty.bitwidth / 8, 8) + bytes += member_ty.bitwidth / 8 size_bytes = bytes From 22ce46749a2751bee17a94aa8a8469d6a94d0f6b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 9 Mar 2022 13:49:50 -0800 Subject: [PATCH 020/212] minor update --- python/cudf/cudf/core/udf/lowering.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index e1e074615d4..0ccc1dbb43f 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -383,7 +383,7 @@ def call_len_string_view(st): return _len_string_view(st) -@cuda_lower(len, MaskedType(types.pyobject)) +@cuda_lower(len, MaskedType(string_view)) def string_view_len_impl(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] From c6fbdcf3d2db64d121a98e512dac7658ff6ae48c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 6 Apr 2022 11:13:19 -0700 Subject: [PATCH 021/212] fix bug introduced by bad merge --- python/cudf/cudf/core/udf/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index a3735236943..6b6180f5a15 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -24,7 +24,10 @@ from cudf.api.types import is_string_dtype from cudf_jit_udf import to_string_view_array +from cudf.utils.utils import _cudf_nvtx_annotate + JIT_SUPPORTED_TYPES = ( + NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES ) libcudf_bitmask_type = numpy_support.from_dtype(np.dtype("int32")) MASK_BITSIZE = np.dtype("int32").itemsize * 8 From 1e9dec36afbddf7231ad6e0863a8e105e4b18c1e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 6 Apr 2022 13:42:22 -0700 Subject: [PATCH 022/212] partial implementation for returning strings --- .../cudf/_lib/cpp/column/column_factories.pxd | 6 +++ python/cudf/cudf/core/indexed_frame.py | 4 +- python/cudf/cudf/core/udf/lowering.py | 10 +++-- python/cudf/cudf/core/udf/typing.py | 38 +++++++++++++++++++ python/cudf/cudf/core/udf/utils.py | 18 +++++++-- 5 files changed, 66 insertions(+), 10 deletions(-) diff --git a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd index 0f22e788bd7..feb20b9ffa2 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd @@ -6,6 +6,8 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type, mask_state, size_type +cdef extern from "cudf/strings/string_view.hpp" namespace "cudf" nogil: + cdef cppclass string_view cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_numeric_column(data_type type, @@ -14,3 +16,7 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_column_from_scalar (const scalar & s, size_type size) except + + + cdef unique_ptr[column] make_strings_column( + string_view* inp, + ) diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index eb5161c11fb..c006925a0bd 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -43,7 +43,7 @@ from cudf.core.frame import Frame, _drop_rows_by_labels from cudf.core.index import Index, RangeIndex, _index_from_columns from cudf.core.multiindex import MultiIndex -from cudf.core.udf.utils import _compile_or_get, _launch_arg_from_col, _supported_cols_from_frame +from cudf.core.udf.utils import _compile_or_get, _launch_arg_from_col, _supported_cols_from_frame, _return_col_from_dtype from cudf.utils.utils import _cudf_nvtx_annotate doc_reset_index_template = """ @@ -1049,7 +1049,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): ) from e # Mask and data column preallocated - ans_col = cp.empty(len(self), dtype=retty) + ans_col = _return_col_from_dtype(retty, len(self)) ans_mask = cudf.core.column.column_empty(len(self), dtype="bool") launch_args = [(ans_col, ans_mask), len(self)] offsets = [] diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 1f2f9f323fe..2b9a62ba751 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -28,6 +28,7 @@ _string_view_rfind, _string_view_startswith, string_view, + dstring ) @@ -412,10 +413,11 @@ def string_view_len_impl(context, builder, sig, args): return result -# @cuda_lower(len, types.literal('abcde')) -# def string_literal_len_impl(context, builder, sig, args): -# # todo- should be able to compile out the length of literals... -# pass +@cuda_lowering_registry.lower_cast(string_view, dstring) +def cast_stringview_to_dstring(context, builder, fromty, toty, val): + """defer to the c++ constructor for this""" + out_dstr = cgutils.create_struct_proxy(toty)(context, builder) + return @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 8a629171391..fcecac63c1b 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -37,6 +37,37 @@ # String object definitions + +class DStringType(types.Type): + def __init__(self): + super().__init__(name='dstring') + +dstring = DStringType() + + +@register_model(DStringType) +class dstring_model(models.StructModel): + _members = ( + ('m_data', types.CPointer(types.char)), + ('m_bytes', types.int32), + ('m_size', types.int32), + ) + + bytes = 0 + for member_ty in (t[1] for t in _members): + if isinstance(member_ty, types.CPointer): + # TODO: is this always right? + bytes += 8 + else: + bytes += member_ty.bitwidth / 8 + + size_bytes = bytes + + def __init__(self, dmm, fe_type): + super().__init__(dmm, fe_type, self._members) + + + class StringView(types.Type): def __init__(self): super().__init__(name="string_view") @@ -522,6 +553,13 @@ def resolve_find(self, mod): def resolve_rfind(self, mod): return types.BoundFunction(MaskedStringRFind, MaskedType(string_view)) + def resolve_value(self, mod): + return string_view + + def resolve_valid(self, mod): + return types.boolean + + _len_string_view = cuda.declare_device( "len_2", types.int32(types.CPointer(string_view)) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 6b6180f5a15..b1618efc06d 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -9,10 +9,9 @@ from numba.np import numpy_support from numba.types import Poison, Tuple, boolean, int64, void, CPointer -from cudf.core.buffer import Buffer - +import cupy as cp from cudf.core.dtypes import CategoricalDtype -from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler +from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler, dstring_model from cudf.utils import cudautils from cudf.utils.dtypes import ( BOOL_TYPES, @@ -26,6 +25,8 @@ from cudf.utils.utils import _cudf_nvtx_annotate +import rmm + JIT_SUPPORTED_TYPES = ( NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES ) @@ -217,7 +218,7 @@ def _compile_or_get(frame, func, args, kernel_getter=None): kernel, scalar_return_type = kernel_getter(frame, func, args) - np_return_type = numpy_support.as_dtype(scalar_return_type) + np_return_type = scalar_return_type if scalar_return_type is string_view else numpy_support.as_dtype(scalar_return_type) precompiled[cache_key] = (kernel, np_return_type) return kernel, np_return_type @@ -240,3 +241,12 @@ def _launch_arg_from_col(col): return data else: return data, mask + +def _return_col_from_dtype(dt, size): + if dt is string_view: + # + return rmm.DeviceBuffer( + size=int(size * dstring_model.size_bytes) + ) + else: + return cp.empty(size, dtype=dt) From dd416a2e09369ba9d05550f7dec312ead92e1e94 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 8 Apr 2022 11:51:22 -0700 Subject: [PATCH 023/212] returning a string is working --- python/cudf/cudf/core/indexed_frame.py | 5 +++-- python/cudf/cudf/core/udf/lowering.py | 9 -------- python/cudf/cudf/core/udf/typing.py | 31 -------------------------- python/cudf/cudf/core/udf/utils.py | 14 +++++++++--- 4 files changed, 14 insertions(+), 45 deletions(-) diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index c006925a0bd..3b1539af4a7 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -43,7 +43,7 @@ from cudf.core.frame import Frame, _drop_rows_by_labels from cudf.core.index import Index, RangeIndex, _index_from_columns from cudf.core.multiindex import MultiIndex -from cudf.core.udf.utils import _compile_or_get, _launch_arg_from_col, _supported_cols_from_frame, _return_col_from_dtype +from cudf.core.udf.utils import _compile_or_get, _launch_arg_from_col, _supported_cols_from_frame, _return_col_from_dtype, _post_process_output_col from cudf.utils.utils import _cudf_nvtx_annotate doc_reset_index_template = """ @@ -1067,7 +1067,8 @@ def _apply(self, func, kernel_getter, *args, **kwargs): except Exception as e: raise RuntimeError("UDF kernel execution failed.") from e - col = cudf.core.column.as_column(ans_col) + col = _post_process_output_col(ans_col, retty) + col.set_base_mask(libcudf.transform.bools_to_mask(ans_mask)) result = cudf.Series._from_data({None: col}, self._index) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 2b9a62ba751..7275ba82a7d 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -28,7 +28,6 @@ _string_view_rfind, _string_view_startswith, string_view, - dstring ) @@ -298,7 +297,6 @@ def pack_return_scalar_impl(context, builder, sig, args): return outdata._getvalue() - @cuda_lower(operator.truth, MaskedType) def masked_scalar_truth_impl(context, builder, sig, args): indata = cgutils.create_struct_proxy(MaskedType(types.boolean))( @@ -413,13 +411,6 @@ def string_view_len_impl(context, builder, sig, args): return result -@cuda_lowering_registry.lower_cast(string_view, dstring) -def cast_stringview_to_dstring(context, builder, fromty, toty, val): - """defer to the c++ constructor for this""" - out_dstr = cgutils.create_struct_proxy(toty)(context, builder) - return - - @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) def cast_stringliteral_to_masked_stringview( context, builder, fromty, toty, val diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index fcecac63c1b..20d3e1bd4e4 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -37,37 +37,6 @@ # String object definitions - -class DStringType(types.Type): - def __init__(self): - super().__init__(name='dstring') - -dstring = DStringType() - - -@register_model(DStringType) -class dstring_model(models.StructModel): - _members = ( - ('m_data', types.CPointer(types.char)), - ('m_bytes', types.int32), - ('m_size', types.int32), - ) - - bytes = 0 - for member_ty in (t[1] for t in _members): - if isinstance(member_ty, types.CPointer): - # TODO: is this always right? - bytes += 8 - else: - bytes += member_ty.bitwidth / 8 - - size_bytes = bytes - - def __init__(self, dmm, fe_type): - super().__init__(dmm, fe_type, self._members) - - - class StringView(types.Type): def __init__(self): super().__init__(name="string_view") diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index b1618efc06d..0253ff18de0 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -11,7 +11,8 @@ import cupy as cp from cudf.core.dtypes import CategoricalDtype -from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler, dstring_model +from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler, stringview_model +from cudf.core.column.column import as_column from cudf.utils import cudautils from cudf.utils.dtypes import ( BOOL_TYPES, @@ -21,7 +22,7 @@ STRING_TYPES, ) from cudf.api.types import is_string_dtype -from cudf_jit_udf import to_string_view_array +from cudf_jit_udf import to_string_view_array, from_stringview_array from cudf.utils.utils import _cudf_nvtx_annotate @@ -246,7 +247,14 @@ def _return_col_from_dtype(dt, size): if dt is string_view: # return rmm.DeviceBuffer( - size=int(size * dstring_model.size_bytes) + size=int(size * stringview_model.size_bytes) ) else: return cp.empty(size, dtype=dt) + +def _post_process_output_col(col, retty): + if retty == string_view: + breakpoint() + return from_stringview_array(col) + else: + return as_column(col) From 0ebcd075811ce1ef8d248ed7f8bfc1e24bfbc532 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 8 Apr 2022 12:11:46 -0700 Subject: [PATCH 024/212] remove stale breakpoint --- python/cudf/cudf/core/udf/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 0253ff18de0..20acc810d16 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -254,7 +254,6 @@ def _return_col_from_dtype(dt, size): def _post_process_output_col(col, retty): if retty == string_view: - breakpoint() return from_stringview_array(col) else: return as_column(col) From 297070ae667833e5efe1d84dba9effe6904e906e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 11 Apr 2022 11:30:48 -0700 Subject: [PATCH 025/212] a wrong and not working, but informative attempt at upper() --- python/cudf/cudf/core/udf/lowering.py | 33 +++++++++++++++++++++++++++ python/cudf/cudf/core/udf/typing.py | 25 ++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 7275ba82a7d..6ea92f2825f 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -27,6 +27,7 @@ _string_view_find, _string_view_rfind, _string_view_startswith, + _string_view_upper, string_view, ) @@ -583,3 +584,35 @@ def masked_stringview_rfind(context, builder, sig, args): (st_ptr, tgt_ptr), ) return result + +def call_string_view_upper(st, tgt): + return _string_view_upper(st, tgt) + +@cuda_lower( + "MaskedType.upper", MaskedType(string_view), MaskedType(string_view) +) +def masked_stringview_upper(context, builder, sig, args): + maskedty = sig.args[0] + st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) + ret = cgutils.create_struct_proxy(maskedty)(context, builder) + + st_ptr = builder.alloca(st.value.type) + tgt_ptr = builder.alloca(st.value.type) + + builder.store(st.value, st_ptr) + + result = context.compile_internal( + builder, + call_string_view_upper, + nb_signature( + types.int32, types.CPointer(string_view), types.CPointer(string_view) + ), + (st_ptr, tgt_ptr), + ) + + #builder.store(ret.value, tgt_ptr) + + builder.store(ret.value, tgt_ptr) + ret.valid = st.valid + + return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 20d3e1bd4e4..e4fb0512b38 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -501,6 +501,13 @@ def generic(self, args, kws): types.int32, MaskedType(string_view), recvr=self.this ) +class MaskedStringUpper(AbstractTemplate): + key = "MaskedType.upper" + + def generic(self, args, kws): + return nb_signature( + MaskedType(string_view), MaskedType(string_view), recvr=self.this + ) @cuda_decl_registry.register_attr class MaskedStringAttrs(AttributeTemplate): @@ -517,10 +524,19 @@ def resolve_endswith(self, mod): ) def resolve_find(self, mod): - return types.BoundFunction(MaskedStringFind, MaskedType(string_view)) + return types.BoundFunction( + MaskedStringFind, MaskedType(string_view) + ) def resolve_rfind(self, mod): - return types.BoundFunction(MaskedStringRFind, MaskedType(string_view)) + return types.BoundFunction( + MaskedStringRFind, MaskedType(string_view) + ) + + def resolve_upper(self, mod): + return types.BoundFunction( + MaskedStringUpper, MaskedType(string_view) + ) def resolve_value(self, mod): return string_view @@ -549,3 +565,8 @@ def resolve_valid(self, mod): "rfind", types.int32(types.CPointer(string_view), types.CPointer(string_view)), ) + +_string_view_upper = cuda.declare_device( + "upper", + types.int32(types.CPointer(string_view), types.CPointer(string_view)), +) From e3456de510aa5139a02c5b5c14690d668879c855 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 11 Apr 2022 14:06:09 -0700 Subject: [PATCH 026/212] returning dstrings instead of string_views --- python/cudf/cudf/core/udf/lowering.py | 44 +++++++++++++++++- python/cudf/cudf/core/udf/row_function.py | 7 ++- python/cudf/cudf/core/udf/typing.py | 54 +++++++++++++++++++---- python/cudf/cudf/core/udf/utils.py | 17 +++---- 4 files changed, 100 insertions(+), 22 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 6ea92f2825f..2a2ef2cbc38 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -28,7 +28,9 @@ _string_view_rfind, _string_view_startswith, _string_view_upper, + _create_dstring_from_stringview, string_view, + dstring ) @@ -291,6 +293,7 @@ def pack_return_masked_impl(context, builder, sig, args): @cuda_lower(api.pack_return, types.Number) @cuda_lower(api.pack_return, types.NPDatetime) @cuda_lower(api.pack_return, types.NPTimedelta) +@cuda_lower(api.pack_return, dstring) def pack_return_scalar_impl(context, builder, sig, args): outdata = cgutils.create_struct_proxy(sig.return_type)(context, builder) outdata.value = args[0] @@ -361,7 +364,7 @@ def cast_masked_to_masked(context, builder, fromty, toty, val): @lower_builtin(api.Masked, types.Number, types.boolean) @lower_builtin(api.Masked, types.NPDatetime, types.boolean) @lower_builtin(api.Masked, types.NPTimedelta, types.boolean) -@lower_builtin(api.Masked, string_view, types.boolean) +@lower_builtin(api.Masked, dstring, types.boolean) def masked_constructor(context, builder, sig, args): ty = sig.return_type value, valid = args @@ -370,6 +373,33 @@ def masked_constructor(context, builder, sig, args): masked.valid = valid return masked._getvalue() +# make it so that string input data is immediately converted +# to a MaskedType(dstring). This guarantees string functions +# only need to ever expect cudf::dstring inputs and guarantees +# that UDFs returning string data will always return dstring types +def call_create_dstring_from_stringview(strview, dstr): + return _create_dstring_from_stringview(strview, dstr) + +@lower_builtin(api.Masked, string_view, types.boolean) +def masked_constructor_stringview(context, builder, sig, args): + #breakpoint() + value, valid = args + ret = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) + + dstr = builder.alloca(ret.value.type) + strview = builder.alloca(value.type) + + builder.store(value, strview) + + _ = context.compile_internal( + builder, + call_create_dstring_from_stringview, + nb_signature(types.int32, types.CPointer(string_view), types.CPointer(dstring)), + (strview, dstr) + ) + ret.valid = valid + return ret._getvalue() + # Allows us to make an instance of MaskedType a global variable # and properly use it inside functions we will later compile @@ -589,9 +619,19 @@ def call_string_view_upper(st, tgt): return _string_view_upper(st, tgt) @cuda_lower( - "MaskedType.upper", MaskedType(string_view), MaskedType(string_view) + "MaskedType.upper", MaskedType(string_view) ) def masked_stringview_upper(context, builder, sig, args): + # create an empty MaskedType(dstring) + retty = cgutils.create_struct_proxy(sig.return_type)(context, builder) + + # input struct + input_masked_strview = cgutils.create_struct_proxy(sig.args[0])( + context, builder, value=args[0] + ) + + + maskedty = sig.args[0] st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) ret = cgutils.create_struct_proxy(maskedty)(context, builder) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index d4ec9c74d43..634d3811c0a 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -24,7 +24,7 @@ _supported_dtypes_from_frame, ) -from cudf.core.udf.typing import stringview_model +from cudf.core.udf.typing import stringview_model, dstring_model def _get_frame_row_type(dtype): @@ -50,7 +50,7 @@ def _get_frame_row_type(dtype): sizes = [] for field in dtype.fields.values(): if field[0] == np.dtype('object'): - sizes.append(stringview_model.size_bytes) + sizes.append(dstring_model.size_bytes) else: sizes.append(field[0].itemsize) @@ -72,7 +72,7 @@ def _get_frame_row_type(dtype): # increment offset by itemsize plus one byte for validity if elemdtype == np.dtype('object'): - itemsize = stringview_model.size_bytes + itemsize = dstring_model.size_bytes else: itemsize = elemdtype.itemsize offset += itemsize + 1 @@ -142,7 +142,6 @@ def _get_row_kernel(frame, func, args): scalar_return_type = _get_udf_return_type(row_type, func, args) # this is the signature for the final full kernel compilation sig = _construct_signature(frame, scalar_return_type, args) - # this row type is used within the kernel to pack up the column and # mask data into the dict like data structure the user udf expects np_field_types = np.dtype( diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index e4fb0512b38..dac1a6fc6a1 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -37,18 +37,28 @@ # String object definitions +class DString(types.Type): + def __init__(self): + super().__init__(name="dstring") + + + class StringView(types.Type): def __init__(self): super().__init__(name="string_view") string_view = StringView() +dstring = DString() @typeof_impl.register(StringView) def typeof_stringview(val, c): return string_view +@typeof_impl.register(DString) +def typeof_dstring(val, c): + return dstring @register_model(StringView) class stringview_model(models.StructModel): @@ -74,11 +84,34 @@ class stringview_model(models.StructModel): size_bytes = bytes - def __init__(self, dmm, fe_type): super().__init__(dmm, fe_type, self._members) +@register_model(DString) +class dstring_model(models.StructModel): + # from dstring.hpp: + # private: + # char* m_data{}; + # cudf::size_type m_bytes{}; + # cudf::size_type m_size{}; + _members = ( + ("m_data", types.CPointer(types.char)), + ("m_bytes", types.int32), + ("m_size", types.int32) + ) + bytes = 0 + for member_ty in (t[1] for t in _members): + if isinstance(member_ty, types.CPointer): + # TODO: is this always right? + bytes += 8 + else: + bytes += member_ty.bitwidth / 8 + + size_bytes = bytes + + def __init__(self, dmm, fe_type): + super().__init__(dmm, fe_type, self._members) class StrViewArgHandler: @@ -96,7 +129,7 @@ class StrViewArgHandler: See numba.cuda.compiler._prepare_args for details. """ def prepare_args(self, ty, val, **kwargs): - if isinstance(ty, types.CPointer) and isinstance(ty.dtype, StringView): + if isinstance(ty, types.CPointer) and isinstance(ty.dtype, DString): return types.uint64, val.ptr else: return ty, val @@ -116,8 +149,8 @@ def __init__(self, value): # with a value type # TODO - replace object with stringview immediately - if isinstance(value, (types.PyObject, StringView)): - self.value_type = string_view + if isinstance(value, (types.PyObject, StringView, DString)): + self.value_type = dstring elif isinstance(value, SUPPORTED_NUMBA_TYPES): self.value_type = value else: @@ -218,7 +251,7 @@ class MaskedConstructor(ConcreteTemplate): | datetime_cases | timedelta_cases | {types.boolean} - | {types.pyobject, string_view} + | {types.pyobject, string_view, dstring} ) ] @@ -506,7 +539,7 @@ class MaskedStringUpper(AbstractTemplate): def generic(self, args, kws): return nb_signature( - MaskedType(string_view), MaskedType(string_view), recvr=self.this + MaskedType(dstring), recvr=self.this ) @cuda_decl_registry.register_attr @@ -539,7 +572,7 @@ def resolve_upper(self, mod): ) def resolve_value(self, mod): - return string_view + return dstring def resolve_valid(self, mod): return types.boolean @@ -568,5 +601,10 @@ def resolve_valid(self, mod): _string_view_upper = cuda.declare_device( "upper", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), + types.int32(types.CPointer(dstring), types.CPointer(string_view)), +) + +_create_dstring_from_stringview = cuda.declare_device( + "create_dstring_from_stringview", + types.int32(types.CPointer(string_view), types.CPointer(dstring)) ) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 20acc810d16..1e107da6bb2 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -11,7 +11,7 @@ import cupy as cp from cudf.core.dtypes import CategoricalDtype -from cudf.core.udf.typing import MaskedType, string_view, str_view_arg_handler, stringview_model +from cudf.core.udf.typing import MaskedType, dstring_model, string_view, str_view_arg_handler, dstring from cudf.core.column.column import as_column from cudf.utils import cudautils from cudf.utils.dtypes import ( @@ -22,7 +22,7 @@ STRING_TYPES, ) from cudf.api.types import is_string_dtype -from cudf_jit_udf import to_string_view_array, from_stringview_array +from cudf_jit_udf import to_string_view_array, from_dstring_array from cudf.utils.utils import _cudf_nvtx_annotate @@ -125,7 +125,7 @@ def _masked_array_type_from_col(col): """ if is_string_dtype(col.dtype): # strings_udf library provides a pointer directly to the data - col_type = CPointer(string_view) + col_type = CPointer(dstring) else: nb_scalar_ty = numpy_support.from_dtype(col.dtype) col_type = nb_scalar_ty[::1] @@ -219,7 +219,7 @@ def _compile_or_get(frame, func, args, kernel_getter=None): kernel, scalar_return_type = kernel_getter(frame, func, args) - np_return_type = scalar_return_type if scalar_return_type is string_view else numpy_support.as_dtype(scalar_return_type) + np_return_type = scalar_return_type if scalar_return_type is dstring else numpy_support.as_dtype(scalar_return_type) precompiled[cache_key] = (kernel, np_return_type) return kernel, np_return_type @@ -244,16 +244,17 @@ def _launch_arg_from_col(col): return data, mask def _return_col_from_dtype(dt, size): - if dt is string_view: + if dt is dstring: # return rmm.DeviceBuffer( - size=int(size * stringview_model.size_bytes) + size=int(size * dstring_model.size_bytes) ) else: return cp.empty(size, dtype=dt) def _post_process_output_col(col, retty): - if retty == string_view: - return from_stringview_array(col) + if retty == dstring: + breakpoint() + return from_dstring_array(col) else: return as_column(col) From 55abe5e33291ab4f6e8b558931b93fa03cfbc16a Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 12 Apr 2022 07:49:59 -0700 Subject: [PATCH 027/212] fully convert to dstring --- python/cudf/cudf/core/udf/lowering.py | 108 +++++++++++++------------- python/cudf/cudf/core/udf/typing.py | 52 ++++++------- 2 files changed, 81 insertions(+), 79 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 2a2ef2cbc38..0f024c98130 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -22,12 +22,12 @@ from cudf.core.udf.typing import ( MaskedType, NAType, - _len_string_view, - _string_view_endswith, - _string_view_find, - _string_view_rfind, - _string_view_startswith, - _string_view_upper, + _dstring_len, + _dstring_endswith, + _dstring_find, + _dstring_rfind, + _dstring_startswith, + _dstring_upper, _create_dstring_from_stringview, string_view, dstring @@ -412,55 +412,57 @@ def lower_constant_masked(context, builder, ty, val): # String function implementations -def call_len_string_view(st): - return _len_string_view(st) +def call_len_dstring(st): + return _dstring_len(st) -@cuda_lower(len, MaskedType(string_view)) +@cuda_lower(len, MaskedType(dstring)) def string_view_len_impl(context, builder, sig, args): - retty = sig.return_type - maskedty = sig.args[0] - masked_str = cgutils.create_struct_proxy(maskedty)( + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_dstr_ty = sig.args[0] + masked_dstr = cgutils.create_struct_proxy(masked_dstr_ty)( context, builder, value=args[0] ) # the first element is the string_view struct # get a pointer that we will copy the data to - strty = masked_str.value.type + strty = masked_dstr.value.type arg = builder.alloca(strty) # store - builder.store(masked_str.value, arg) + builder.store(masked_dstr.value, arg) result = context.compile_internal( builder, - call_len_string_view, - nb_signature(retty, types.CPointer(string_view)), + call_len_dstring, + nb_signature(sig.return_type.value_type, types.CPointer(dstring)), (arg,), ) + ret.value = result + ret.valid = masked_dstr.valid - return result + return ret._getvalue() @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) -def cast_stringliteral_to_masked_stringview( +def cast_stringliteral_to_masked_dstring( context, builder, fromty, toty, val ): """ - cast a literal to a Masked(string_view) + cast a literal to a Masked(dstring) """ # create an empty string_view - str_view = cgutils.create_struct_proxy(toty.value_type)(context, builder) + dstr = cgutils.create_struct_proxy(dstring)(context, builder) # set the empty strview data pointer to point to the literal value s = context.insert_const_string(builder.module, fromty.literal_value) - str_view.data = context.insert_addrspace_conv( + dstr.m_data = context.insert_addrspace_conv( builder, s, nvvm.ADDRSPACE_CONSTANT ) - str_view.length = context.get_constant( + dstr.m_size = context.get_constant( types.int32, len(fromty.literal_value) ) - str_view.bytes = context.get_constant( + dstr.m_bytes = context.get_constant( types.int32, len(fromty.literal_value.encode("UTF-8")) ) @@ -471,19 +473,19 @@ def cast_stringliteral_to_masked_stringview( to_return.valid = context.get_constant(types.boolean, 1) # set the value to be the string view - to_return.value = str_view._getvalue() + to_return.value = dstr._getvalue() return to_return._getvalue() -def call_string_view_startswith(st, tgt): - return _string_view_startswith(st, tgt) +def call_dstring_startswith(st, tgt): + return _dstring_startswith(st, tgt) @cuda_lower( - "MaskedType.startswith", MaskedType(string_view), MaskedType(string_view) + "MaskedType.startswith", MaskedType(dstring), MaskedType(dstring) ) -def masked_stringview_startswith(context, builder, sig, args): +def masked_dstring_startswith(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] @@ -502,23 +504,23 @@ def masked_stringview_startswith(context, builder, sig, args): result = context.compile_internal( builder, - call_string_view_startswith, + call_dstring_startswith, nb_signature( - retty, types.CPointer(string_view), types.CPointer(string_view) + retty, types.CPointer(dstring), types.CPointer(dstring) ), (st_ptr, tgt_ptr), ) return result -def call_string_view_endswith(st, tgt): - return _string_view_endswith(st, tgt) +def call_dstring_endswith(st, tgt): + return _dstring_endswith(st, tgt) @cuda_lower( - "MaskedType.endswith", MaskedType(string_view), MaskedType(string_view) + "MaskedType.endswith", MaskedType(dstring), MaskedType(dstring) ) -def masked_stringview_endswith(context, builder, sig, args): +def masked_dstring_endswith(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] @@ -537,23 +539,23 @@ def masked_stringview_endswith(context, builder, sig, args): result = context.compile_internal( builder, - call_string_view_endswith, + call_dstring_endswith, nb_signature( - retty, types.CPointer(string_view), types.CPointer(string_view) + retty, types.CPointer(dstring), types.CPointer(dstring) ), (st_ptr, tgt_ptr), ) return result -def call_string_view_find(st, tgt): - return _string_view_find(st, tgt) +def call_dstring_find(st, tgt): + return _dstring_find(st, tgt) @cuda_lower( - "MaskedType.find", MaskedType(string_view), MaskedType(string_view) + "MaskedType.find", MaskedType(dstring), MaskedType(dstring) ) -def masked_stringview_find(context, builder, sig, args): +def masked_dstring_find(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] @@ -572,23 +574,23 @@ def masked_stringview_find(context, builder, sig, args): result = context.compile_internal( builder, - call_string_view_find, + call_dstring_find, nb_signature( - retty, types.CPointer(string_view), types.CPointer(string_view) + retty, types.CPointer(dstring), types.CPointer(dstring) ), (st_ptr, tgt_ptr), ) return result -def call_string_view_rfind(st, tgt): - return _string_view_rfind(st, tgt) +def call_dstring_rfind(st, tgt): + return _dstring_rfind(st, tgt) @cuda_lower( - "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) + "MaskedType.rfind", MaskedType(dstring), MaskedType(dstring) ) -def masked_stringview_rfind(context, builder, sig, args): +def masked_dstring_rfind(context, builder, sig, args): retty = sig.return_type maskedty = sig.args[0] @@ -607,19 +609,19 @@ def masked_stringview_rfind(context, builder, sig, args): result = context.compile_internal( builder, - call_string_view_rfind, + call_dstring_rfind, nb_signature( - retty, types.CPointer(string_view), types.CPointer(string_view) + retty, types.CPointer(dstring), types.CPointer(dstring) ), (st_ptr, tgt_ptr), ) return result -def call_string_view_upper(st, tgt): - return _string_view_upper(st, tgt) +def call_dstring_upper(st, tgt): + return _dstring_upper(st, tgt) @cuda_lower( - "MaskedType.upper", MaskedType(string_view) + "MaskedType.upper", MaskedType(dstring) ) def masked_stringview_upper(context, builder, sig, args): # create an empty MaskedType(dstring) @@ -643,9 +645,9 @@ def masked_stringview_upper(context, builder, sig, args): result = context.compile_internal( builder, - call_string_view_upper, + call_dstring_upper, nb_signature( - types.int32, types.CPointer(string_view), types.CPointer(string_view) + types.int32, types.CPointer(dstring), types.CPointer(dstring) ), (st_ptr, tgt_ptr), ) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index dac1a6fc6a1..3e17d2b1a56 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -465,16 +465,16 @@ def generic(self, args, kws): # String functions @cuda_decl_registry.register_global(len) -class MaskedStringViewLength(AbstractTemplate): +class MaskedDStringLength(AbstractTemplate): """ provide the length of a cudf::string_view like struct """ def generic(self, args, kws): if isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView + args[0].value_type, DString ): - return nb_signature(types.int32, args[0]) + return nb_signature(MaskedType(types.int32), args[0]) @cuda_decl_registry.register_global(len) @@ -504,7 +504,7 @@ class MaskedStringStartsWith(AbstractTemplate): def generic(self, args, kws): return nb_signature( - types.boolean, MaskedType(string_view), recvr=self.this + types.boolean, MaskedType(dstring), recvr=self.this ) @@ -513,7 +513,7 @@ class MaskedStringEndsWith(AbstractTemplate): def generic(self, args, kws): return nb_signature( - types.boolean, MaskedType(string_view), recvr=self.this + types.boolean, MaskedType(dstring), recvr=self.this ) @@ -522,7 +522,7 @@ class MaskedStringFind(AbstractTemplate): def generic(self, args, kws): return nb_signature( - types.int32, MaskedType(string_view), recvr=self.this + types.int32, MaskedType(dstring), recvr=self.this ) @@ -531,7 +531,7 @@ class MaskedStringRFind(AbstractTemplate): def generic(self, args, kws): return nb_signature( - types.int32, MaskedType(string_view), recvr=self.this + types.int32, MaskedType(dstring), recvr=self.this ) class MaskedStringUpper(AbstractTemplate): @@ -543,32 +543,32 @@ def generic(self, args, kws): ) @cuda_decl_registry.register_attr -class MaskedStringAttrs(AttributeTemplate): - key = MaskedType(string_view) +class MaskedDStringAttrs(AttributeTemplate): + key = MaskedType(dstring) def resolve_startswith(self, mod): return types.BoundFunction( - MaskedStringStartsWith, MaskedType(string_view) + MaskedStringStartsWith, MaskedType(dstring) ) def resolve_endswith(self, mod): return types.BoundFunction( - MaskedStringEndsWith, MaskedType(string_view) + MaskedStringEndsWith, MaskedType(dstring) ) def resolve_find(self, mod): return types.BoundFunction( - MaskedStringFind, MaskedType(string_view) + MaskedStringFind, MaskedType(dstring) ) def resolve_rfind(self, mod): return types.BoundFunction( - MaskedStringRFind, MaskedType(string_view) + MaskedStringRFind, MaskedType(dstring) ) def resolve_upper(self, mod): return types.BoundFunction( - MaskedStringUpper, MaskedType(string_view) + MaskedStringUpper, MaskedType(dstring) ) def resolve_value(self, mod): @@ -579,29 +579,29 @@ def resolve_valid(self, mod): -_len_string_view = cuda.declare_device( - "len_2", types.int32(types.CPointer(string_view)) +_dstring_len = cuda.declare_device( + "len", types.int32(types.CPointer(dstring)) ) -_string_view_startswith = cuda.declare_device( +_dstring_startswith = cuda.declare_device( "startswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(types.CPointer(dstring), types.CPointer(dstring)), ) -_string_view_endswith = cuda.declare_device( +_dstring_endswith = cuda.declare_device( "endswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(types.CPointer(dstring), types.CPointer(dstring)), ) -_string_view_find = cuda.declare_device( +_dstring_find = cuda.declare_device( "find", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), + types.int32(types.CPointer(dstring), types.CPointer(dstring)), ) -_string_view_rfind = cuda.declare_device( +_dstring_rfind = cuda.declare_device( "rfind", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), + types.int32(types.CPointer(dstring), types.CPointer(dstring)), ) -_string_view_upper = cuda.declare_device( +_dstring_upper = cuda.declare_device( "upper", - types.int32(types.CPointer(dstring), types.CPointer(string_view)), + types.int32(types.CPointer(dstring), types.CPointer(dstring)), ) _create_dstring_from_stringview = cuda.declare_device( From 1dbd42751bece15bf6b9605922adda2e9a206c29 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 12 Apr 2022 09:03:17 -0700 Subject: [PATCH 028/212] tests and plumbing for upper --- python/cudf/cudf/core/udf/lowering.py | 27 +++++++------------ python/cudf/cudf/core/udf/utils.py | 1 - python/cudf/cudf/tests/test_udf_masked_ops.py | 15 +++++++++++ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 0f024c98130..2684bb96f4e 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -623,27 +623,21 @@ def call_dstring_upper(st, tgt): @cuda_lower( "MaskedType.upper", MaskedType(dstring) ) -def masked_stringview_upper(context, builder, sig, args): +def masked_dstring_upper(context, builder, sig, args): # create an empty MaskedType(dstring) - retty = cgutils.create_struct_proxy(sig.return_type)(context, builder) + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) # input struct - input_masked_strview = cgutils.create_struct_proxy(sig.args[0])( + input_masked_dstring = cgutils.create_struct_proxy(sig.args[0])( context, builder, value=args[0] ) + st_ptr = builder.alloca(input_masked_dstring.value.type) + tgt_ptr = builder.alloca(input_masked_dstring.value.type) + builder.store(input_masked_dstring.value, st_ptr) - maskedty = sig.args[0] - st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - ret = cgutils.create_struct_proxy(maskedty)(context, builder) - - st_ptr = builder.alloca(st.value.type) - tgt_ptr = builder.alloca(st.value.type) - - builder.store(st.value, st_ptr) - - result = context.compile_internal( + _ = context.compile_internal( builder, call_dstring_upper, nb_signature( @@ -652,9 +646,6 @@ def masked_stringview_upper(context, builder, sig, args): (st_ptr, tgt_ptr), ) - #builder.store(ret.value, tgt_ptr) - - builder.store(ret.value, tgt_ptr) - ret.valid = st.valid - + ret.value = builder.load(tgt_ptr) + ret.valid = input_masked_dstring.valid return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 1e107da6bb2..5bc53bdbd61 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -254,7 +254,6 @@ def _return_col_from_dtype(dt, size): def _post_process_output_col(col, retty): if retty == dstring: - breakpoint() return from_dstring_array(col) else: return as_column(col) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index af2b5f95155..15b2afbdb10 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -782,3 +782,18 @@ def func(row): return st.rfind(substr) run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ["abc", "ABC", "aBc", "123", ""] + } +]) +def test_string_udf_upper(data): + # tests the `upper` method of strings + + data = cudf.DataFrame(data) + def func(row): + st = row['str_col'] + return st.upper() + + run_masked_udf_test(func, data, check_dtype=False) From f030f90fa5dc71df6ef4669bb1a0aa600f3b85b4 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 12 Apr 2022 09:13:57 -0700 Subject: [PATCH 029/212] plumbed lower --- python/cudf/cudf/core/udf/lowering.py | 34 +++++++++++++++++++ python/cudf/cudf/core/udf/typing.py | 18 ++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 15 ++++++++ 3 files changed, 67 insertions(+) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 2684bb96f4e..bd49f1e4048 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -28,6 +28,7 @@ _dstring_rfind, _dstring_startswith, _dstring_upper, + _dstring_lower, _create_dstring_from_stringview, string_view, dstring @@ -649,3 +650,36 @@ def masked_dstring_upper(context, builder, sig, args): ret.value = builder.load(tgt_ptr) ret.valid = input_masked_dstring.valid return ret._getvalue() + +def call_dstring_lower(st, tgt): + return _dstring_lower(st, tgt) + +@cuda_lower( + "MaskedType.lower", MaskedType(dstring) +) +def masked_dstring_lower(context, builder, sig, args): + # create an empty MaskedType(dstring) + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + + # input struct + input_masked_dstring = cgutils.create_struct_proxy(sig.args[0])( + context, builder, value=args[0] + ) + + st_ptr = builder.alloca(input_masked_dstring.value.type) + tgt_ptr = builder.alloca(input_masked_dstring.value.type) + + builder.store(input_masked_dstring.value, st_ptr) + + _ = context.compile_internal( + builder, + call_dstring_lower, + nb_signature( + types.int32, types.CPointer(dstring), types.CPointer(dstring) + ), + (st_ptr, tgt_ptr), + ) + + ret.value = builder.load(tgt_ptr) + ret.valid = input_masked_dstring.valid + return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 3e17d2b1a56..de46efc682d 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -542,6 +542,14 @@ def generic(self, args, kws): MaskedType(dstring), recvr=self.this ) +class MaskedStringLower(AbstractTemplate): + key = "MaskedType.lower" + + def generic(self, args, kws): + return nb_signature( + MaskedType(dstring), recvr=self.this + ) + @cuda_decl_registry.register_attr class MaskedDStringAttrs(AttributeTemplate): key = MaskedType(dstring) @@ -571,6 +579,11 @@ def resolve_upper(self, mod): MaskedStringUpper, MaskedType(dstring) ) + def resolve_lower(self, mod): + return types.BoundFunction( + MaskedStringLower, MaskedType(dstring) + ) + def resolve_value(self, mod): return dstring @@ -604,6 +617,11 @@ def resolve_valid(self, mod): types.int32(types.CPointer(dstring), types.CPointer(dstring)), ) +_dstring_lower = cuda.declare_device( + "lower", + types.int32(types.CPointer(dstring), types.CPointer(dstring)) +) + _create_dstring_from_stringview = cuda.declare_device( "create_dstring_from_stringview", types.int32(types.CPointer(string_view), types.CPointer(dstring)) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 15b2afbdb10..5fbc36dae47 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -797,3 +797,18 @@ def func(row): return st.upper() run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ["abc", "ABC", "aBc", "123", ""] + } +]) +def test_string_udf_lower(data): + # tests the `lower` method of strings + + data = cudf.DataFrame(data) + def func(row): + st = row['str_col'] + return st.lower() + + run_masked_udf_test(func, data, check_dtype=False) From 4c95fc325c757f63811875b94e40af6a775e5769 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 13 Apr 2022 10:44:59 -0700 Subject: [PATCH 030/212] partial getitem implementation for ints, not working yet --- python/cudf/cudf/core/udf/lowering.py | 31 +++++++++++++++++++ python/cudf/cudf/core/udf/typing.py | 17 ++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 17 ++++++++++ 3 files changed, 65 insertions(+) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index bd49f1e4048..3e80f4e94a9 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -29,11 +29,14 @@ _dstring_startswith, _dstring_upper, _dstring_lower, + _dstring_at, _create_dstring_from_stringview, string_view, dstring ) +import operator + @cuda_lowering_registry.lower_constant(NAType) def constant_na(context, builder, ty, pyval): @@ -444,6 +447,34 @@ def string_view_len_impl(context, builder, sig, args): return ret._getvalue() +def call_dstring_at(st, tgt, idx): + return _dstring_at(st, tgt, idx) + +@cuda_lower(operator.getitem, MaskedType(dstring), types.Integer) +def masked_dstring_substring(context, builder, sig, args): + input = cgutils.create_struct_proxy(sig.args[0])(context, builder, value=args[0]) + + # create two pointers to empty dstrings + strty = input.value.type + dstr = builder.alloca(strty) + retstr = builder.alloca(strty) + + # store the real input value as the first dstring + builder.store(input.value, dstr) + + # call dstring::at + _ = context.compile_internal( + builder, + call_dstring_at, + nb_signature(types.CPointer(dstring), types.CPointer(dstring), sig.args[1]), + (dstr, retstr, args[1]) + ) + + to_return = cgutils.create_struct_proxy(sig.return_type) + to_return.valid = input.valid + to_return.value = builder.load(retstr) + + return to_return._getvalue() @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) def cast_stringliteral_to_masked_dstring( diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index de46efc682d..aebb7d07213 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -35,6 +35,7 @@ types.PyObject, ) +import operator # String object definitions class DString(types.Type): @@ -489,6 +490,17 @@ def generic(self, args, kws): return nb_signature(types.int32, args[0]) +@cuda_decl_registry.register_global(operator.getitem) +class MaskedDstringSubstring(AbstractTemplate): + """ + Typing for st[idx], st[:idx], etc + """ + def generic(self, args, kws): + if isinstance(args[0], MaskedType) and args[0].value_type == dstring and isinstance(args[1], types.Integer): + # __getitem__ is actually a two argument function: (val, idx) -> ret + return nb_signature(MaskedType(dstring), MaskedType(dstring), args[1]) + + for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) @@ -622,6 +634,11 @@ def resolve_valid(self, mod): types.int32(types.CPointer(dstring), types.CPointer(dstring)) ) +_dstring_at = cuda.declare_device( + "at", + types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int32) +) + _create_dstring_from_stringview = cuda.declare_device( "create_dstring_from_stringview", types.int32(types.CPointer(string_view), types.CPointer(dstring)) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 5fbc36dae47..36b35b90de2 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -812,3 +812,20 @@ def func(row): return st.lower() run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ['abc', 'a', '', '123AbC'] + } +]) +@pytest.mark.parametrize("idx", [0, 1, 2, -1]) +def test_string_udf_indexing(data, idx): + # tests indexing into strings with an int + + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return row[idx] + + run_masked_udf_test(func, data) From f09ecebd2070e35a892d2779f98196a66572fd0d Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 13 Apr 2022 12:21:31 -0700 Subject: [PATCH 031/212] substring plumbing, also not working (for the same reason as at) --- python/cudf/cudf/core/udf/lowering.py | 34 ++++++++++++++++++- python/cudf/cudf/core/udf/typing.py | 12 +++++-- python/cudf/cudf/tests/test_udf_masked_ops.py | 23 +++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 3e80f4e94a9..d20ddddb2f6 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -30,6 +30,7 @@ _dstring_upper, _dstring_lower, _dstring_at, + _dstring_substr, _create_dstring_from_stringview, string_view, dstring @@ -451,7 +452,7 @@ def call_dstring_at(st, tgt, idx): return _dstring_at(st, tgt, idx) @cuda_lower(operator.getitem, MaskedType(dstring), types.Integer) -def masked_dstring_substring(context, builder, sig, args): +def masked_dstring_at(context, builder, sig, args): input = cgutils.create_struct_proxy(sig.args[0])(context, builder, value=args[0]) # create two pointers to empty dstrings @@ -476,6 +477,37 @@ def masked_dstring_substring(context, builder, sig, args): return to_return._getvalue() +def call_dstring_substr(st, tgt, start, stop): + return _dstring_substr(st, tgt, start, stop) + +@cuda_lower(operator.getitem, MaskedType(dstring), types.SliceType) +def masked_dstring_substring(context, builder, sig, args): + input = cgutils.create_struct_proxy(sig.args[0])(context, builder, value=args[0]) + slc = cgutils.create_struct_proxy(sig.args[1])(context, builder, value=args[1]) + + # create two pointers to empty dstrings + strty = input.value.type + dstr = builder.alloca(strty) + retstr = builder.alloca(strty) + + # store the real input value as the first dstring + builder.store(input.value, dstr) + + # call dstring::substring + _ = context.compile_internal( + builder, + call_dstring_substr, + nb_signature(types.CPointer(dstring), types.CPointer(dstring), types.int32, types.int32), + (dstr, retstr, slc.start, slc.stop) + ) + + to_return = cgutils.create_struct_proxy(sig.return_type) + to_return.valid = input.valid + to_return.value = builder.load(retstr) + + return to_return._getvalue() + + @cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) def cast_stringliteral_to_masked_dstring( context, builder, fromty, toty, val diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index aebb7d07213..c6a1b8af254 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -496,11 +496,14 @@ class MaskedDstringSubstring(AbstractTemplate): Typing for st[idx], st[:idx], etc """ def generic(self, args, kws): - if isinstance(args[0], MaskedType) and args[0].value_type == dstring and isinstance(args[1], types.Integer): + if ( + isinstance(args[0], MaskedType) + and args[0].value_type == dstring + and isinstance(args[1], (types.Integer, types.SliceType)) + ): # __getitem__ is actually a two argument function: (val, idx) -> ret return nb_signature(MaskedType(dstring), MaskedType(dstring), args[1]) - for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) @@ -639,6 +642,11 @@ def resolve_valid(self, mod): types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int32) ) +_dstring_substr = cuda.declare_device( + "substr", + types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int32, types.int32) +) + _create_dstring_from_stringview = cuda.declare_device( "create_dstring_from_stringview", types.int32(types.CPointer(string_view), types.CPointer(dstring)) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 36b35b90de2..d4dba26893a 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -829,3 +829,26 @@ def func(row): return row[idx] run_masked_udf_test(func, data) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ['abc', 'a', '', '123AbC'] + } +]) +@pytest.mark.parametrize("slc", [ + slice(0, 1), + slice(0, -1) + slice(None, 2), + slice(2, None) + slice(0, 0) +]) +def test_string_udf_substring(data, slc): + # tests indexing into strings with an int + + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return row[slc] + + run_masked_udf_test(func, data) From b0fb8d250b794f9c3e28efdfcea2dec5dbb735f7 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 14 Apr 2022 08:22:25 -0700 Subject: [PATCH 032/212] substr RUNNING but different results from pandas... --- python/cudf/cudf/core/udf/lowering.py | 8 ++++---- python/cudf/cudf/core/udf/typing.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index d20ddddb2f6..95756e3d29b 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -467,11 +467,11 @@ def masked_dstring_at(context, builder, sig, args): _ = context.compile_internal( builder, call_dstring_at, - nb_signature(types.CPointer(dstring), types.CPointer(dstring), sig.args[1]), + nb_signature(types.int32, types.CPointer(dstring), types.CPointer(dstring), sig.args[1]), (dstr, retstr, args[1]) ) - to_return = cgutils.create_struct_proxy(sig.return_type) + to_return = cgutils.create_struct_proxy(sig.return_type)(context, builder) to_return.valid = input.valid to_return.value = builder.load(retstr) @@ -497,11 +497,11 @@ def masked_dstring_substring(context, builder, sig, args): _ = context.compile_internal( builder, call_dstring_substr, - nb_signature(types.CPointer(dstring), types.CPointer(dstring), types.int32, types.int32), + nb_signature(types.int32, types.CPointer(dstring), types.CPointer(dstring), types.int64, types.int64), (dstr, retstr, slc.start, slc.stop) ) - to_return = cgutils.create_struct_proxy(sig.return_type) + to_return = cgutils.create_struct_proxy(sig.return_type)(context, builder) to_return.valid = input.valid to_return.value = builder.load(retstr) diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index c6a1b8af254..12b2a00d909 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -644,7 +644,7 @@ def resolve_valid(self, mod): _dstring_substr = cuda.declare_device( "substr", - types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int32, types.int32) + types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int64, types.int64) ) _create_dstring_from_stringview = cuda.declare_device( From 3691c89c72c72588f55feeb4b2efc7922e38f80e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 14 Apr 2022 14:02:57 -0700 Subject: [PATCH 033/212] add strip, rstrip, and lstrip --- python/cudf/cudf/core/udf/lowering.py | 99 +++++++++++++++++++ python/cudf/cudf/core/udf/typing.py | 56 +++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 51 ++++++++++ 3 files changed, 206 insertions(+) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 95756e3d29b..3e3524d09d7 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -31,6 +31,9 @@ _dstring_lower, _dstring_at, _dstring_substr, + _dstring_strip, + _dstring_lstrip, + _dstring_rstrip, _create_dstring_from_stringview, string_view, dstring @@ -746,3 +749,99 @@ def masked_dstring_lower(context, builder, sig, args): ret.value = builder.load(tgt_ptr) ret.valid = input_masked_dstring.valid return ret._getvalue() + +def call_dstring_strip(st, tgt, chars): + return _dstring_strip(st, tgt, chars) + +@cuda_lower( + "MaskedType.strip", MaskedType(dstring), MaskedType(dstring) +) +def masked_dstring_strip(context, builder, sig, args): + source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) + chars = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) + + + source_ptr = builder.alloca(source.value.type) + target_ptr = builder.alloca(source.value.type) + chars_ptr = builder.alloca(source.value.type) + + builder.store(source.value, source_ptr) + builder.store(chars.value, chars_ptr) + + _ = context.compile_internal( + builder, + call_dstring_strip, + nb_signature( + types.int32, types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring) + ), + (source_ptr, target_ptr, chars_ptr), + ) + + result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) + result.valid = source.valid + result.value = builder.load(target_ptr) + return result._getvalue() + +def call_dstring_rstrip(st, tgt, chars): + return _dstring_rstrip(st, tgt, chars) + +@cuda_lower( + "MaskedType.rstrip", MaskedType(dstring), MaskedType(dstring) +) +def masked_dstring_rstrip(context, builder, sig, args): + source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) + chars = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) + + + source_ptr = builder.alloca(source.value.type) + target_ptr = builder.alloca(source.value.type) + chars_ptr = builder.alloca(source.value.type) + + builder.store(source.value, source_ptr) + builder.store(chars.value, chars_ptr) + + _ = context.compile_internal( + builder, + call_dstring_rstrip, + nb_signature( + types.int32, types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring) + ), + (source_ptr, target_ptr, chars_ptr), + ) + + result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) + result.valid = source.valid + result.value = builder.load(target_ptr) + return result._getvalue() + +def call_dstring_lstrip(st, tgt, chars): + return _dstring_lstrip(st, tgt, chars) + +@cuda_lower( + "MaskedType.lstrip", MaskedType(dstring), MaskedType(dstring) +) +def masked_dstring_lstrip(context, builder, sig, args): + source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) + chars = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) + + + source_ptr = builder.alloca(source.value.type) + target_ptr = builder.alloca(source.value.type) + chars_ptr = builder.alloca(source.value.type) + + builder.store(source.value, source_ptr) + builder.store(chars.value, chars_ptr) + + _ = context.compile_internal( + builder, + call_dstring_lstrip, + nb_signature( + types.int32, types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring) + ), + (source_ptr, target_ptr, chars_ptr), + ) + + result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) + result.valid = source.valid + result.value = builder.load(target_ptr) + return result._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 12b2a00d909..8e384d62198 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -565,6 +565,32 @@ def generic(self, args, kws): MaskedType(dstring), recvr=self.this ) +class MaskedStringStrip(AbstractTemplate): + key = "MaskedType.strip" + + def generic(self, args, kws): + return nb_signature( + MaskedType(dstring), MaskedType(dstring), recvr=self.this + ) + +class MaskedStringRStrip(AbstractTemplate): + key = "MaskedType.rstrip" + + def generic(self, args, kws): + return nb_signature( + MaskedType(dstring), recvr=self.this + ) + +class MaskedStringLStrip(AbstractTemplate): + key = "MaskedType.lstrip" + + def generic(self, args, kws): + return nb_signature( + MaskedType(dstring), recvr=self.this + ) + + + @cuda_decl_registry.register_attr class MaskedDStringAttrs(AttributeTemplate): key = MaskedType(dstring) @@ -599,6 +625,21 @@ def resolve_lower(self, mod): MaskedStringLower, MaskedType(dstring) ) + def resolve_strip(self, mod): + return types.BoundFunction( + MaskedStringStrip, MaskedType(dstring) + ) + + def resolve_rstrip(self, mod): + return types.BoundFunction( + MaskedStringStrip, MaskedType(dstring) + ) + + def resolve_lstrip(self, mod): + return types.BoundFunction( + MaskedStringStrip, MaskedType(dstring) + ) + def resolve_value(self, mod): return dstring @@ -647,6 +688,21 @@ def resolve_valid(self, mod): types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int64, types.int64) ) +_dstring_strip = cuda.declare_device( + "strip", + types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) +) + +_dstring_lstrip = cuda.declare_device( + "lstrip", + types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) +) + +_dstring_rstrip = cuda.declare_device( + "rstrip", + types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) +) + _create_dstring_from_stringview = cuda.declare_device( "create_dstring_from_stringview", types.int32(types.CPointer(string_view), types.CPointer(dstring)) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index d4dba26893a..eb9f6fa2641 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -852,3 +852,54 @@ def func(row): return row[slc] run_masked_udf_test(func, data) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ['abcd', 'AbCd', 'ABCD', '123AbC'] + } +]) +@pytest.mark.parametrize('chars', ['a', 'b', 'C', 'cd']) +def test_string_udf_strip(data, chars): + # tests str.strip() + + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.strip(chars) + + run_masked_udf_test(func, data) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ['abcdd', 'AbCd', 'ABCD', '123AbC'] + } +]) +@pytest.mark.parametrize('chars', ['a', 'b', 'C', 'cd']) +def test_string_udf_lstrip(data, chars): + # tests str.lstrip() + + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.lstrip(chars) + + run_masked_udf_test(func, data) + +@pytest.mark.parametrize('data', [ + { + 'str_col': ['abcd', 'AbCd', 'ABCD', '123AbC'] + } +]) +@pytest.mark.parametrize('chars', ['a', 'b', 'C', 'cd']) +def test_string_udf_rstrip(data, chars): + # tests str.rstrip() + + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.rstrip(chars) + + run_masked_udf_test(func, data) From 66e92e29acff8eb6755aa335cd0e99562de4765b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 18 Apr 2022 12:44:32 -0700 Subject: [PATCH 034/212] working through +, not working yet --- python/cudf/cudf/core/udf/lowering.py | 30 +++++++++++++++++++++++++++ python/cudf/cudf/core/udf/typing.py | 28 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 3e3524d09d7..803ca18a454 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -34,6 +34,7 @@ _dstring_strip, _dstring_lstrip, _dstring_rstrip, + _dstring_append, _create_dstring_from_stringview, string_view, dstring @@ -845,3 +846,32 @@ def masked_dstring_lstrip(context, builder, sig, args): result.valid = source.valid result.value = builder.load(target_ptr) return result._getvalue() + +def call_dstring_append(st, tgt): + return _dstring_append(st, tgt) + +@cuda_lower(operator.add, MaskedType(dstring), MaskedType(dstring)) +def masked_dstring_add(context, builder, sig, args): + source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) + target = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) + + source_ptr = builder.alloca(source.value.type) + target_ptr = builder.alloca(source.value.type) + + + builder.store(source.value, source_ptr) + builder.store(target.value, target_ptr) + + _ = context.compile_internal( + builder, + call_dstring_append, + nb_signature( + types.int32, types.CPointer(dstring), types.CPointer(dstring) + ), + (source_ptr, target_ptr), + ) + + result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) + result.valid = source.valid + result.value = builder.load(source_ptr) + return result._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 8e384d62198..ef793839e1b 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -504,6 +504,29 @@ def generic(self, args, kws): # __getitem__ is actually a two argument function: (val, idx) -> ret return nb_signature(MaskedType(dstring), MaskedType(dstring), args[1]) +@cuda_decl_registry.register_global(operator.add) +class MaskedDstringAppend(AbstractTemplate): + """ + Typing for operations like st + 'abc' + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], MaskedType) + and args[0].value_type == dstring + and ( + # dstring + 'abc' + isinstance(args[1], types.StringLiteral) + or ( + # dstring + dstring + isinstance(args[1], MaskedType) + and args[1].value_type == dstring + ) + ) + ): + return nb_signature(MaskedType(dstring), MaskedType(dstring), MaskedType(dstring)) + + for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) @@ -703,6 +726,11 @@ def resolve_valid(self, mod): types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) ) +_dstring_append = cuda.declare_device( + "append", + types.int32(types.CPointer(dstring), types.CPointer(dstring)) +) + _create_dstring_from_stringview = cuda.declare_device( "create_dstring_from_stringview", types.int32(types.CPointer(string_view), types.CPointer(dstring)) From 1cf26a40507265fa6585b00e9a9efeaebb52c9e6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 23 May 2022 11:35:49 -0700 Subject: [PATCH 035/212] plumb out to stringudfs --- python/cudf/cudf/core/udf/lowering.py | 505 +----------------- python/cudf/cudf/core/udf/typing.py | 344 +----------- python/cudf/cudf/core/udf/utils.py | 7 +- python/cudf/cudf/tests/test_udf_masked_ops.py | 4 +- 4 files changed, 23 insertions(+), 837 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 803ca18a454..a44e08e7a67 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -22,24 +22,11 @@ from cudf.core.udf.typing import ( MaskedType, NAType, - _dstring_len, - _dstring_endswith, - _dstring_find, - _dstring_rfind, - _dstring_startswith, - _dstring_upper, - _dstring_lower, - _dstring_at, - _dstring_substr, - _dstring_strip, - _dstring_lstrip, - _dstring_rstrip, - _dstring_append, - _create_dstring_from_stringview, - string_view, - dstring ) +from stringudfs._typing import string_view +from stringudfs.lowering import string_view_len_impl + import operator @@ -302,7 +289,7 @@ def pack_return_masked_impl(context, builder, sig, args): @cuda_lower(api.pack_return, types.Number) @cuda_lower(api.pack_return, types.NPDatetime) @cuda_lower(api.pack_return, types.NPTimedelta) -@cuda_lower(api.pack_return, dstring) +@cuda_lower(api.pack_return, string_view) def pack_return_scalar_impl(context, builder, sig, args): outdata = cgutils.create_struct_proxy(sig.return_type)(context, builder) outdata.value = args[0] @@ -373,7 +360,7 @@ def cast_masked_to_masked(context, builder, fromty, toty, val): @lower_builtin(api.Masked, types.Number, types.boolean) @lower_builtin(api.Masked, types.NPDatetime, types.boolean) @lower_builtin(api.Masked, types.NPTimedelta, types.boolean) -@lower_builtin(api.Masked, dstring, types.boolean) +@lower_builtin(api.Masked, string_view, types.boolean) def masked_constructor(context, builder, sig, args): ty = sig.return_type value, valid = args @@ -382,32 +369,6 @@ def masked_constructor(context, builder, sig, args): masked.valid = valid return masked._getvalue() -# make it so that string input data is immediately converted -# to a MaskedType(dstring). This guarantees string functions -# only need to ever expect cudf::dstring inputs and guarantees -# that UDFs returning string data will always return dstring types -def call_create_dstring_from_stringview(strview, dstr): - return _create_dstring_from_stringview(strview, dstr) - -@lower_builtin(api.Masked, string_view, types.boolean) -def masked_constructor_stringview(context, builder, sig, args): - #breakpoint() - value, valid = args - ret = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) - - dstr = builder.alloca(ret.value.type) - strview = builder.alloca(value.type) - - builder.store(value, strview) - - _ = context.compile_internal( - builder, - call_create_dstring_from_stringview, - nb_signature(types.int32, types.CPointer(string_view), types.CPointer(dstring)), - (strview, dstr) - ) - ret.valid = valid - return ret._getvalue() # Allows us to make an instance of MaskedType a global variable @@ -419,459 +380,15 @@ def lower_constant_masked(context, builder, ty, val): masked.valid = context.get_constant(types.boolean, val.valid) return masked._getvalue() - -# String function implementations -def call_len_dstring(st): - return _dstring_len(st) - - -@cuda_lower(len, MaskedType(dstring)) -def string_view_len_impl(context, builder, sig, args): +@cuda_lower(len, MaskedType(string_view)) +def masked_string_view_len_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_dstr_ty = sig.args[0] - masked_dstr = cgutils.create_struct_proxy(masked_dstr_ty)( + masked_sv_ty = sig.args[0] + masked_sv = cgutils.create_struct_proxy(masked_sv_ty)( context, builder, value=args[0] ) - - # the first element is the string_view struct - # get a pointer that we will copy the data to - strty = masked_dstr.value.type - arg = builder.alloca(strty) - - # store - builder.store(masked_dstr.value, arg) - - result = context.compile_internal( - builder, - call_len_dstring, - nb_signature(sig.return_type.value_type, types.CPointer(dstring)), - (arg,), - ) + result = string_view_len_impl(context, builder, types.int32(string_view), (masked_sv.value,)) ret.value = result - ret.valid = masked_dstr.valid + ret.valid = masked_sv.valid return ret._getvalue() - -def call_dstring_at(st, tgt, idx): - return _dstring_at(st, tgt, idx) - -@cuda_lower(operator.getitem, MaskedType(dstring), types.Integer) -def masked_dstring_at(context, builder, sig, args): - input = cgutils.create_struct_proxy(sig.args[0])(context, builder, value=args[0]) - - # create two pointers to empty dstrings - strty = input.value.type - dstr = builder.alloca(strty) - retstr = builder.alloca(strty) - - # store the real input value as the first dstring - builder.store(input.value, dstr) - - # call dstring::at - _ = context.compile_internal( - builder, - call_dstring_at, - nb_signature(types.int32, types.CPointer(dstring), types.CPointer(dstring), sig.args[1]), - (dstr, retstr, args[1]) - ) - - to_return = cgutils.create_struct_proxy(sig.return_type)(context, builder) - to_return.valid = input.valid - to_return.value = builder.load(retstr) - - return to_return._getvalue() - -def call_dstring_substr(st, tgt, start, stop): - return _dstring_substr(st, tgt, start, stop) - -@cuda_lower(operator.getitem, MaskedType(dstring), types.SliceType) -def masked_dstring_substring(context, builder, sig, args): - input = cgutils.create_struct_proxy(sig.args[0])(context, builder, value=args[0]) - slc = cgutils.create_struct_proxy(sig.args[1])(context, builder, value=args[1]) - - # create two pointers to empty dstrings - strty = input.value.type - dstr = builder.alloca(strty) - retstr = builder.alloca(strty) - - # store the real input value as the first dstring - builder.store(input.value, dstr) - - # call dstring::substring - _ = context.compile_internal( - builder, - call_dstring_substr, - nb_signature(types.int32, types.CPointer(dstring), types.CPointer(dstring), types.int64, types.int64), - (dstr, retstr, slc.start, slc.stop) - ) - - to_return = cgutils.create_struct_proxy(sig.return_type)(context, builder) - to_return.valid = input.valid - to_return.value = builder.load(retstr) - - return to_return._getvalue() - - -@cuda_lowering_registry.lower_cast(types.StringLiteral, MaskedType) -def cast_stringliteral_to_masked_dstring( - context, builder, fromty, toty, val -): - """ - cast a literal to a Masked(dstring) - """ - # create an empty string_view - dstr = cgutils.create_struct_proxy(dstring)(context, builder) - - # set the empty strview data pointer to point to the literal value - s = context.insert_const_string(builder.module, fromty.literal_value) - dstr.m_data = context.insert_addrspace_conv( - builder, s, nvvm.ADDRSPACE_CONSTANT - ) - dstr.m_size = context.get_constant( - types.int32, len(fromty.literal_value) - ) - dstr.m_bytes = context.get_constant( - types.int32, len(fromty.literal_value.encode("UTF-8")) - ) - - # create an empty MaskedType - to_return = cgutils.create_struct_proxy(toty)(context, builder) - - # make it valid - to_return.valid = context.get_constant(types.boolean, 1) - - # set the value to be the string view - to_return.value = dstr._getvalue() - - return to_return._getvalue() - - -def call_dstring_startswith(st, tgt): - return _dstring_startswith(st, tgt) - - -@cuda_lower( - "MaskedType.startswith", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_startswith(context, builder, sig, args): - retty = sig.return_type - maskedty = sig.args[0] - - st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)( - context, builder, value=args[1] - ) - - strty = st.value.type - - st_ptr = builder.alloca(strty) - tgt_ptr = builder.alloca(strty) - - builder.store(st.value, st_ptr) - builder.store(tgt.value, tgt_ptr) - - result = context.compile_internal( - builder, - call_dstring_startswith, - nb_signature( - retty, types.CPointer(dstring), types.CPointer(dstring) - ), - (st_ptr, tgt_ptr), - ) - return result - - -def call_dstring_endswith(st, tgt): - return _dstring_endswith(st, tgt) - - -@cuda_lower( - "MaskedType.endswith", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_endswith(context, builder, sig, args): - retty = sig.return_type - maskedty = sig.args[0] - - st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)( - context, builder, value=args[1] - ) - - strty = st.value.type - - st_ptr = builder.alloca(strty) - tgt_ptr = builder.alloca(strty) - - builder.store(st.value, st_ptr) - builder.store(tgt.value, tgt_ptr) - - result = context.compile_internal( - builder, - call_dstring_endswith, - nb_signature( - retty, types.CPointer(dstring), types.CPointer(dstring) - ), - (st_ptr, tgt_ptr), - ) - return result - - -def call_dstring_find(st, tgt): - return _dstring_find(st, tgt) - - -@cuda_lower( - "MaskedType.find", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_find(context, builder, sig, args): - retty = sig.return_type - maskedty = sig.args[0] - - st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)( - context, builder, value=args[1] - ) - - strty = st.value.type - - st_ptr = builder.alloca(strty) - tgt_ptr = builder.alloca(strty) - - builder.store(st.value, st_ptr) - builder.store(tgt.value, tgt_ptr) - - result = context.compile_internal( - builder, - call_dstring_find, - nb_signature( - retty, types.CPointer(dstring), types.CPointer(dstring) - ), - (st_ptr, tgt_ptr), - ) - return result - - -def call_dstring_rfind(st, tgt): - return _dstring_rfind(st, tgt) - - -@cuda_lower( - "MaskedType.rfind", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_rfind(context, builder, sig, args): - retty = sig.return_type - maskedty = sig.args[0] - - st = cgutils.create_struct_proxy(maskedty)(context, builder, value=args[0]) - tgt = cgutils.create_struct_proxy(maskedty)( - context, builder, value=args[1] - ) - - strty = st.value.type - - st_ptr = builder.alloca(strty) - tgt_ptr = builder.alloca(strty) - - builder.store(st.value, st_ptr) - builder.store(tgt.value, tgt_ptr) - - result = context.compile_internal( - builder, - call_dstring_rfind, - nb_signature( - retty, types.CPointer(dstring), types.CPointer(dstring) - ), - (st_ptr, tgt_ptr), - ) - return result - -def call_dstring_upper(st, tgt): - return _dstring_upper(st, tgt) - -@cuda_lower( - "MaskedType.upper", MaskedType(dstring) -) -def masked_dstring_upper(context, builder, sig, args): - # create an empty MaskedType(dstring) - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - - # input struct - input_masked_dstring = cgutils.create_struct_proxy(sig.args[0])( - context, builder, value=args[0] - ) - - st_ptr = builder.alloca(input_masked_dstring.value.type) - tgt_ptr = builder.alloca(input_masked_dstring.value.type) - - builder.store(input_masked_dstring.value, st_ptr) - - _ = context.compile_internal( - builder, - call_dstring_upper, - nb_signature( - types.int32, types.CPointer(dstring), types.CPointer(dstring) - ), - (st_ptr, tgt_ptr), - ) - - ret.value = builder.load(tgt_ptr) - ret.valid = input_masked_dstring.valid - return ret._getvalue() - -def call_dstring_lower(st, tgt): - return _dstring_lower(st, tgt) - -@cuda_lower( - "MaskedType.lower", MaskedType(dstring) -) -def masked_dstring_lower(context, builder, sig, args): - # create an empty MaskedType(dstring) - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - - # input struct - input_masked_dstring = cgutils.create_struct_proxy(sig.args[0])( - context, builder, value=args[0] - ) - - st_ptr = builder.alloca(input_masked_dstring.value.type) - tgt_ptr = builder.alloca(input_masked_dstring.value.type) - - builder.store(input_masked_dstring.value, st_ptr) - - _ = context.compile_internal( - builder, - call_dstring_lower, - nb_signature( - types.int32, types.CPointer(dstring), types.CPointer(dstring) - ), - (st_ptr, tgt_ptr), - ) - - ret.value = builder.load(tgt_ptr) - ret.valid = input_masked_dstring.valid - return ret._getvalue() - -def call_dstring_strip(st, tgt, chars): - return _dstring_strip(st, tgt, chars) - -@cuda_lower( - "MaskedType.strip", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_strip(context, builder, sig, args): - source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) - chars = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) - - - source_ptr = builder.alloca(source.value.type) - target_ptr = builder.alloca(source.value.type) - chars_ptr = builder.alloca(source.value.type) - - builder.store(source.value, source_ptr) - builder.store(chars.value, chars_ptr) - - _ = context.compile_internal( - builder, - call_dstring_strip, - nb_signature( - types.int32, types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring) - ), - (source_ptr, target_ptr, chars_ptr), - ) - - result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) - result.valid = source.valid - result.value = builder.load(target_ptr) - return result._getvalue() - -def call_dstring_rstrip(st, tgt, chars): - return _dstring_rstrip(st, tgt, chars) - -@cuda_lower( - "MaskedType.rstrip", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_rstrip(context, builder, sig, args): - source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) - chars = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) - - - source_ptr = builder.alloca(source.value.type) - target_ptr = builder.alloca(source.value.type) - chars_ptr = builder.alloca(source.value.type) - - builder.store(source.value, source_ptr) - builder.store(chars.value, chars_ptr) - - _ = context.compile_internal( - builder, - call_dstring_rstrip, - nb_signature( - types.int32, types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring) - ), - (source_ptr, target_ptr, chars_ptr), - ) - - result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) - result.valid = source.valid - result.value = builder.load(target_ptr) - return result._getvalue() - -def call_dstring_lstrip(st, tgt, chars): - return _dstring_lstrip(st, tgt, chars) - -@cuda_lower( - "MaskedType.lstrip", MaskedType(dstring), MaskedType(dstring) -) -def masked_dstring_lstrip(context, builder, sig, args): - source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) - chars = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) - - - source_ptr = builder.alloca(source.value.type) - target_ptr = builder.alloca(source.value.type) - chars_ptr = builder.alloca(source.value.type) - - builder.store(source.value, source_ptr) - builder.store(chars.value, chars_ptr) - - _ = context.compile_internal( - builder, - call_dstring_lstrip, - nb_signature( - types.int32, types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring) - ), - (source_ptr, target_ptr, chars_ptr), - ) - - result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) - result.valid = source.valid - result.value = builder.load(target_ptr) - return result._getvalue() - -def call_dstring_append(st, tgt): - return _dstring_append(st, tgt) - -@cuda_lower(operator.add, MaskedType(dstring), MaskedType(dstring)) -def masked_dstring_add(context, builder, sig, args): - source = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[0]) - target = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder, value=args[1]) - - source_ptr = builder.alloca(source.value.type) - target_ptr = builder.alloca(source.value.type) - - - builder.store(source.value, source_ptr) - builder.store(target.value, target_ptr) - - _ = context.compile_internal( - builder, - call_dstring_append, - nb_signature( - types.int32, types.CPointer(dstring), types.CPointer(dstring) - ), - (source_ptr, target_ptr), - ) - - result = cgutils.create_struct_proxy(MaskedType(dstring))(context, builder) - result.valid = source.valid - result.value = builder.load(source_ptr) - return result._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 11d700b4154..99444b020c1 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -37,107 +37,10 @@ import operator -# String object definitions -class DString(types.Type): - def __init__(self): - super().__init__(name="dstring") - - - -class StringView(types.Type): - def __init__(self): - super().__init__(name="string_view") - - -string_view = StringView() -dstring = DString() - - -@typeof_impl.register(StringView) -def typeof_stringview(val, c): - return string_view +from stringudfs._typing import DString, StringView, dstring, string_view, dstring_model, stringview_model, str_view_arg_handler -@typeof_impl.register(DString) -def typeof_dstring(val, c): - return dstring - -@register_model(StringView) -class stringview_model(models.StructModel): - # from string_view.hpp: - # private: - # const char* _data{}; ///< Pointer to device memory contain char array for this string - # size_type _bytes{}; ///< Number of bytes in _data for this string - # mutable size_type _length{}; ///< Number of characters in this string (computed) - - _members = ( - ("data", types.CPointer(types.char)), - ("bytes", types.int32), - ("length", types.int32), - ) - - bytes = 0 - for member_ty in (t[1] for t in _members): - if isinstance(member_ty, types.CPointer): - # TODO: is this always right? - bytes += 8 - else: - bytes += member_ty.bitwidth / 8 - - size_bytes = bytes - - def __init__(self, dmm, fe_type): - super().__init__(dmm, fe_type, self._members) - -@register_model(DString) -class dstring_model(models.StructModel): - # from dstring.hpp: - # private: - # char* m_data{}; - # cudf::size_type m_bytes{}; - # cudf::size_type m_size{}; - - _members = ( - ("m_data", types.CPointer(types.char)), - ("m_bytes", types.int32), - ("m_size", types.int32) - ) - bytes = 0 - for member_ty in (t[1] for t in _members): - if isinstance(member_ty, types.CPointer): - # TODO: is this always right? - bytes += 8 - else: - bytes += member_ty.bitwidth / 8 - - size_bytes = bytes - - def __init__(self, dmm, fe_type): - super().__init__(dmm, fe_type, self._members) -class StrViewArgHandler: - """ - As part of Numbas preprocessing step incoming function arguments are - modified based on the associated type for that argument that was used - to JIT the kernel. However it only knows how to handle built in array - types natively. With string UDFs, the jitted type is string_view*, - which numba does not know how to handle. - - This small piece of code implements the necessary handling. Really all - it does is says is funnel the handling of string_view* to the handling - of raw pointer arguments, which numba knows what to do with. - - See numba.cuda.compiler._prepare_args for details. - """ - def prepare_args(self, ty, val, **kwargs): - if isinstance(ty, types.CPointer) and isinstance(ty.dtype, DString): - return types.uint64, val.ptr - else: - return ty, val - - -str_view_arg_handler = StrViewArgHandler() - # Masked scalars of all types class MaskedType(types.Type): """ @@ -150,7 +53,9 @@ def __init__(self, value): # with a value type # TODO - replace object with stringview immediately - if isinstance(value, (types.PyObject, StringView, DString)): + if isinstance(value, (types.PyObject, StringView)): + self.value_type = string_view + elif isinstance(value, DString): self.value_type = dstring elif isinstance(value, SUPPORTED_NUMBA_TYPES): self.value_type = value @@ -466,14 +371,14 @@ def generic(self, args, kws): # String functions @cuda_decl_registry.register_global(len) -class MaskedDStringLength(AbstractTemplate): +class MaskedStringViewLength(AbstractTemplate): """ provide the length of a cudf::string_view like struct """ def generic(self, args, kws): if isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, DString + args[0].value_type, StringView ): return nb_signature(MaskedType(types.int32), args[0]) @@ -490,43 +395,6 @@ def generic(self, args, kws): return nb_signature(types.int32, args[0]) -@cuda_decl_registry.register_global(operator.getitem) -class MaskedDstringSubstring(AbstractTemplate): - """ - Typing for st[idx], st[:idx], etc - """ - def generic(self, args, kws): - if ( - isinstance(args[0], MaskedType) - and args[0].value_type == dstring - and isinstance(args[1], (types.Integer, types.SliceType)) - ): - # __getitem__ is actually a two argument function: (val, idx) -> ret - return nb_signature(MaskedType(dstring), MaskedType(dstring), args[1]) - -@cuda_decl_registry.register_global(operator.add) -class MaskedDstringAppend(AbstractTemplate): - """ - Typing for operations like st + 'abc' - """ - - def generic(self, args, kws): - if ( - isinstance(args[0], MaskedType) - and args[0].value_type == dstring - and ( - # dstring + 'abc' - isinstance(args[1], types.StringLiteral) - or ( - # dstring + dstring - isinstance(args[1], MaskedType) - and args[1].value_type == dstring - ) - ) - ): - return nb_signature(MaskedType(dstring), MaskedType(dstring), MaskedType(dstring)) - - for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) @@ -535,203 +403,3 @@ def generic(self, args, kws): for unary_op in unary_ops: cuda_decl_registry.register_global(unary_op)(MaskedScalarUnaryOp) - - -class MaskedStringStartsWith(AbstractTemplate): - key = "MaskedType.startswith" - - def generic(self, args, kws): - return nb_signature( - types.boolean, MaskedType(dstring), recvr=self.this - ) - - -class MaskedStringEndsWith(AbstractTemplate): - key = "MaskedType.endswith" - - def generic(self, args, kws): - return nb_signature( - types.boolean, MaskedType(dstring), recvr=self.this - ) - - -class MaskedStringFind(AbstractTemplate): - key = "MaskedType.find" - - def generic(self, args, kws): - return nb_signature( - types.int32, MaskedType(dstring), recvr=self.this - ) - - -class MaskedStringRFind(AbstractTemplate): - key = "MaskedType.rfind" - - def generic(self, args, kws): - return nb_signature( - types.int32, MaskedType(dstring), recvr=self.this - ) - -class MaskedStringUpper(AbstractTemplate): - key = "MaskedType.upper" - - def generic(self, args, kws): - return nb_signature( - MaskedType(dstring), recvr=self.this - ) - -class MaskedStringLower(AbstractTemplate): - key = "MaskedType.lower" - - def generic(self, args, kws): - return nb_signature( - MaskedType(dstring), recvr=self.this - ) - -class MaskedStringStrip(AbstractTemplate): - key = "MaskedType.strip" - - def generic(self, args, kws): - return nb_signature( - MaskedType(dstring), MaskedType(dstring), recvr=self.this - ) - -class MaskedStringRStrip(AbstractTemplate): - key = "MaskedType.rstrip" - - def generic(self, args, kws): - return nb_signature( - MaskedType(dstring), recvr=self.this - ) - -class MaskedStringLStrip(AbstractTemplate): - key = "MaskedType.lstrip" - - def generic(self, args, kws): - return nb_signature( - MaskedType(dstring), recvr=self.this - ) - - - -@cuda_decl_registry.register_attr -class MaskedDStringAttrs(AttributeTemplate): - key = MaskedType(dstring) - - def resolve_startswith(self, mod): - return types.BoundFunction( - MaskedStringStartsWith, MaskedType(dstring) - ) - - def resolve_endswith(self, mod): - return types.BoundFunction( - MaskedStringEndsWith, MaskedType(dstring) - ) - - def resolve_find(self, mod): - return types.BoundFunction( - MaskedStringFind, MaskedType(dstring) - ) - - def resolve_rfind(self, mod): - return types.BoundFunction( - MaskedStringRFind, MaskedType(dstring) - ) - - def resolve_upper(self, mod): - return types.BoundFunction( - MaskedStringUpper, MaskedType(dstring) - ) - - def resolve_lower(self, mod): - return types.BoundFunction( - MaskedStringLower, MaskedType(dstring) - ) - - def resolve_strip(self, mod): - return types.BoundFunction( - MaskedStringStrip, MaskedType(dstring) - ) - - def resolve_rstrip(self, mod): - return types.BoundFunction( - MaskedStringStrip, MaskedType(dstring) - ) - - def resolve_lstrip(self, mod): - return types.BoundFunction( - MaskedStringStrip, MaskedType(dstring) - ) - - def resolve_value(self, mod): - return dstring - - def resolve_valid(self, mod): - return types.boolean - - - -_dstring_len = cuda.declare_device( - "len", types.int32(types.CPointer(dstring)) -) -_dstring_startswith = cuda.declare_device( - "startswith", - types.boolean(types.CPointer(dstring), types.CPointer(dstring)), -) -_dstring_endswith = cuda.declare_device( - "endswith", - types.boolean(types.CPointer(dstring), types.CPointer(dstring)), -) -_dstring_find = cuda.declare_device( - "find", - types.int32(types.CPointer(dstring), types.CPointer(dstring)), -) -_dstring_rfind = cuda.declare_device( - "rfind", - types.int32(types.CPointer(dstring), types.CPointer(dstring)), -) - -_dstring_upper = cuda.declare_device( - "upper", - types.int32(types.CPointer(dstring), types.CPointer(dstring)), -) - -_dstring_lower = cuda.declare_device( - "lower", - types.int32(types.CPointer(dstring), types.CPointer(dstring)) -) - -_dstring_at = cuda.declare_device( - "at", - types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int32) -) - -_dstring_substr = cuda.declare_device( - "substr", - types.int32(types.CPointer(dstring), types.CPointer(dstring), types.int64, types.int64) -) - -_dstring_strip = cuda.declare_device( - "strip", - types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) -) - -_dstring_lstrip = cuda.declare_device( - "lstrip", - types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) -) - -_dstring_rstrip = cuda.declare_device( - "rstrip", - types.int32(types.CPointer(dstring), types.CPointer(dstring), types.CPointer(dstring)) -) - -_dstring_append = cuda.declare_device( - "append", - types.int32(types.CPointer(dstring), types.CPointer(dstring)) -) - -_create_dstring_from_stringview = cuda.declare_device( - "create_dstring_from_stringview", - types.int32(types.CPointer(string_view), types.CPointer(dstring)) -) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 5bc53bdbd61..fca73fc6b49 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -22,7 +22,8 @@ STRING_TYPES, ) from cudf.api.types import is_string_dtype -from cudf_jit_udf import to_string_view_array, from_dstring_array +from stringudfs._lib.cudf_jit_udf import to_string_view_array, from_dstring_array +from stringudfs import ptxpath from cudf.utils.utils import _cudf_nvtx_annotate @@ -125,7 +126,7 @@ def _masked_array_type_from_col(col): """ if is_string_dtype(col.dtype): # strings_udf library provides a pointer directly to the data - col_type = CPointer(dstring) + col_type = CPointer(string_view) else: nb_scalar_ty = numpy_support.from_dtype(col.dtype) col_type = nb_scalar_ty[::1] @@ -231,7 +232,7 @@ def _get_kernel(kernel_string, globals_, sig, func): globals_["f_"] = f_ exec(kernel_string, globals_) _kernel = globals_["_kernel"] - kernel = cuda.jit(sig, link=['/home/nfs/brmiller/ipynb/strings_udf/len.ptx'], extensions=[str_view_arg_handler])(_kernel) + kernel = cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler])(_kernel) return kernel diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 0c4a4e8f9b3..2d8be5c2ee3 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -840,9 +840,9 @@ def func(row): ]) @pytest.mark.parametrize("slc", [ slice(0, 1), - slice(0, -1) + slice(0, -1), slice(None, 2), - slice(2, None) + slice(2, None), slice(0, 0) ]) def test_string_udf_substring(data, slc): From e61815d3ab41a6ca0d733f90d05e39bae2262fd4 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 26 May 2022 12:17:44 -0700 Subject: [PATCH 036/212] plumbing startswith and endswith back in --- python/cudf/cudf/core/udf/lowering.py | 52 +++++++++++++++++++++++++-- python/cudf/cudf/core/udf/typing.py | 37 ++++++++++++++++++- python/cudf/cudf/core/udf/utils.py | 4 +-- 3 files changed, 88 insertions(+), 5 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index a44e08e7a67..0f71f491301 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -24,8 +24,8 @@ NAType, ) -from stringudfs._typing import string_view -from stringudfs.lowering import string_view_len_impl +from strings_udf._typing import string_view +from strings_udf.lowering import string_view_len_impl, string_view_startswith_impl, string_view_endswith_impl import operator @@ -392,3 +392,51 @@ def masked_string_view_len_impl(context, builder, sig, args): ret.valid = masked_sv.valid return ret._getvalue() + + +@cuda_lower( + "MaskedType.startswith", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_startswith_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_startswith_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + + +@cuda_lower( + "MaskedType.endswith", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_endswith_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_endswith_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 99444b020c1..95f66867bdf 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -37,7 +37,7 @@ import operator -from stringudfs._typing import DString, StringView, dstring, string_view, dstring_model, stringview_model, str_view_arg_handler +from strings_udf._typing import DString, StringView, dstring, string_view, dstring_model, stringview_model, str_view_arg_handler @@ -394,6 +394,41 @@ def generic(self, args, kws): if isinstance(args[0], types.StringLiteral) and len(args) == 1: return nb_signature(types.int32, args[0]) +class MaskedStringViewStartsWith(AbstractTemplate): + key = "MaskedType.startswith" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), MaskedType(string_view), recvr=self.this + ) + +class MaskedStringViewEndsWith(AbstractTemplate): + key = "MaskedType.endswith" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), MaskedType(string_view), recvr=self.this + ) + +@cuda_decl_registry.register_attr +class MaskedStringViewAttrs(AttributeTemplate): + key = MaskedType(string_view) + + def resolve_startswith(self, mod): + return types.BoundFunction( + MaskedStringViewStartsWith, MaskedType(string_view) + ) + + def resolve_endswith(self, mod): + return types.BoundFunction( + MaskedStringViewEndsWith, MaskedType(string_view) + ) + + def resolve_value(self, mod): + return string_view + + def resolve_valid(self, mod): + return types.boolean for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index fca73fc6b49..14abca4a690 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -22,8 +22,8 @@ STRING_TYPES, ) from cudf.api.types import is_string_dtype -from stringudfs._lib.cudf_jit_udf import to_string_view_array, from_dstring_array -from stringudfs import ptxpath +from strings_udf._lib.cudf_jit_udf import to_string_view_array, from_dstring_array +from strings_udf import ptxpath from cudf.utils.utils import _cudf_nvtx_annotate From 19f491a15524eb485ba4bc8a3a74f5f55992817c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 15 Jun 2022 12:49:16 -0700 Subject: [PATCH 037/212] updates from strings_udf/main --- python/cudf/cudf/core/udf/row_function.py | 2 +- python/cudf/cudf/core/udf/typing.py | 6 ++--- python/cudf/cudf/core/udf/utils.py | 33 +++++++++++++---------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 634d3811c0a..e035af33889 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -24,7 +24,7 @@ _supported_dtypes_from_frame, ) -from cudf.core.udf.typing import stringview_model, dstring_model +from strings_udf._typing import stringview_model, dstring_model def _get_frame_row_type(dtype): diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 95f66867bdf..2ad8c2bfc1e 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -37,7 +37,7 @@ import operator -from strings_udf._typing import DString, StringView, dstring, string_view, dstring_model, stringview_model, str_view_arg_handler +from strings_udf._typing import StringView, string_view @@ -55,8 +55,6 @@ def __init__(self, value): # TODO - replace object with stringview immediately if isinstance(value, (types.PyObject, StringView)): self.value_type = string_view - elif isinstance(value, DString): - self.value_type = dstring elif isinstance(value, SUPPORTED_NUMBA_TYPES): self.value_type = value else: @@ -157,7 +155,7 @@ class MaskedConstructor(ConcreteTemplate): | datetime_cases | timedelta_cases | {types.boolean} - | {types.pyobject, string_view, dstring} + | {types.pyobject, string_view} ) ] diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 14abca4a690..6cdee2a48cd 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -11,7 +11,7 @@ import cupy as cp from cudf.core.dtypes import CategoricalDtype -from cudf.core.udf.typing import MaskedType, dstring_model, string_view, str_view_arg_handler, dstring +from cudf.core.udf.typing import MaskedType from cudf.core.column.column import as_column from cudf.utils import cudautils from cudf.utils.dtypes import ( @@ -22,7 +22,8 @@ STRING_TYPES, ) from cudf.api.types import is_string_dtype -from strings_udf._lib.cudf_jit_udf import to_string_view_array, from_dstring_array +from strings_udf._lib.cudf_jit_udf import to_string_view_array +from strings_udf._typing import str_view_arg_handler, string_view from strings_udf import ptxpath from cudf.utils.utils import _cudf_nvtx_annotate @@ -220,7 +221,9 @@ def _compile_or_get(frame, func, args, kernel_getter=None): kernel, scalar_return_type = kernel_getter(frame, func, args) - np_return_type = scalar_return_type if scalar_return_type is dstring else numpy_support.as_dtype(scalar_return_type) + #np_return_type = scalar_return_type if scalar_return_type is dstring else numpy_support.as_dtype(scalar_return_type) + np_return_type = numpy_support.as_dtype(scalar_return_type) + precompiled[cache_key] = (kernel, np_return_type) return kernel, np_return_type @@ -245,16 +248,18 @@ def _launch_arg_from_col(col): return data, mask def _return_col_from_dtype(dt, size): - if dt is dstring: - # - return rmm.DeviceBuffer( - size=int(size * dstring_model.size_bytes) - ) - else: - return cp.empty(size, dtype=dt) + #if dt is dstring: + # # + # return rmm.DeviceBuffer( + # size=int(size * dstring_model.size_bytes) + # ) + #else: + # return cp.empty(size, dtype=dt) + return cp.empty(size, dtype=dt) def _post_process_output_col(col, retty): - if retty == dstring: - return from_dstring_array(col) - else: - return as_column(col) + #if retty == dstring: + # return from_dstring_array(col) + #else: + # return as_column(col) + return as_column(col) From bca8fe8b41d5f124194b2c8be53ca86af107adad Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 12 Jul 2022 14:51:22 -0700 Subject: [PATCH 038/212] plumb back in several more functions --- python/cudf/cudf/core/udf/lowering.py | 76 ++++++++++++++++++- python/cudf/cudf/core/udf/row_function.py | 7 +- python/cudf/cudf/core/udf/typing.py | 39 ++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 28 +++++++ 4 files changed, 146 insertions(+), 4 deletions(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index 0f71f491301..a21ff094d8e 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -25,7 +25,14 @@ ) from strings_udf._typing import string_view -from strings_udf.lowering import string_view_len_impl, string_view_startswith_impl, string_view_endswith_impl +from strings_udf.lowering import ( + string_view_len_impl, + string_view_startswith_impl, + string_view_endswith_impl, + string_view_find_impl, + string_view_rfind_impl, + string_view_contains_impl, +) import operator @@ -440,3 +447,70 @@ def masked_string_view_endswith_impl(context, builder, sig, args): ret.value = result ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) return ret._getvalue() + +@cuda_lower( + "MaskedType.find", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_find_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_find_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + +@cuda_lower( + "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_rfind_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_rfind_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + +@cuda_lower(operator.contains, MaskedType(string_view), MaskedType(string_view)) +def masked_string_view_contains_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_contains_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index e035af33889..7eb9d3741fe 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -24,7 +24,8 @@ _supported_dtypes_from_frame, ) -from strings_udf._typing import stringview_model, dstring_model +from strings_udf._typing import DString +dstring = DString() def _get_frame_row_type(dtype): @@ -50,7 +51,7 @@ def _get_frame_row_type(dtype): sizes = [] for field in dtype.fields.values(): if field[0] == np.dtype('object'): - sizes.append(dstring_model.size_bytes) + sizes.append(dstring.size_bytes) else: sizes.append(field[0].itemsize) @@ -72,7 +73,7 @@ def _get_frame_row_type(dtype): # increment offset by itemsize plus one byte for validity if elemdtype == np.dtype('object'): - itemsize = dstring_model.size_bytes + itemsize = dstring.size_bytes else: itemsize = elemdtype.itemsize offset += itemsize + 1 diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 2ad8c2bfc1e..1ca1766911b 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -380,6 +380,19 @@ def generic(self, args, kws): ): return nb_signature(MaskedType(types.int32), args[0]) +@cuda_decl_registry.register_global(operator.contains) +class MaskedStringViewContains(AbstractTemplate): + """ + return a boolean indicating if a substring is found in a string + """ + + def generic(self, args, kws): + if (isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( + args[1].value_type, StringView + ) or isinstance(args[1], types.StringLiteral)): + return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): @@ -408,6 +421,22 @@ def generic(self, args, kws): MaskedType(types.boolean), MaskedType(string_view), recvr=self.this ) +class MaskedStringViewFind(AbstractTemplate): + key = "MaskedType.find" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.int32), MaskedType(string_view), recvr=self.this + ) + +class MaskedStringViewRFind(AbstractTemplate): + key = "MaskedType.rfind" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.int32), MaskedType(string_view), recvr=self.this + ) + @cuda_decl_registry.register_attr class MaskedStringViewAttrs(AttributeTemplate): key = MaskedType(string_view) @@ -422,6 +451,16 @@ def resolve_endswith(self, mod): MaskedStringViewEndsWith, MaskedType(string_view) ) + def resolve_find(self, mod): + return types.BoundFunction( + MaskedStringViewFind, MaskedType(string_view) + ) + + def resolve_rfind(self, mod): + return types.BoundFunction( + MaskedStringViewRFind, MaskedType(string_view) + ) + def resolve_value(self, mod): return string_view diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 2d8be5c2ee3..64e63229ffd 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -786,6 +786,34 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "gpu", + "2022", + "cuDF", + "again_gpu", + ] + } + ], +) +@pytest.mark.parametrize("substr", ["a", "cu", "", "12"]) +def test_string_udf_contains(data, substr): + # tests the boolean operation `substr in str` + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return substr in st + + run_masked_udf_test(func, data, check_dtype=False) + + @pytest.mark.parametrize('data', [ { 'str_col': ["abc", "ABC", "aBc", "123", ""] From f16554738fc32031075bfbd1146d240900390b66 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 14 Jul 2022 08:26:12 -0700 Subject: [PATCH 039/212] support comparison operators between strings. Reuses existing lowering? --- python/cudf/cudf/core/udf/lowering.py | 1 - python/cudf/cudf/core/udf/typing.py | 19 ++++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 29 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/lowering.py index a21ff094d8e..67cee4127d0 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/lowering.py @@ -78,7 +78,6 @@ def masked_scalar_op_impl(context, builder, sig, args): result = cgutils.create_struct_proxy(masked_return_type)( context, builder ) - # compute output validity valid = builder.and_(m1.valid, m2.valid) result.valid = valid diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/typing.py index 1ca1766911b..64a0d002058 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/typing.py @@ -394,6 +394,21 @@ def generic(self, args, kws): ) or isinstance(args[1], types.StringLiteral)): return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) +class MaskedStringViewCmpOp(AbstractTemplate): + """ + return the boolean result of `cmpop` between to strings + since the typing is the same for every comparison operator, + we can reuse this class for all of them. + """ + + def generic(self, args, kws): + if (isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( + args[1].value_type, StringView + ) or isinstance(args[1], types.StringLiteral)): + return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) + @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): """ @@ -467,6 +482,10 @@ def resolve_value(self, mod): def resolve_valid(self, mod): return types.boolean +for op in comparison_ops: + cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) + + for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 64e63229ffd..c462ffc2a62 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -814,6 +814,35 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "gpu", + "2022", + "cuDF", + "again_gpu", + ] + } + ], +) +@pytest.mark.parametrize("other", ["cudf", "123", "", " "]) +@pytest.mark.parametrize("cmpop", comparison_ops) +def test_string_udf_cmpops(data, other, cmpop): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return cmpop(st, other) + + run_masked_udf_test(func, data, check_dtype=False) + + + @pytest.mark.parametrize('data', [ { 'str_col': ["abc", "ABC", "aBc", "123", ""] From a232a207fd689f8226b3c6aa50320269b9639c22 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 19 Jul 2022 11:24:50 -0700 Subject: [PATCH 040/212] first attempt at adding strings_udf as a subpackage --- python/cudf/cudf/core/udf/__init__.py | 2 +- .../udf/{lowering.py => masked_lowering.py} | 142 +- .../core/udf/{typing.py => masked_typing.py} | 123 +- python/cudf/cudf/core/udf/row_function.py | 2 +- python/cudf/cudf/core/udf/scalar_function.py | 2 +- python/cudf/cudf/core/udf/strings_lowering.py | 151 + python/cudf/cudf/core/udf/strings_typing.py | 137 + python/cudf/cudf/core/udf/utils.py | 4 +- python/cudf/cudf/tests/test_udf_masked_ops.py | 123 - python/cudf/cudf/utils/cudautils.py | 2 +- python/strings_udf/LICENSE | 201 + python/strings_udf/README.md | 140 + python/strings_udf/cpp/CMakeLists.txt | 158 + .../cpp/cmake/thirdparty/get_jitify.cmake | 33 + .../cudf/strings/detail/convert/floats.cuh | 165 + .../cudf/strings/detail/convert/integers.cuh | 149 + .../cudf/strings/detail/strip_utils.cuh | 101 + .../cudf/strings/split/split_utils.cuh | 119 + .../include/cudf/strings/udf/char_types.cuh | 190 + .../cpp/include/cudf/strings/udf/dstring.cuh | 460 + .../cpp/include/cudf/strings/udf/dstring.hpp | 521 + .../cpp/include/cudf/strings/udf/numeric.cuh | 67 + .../cpp/include/cudf/strings/udf/search.cuh | 82 + .../cpp/include/cudf/strings/udf/split.cuh | 188 + .../include/cudf/strings/udf/starts_with.cuh | 117 + .../cpp/include/cudf/strings/udf/strip.cuh | 272 + .../cudf/strings/udf/type_traits_patch.hpp | 63 + .../cpp/include/cudf/strings/udf/udf_apis.hpp | 85 + python/strings_udf/cpp/sample_udfs/copy.udf | 16 + .../strings_udf/cpp/sample_udfs/example.txt | 5 + .../strings_udf/cpp/sample_udfs/example.xml | 6 + python/strings_udf/cpp/sample_udfs/filter.udf | 42 + .../strings_udf/cpp/sample_udfs/integers.udf | 19 + python/strings_udf/cpp/sample_udfs/join.udf | 34 + python/strings_udf/cpp/sample_udfs/lower.udf | 49 + python/strings_udf/cpp/sample_udfs/print.udf | 17 + python/strings_udf/cpp/sample_udfs/split.udf | 47 + .../cpp/sample_udfs/starts_with.udf | 21 + python/strings_udf/cpp/sample_udfs/strip.udf | 18 + python/strings_udf/cpp/sample_udfs/xml.udf | 29 + .../strings_udf/cpp/src/strings/udf/shim.cu | 268 + .../cpp/src/strings/udf/udf_apis.cu | 275 + .../cpp/src/strings/udf/udf_cli.cpp | 192 + python/strings_udf/cpp/tests/append.udf | 45 + python/strings_udf/cpp/tests/char_types.udf | 59 + python/strings_udf/cpp/tests/ctors.udf | 61 + python/strings_udf/cpp/tests/done.txt | 1 + python/strings_udf/cpp/tests/erase.udf | 33 + python/strings_udf/cpp/tests/insert.udf | 40 + python/strings_udf/cpp/tests/integers.udf | 34 + python/strings_udf/cpp/tests/replace.udf | 73 + python/strings_udf/cpp/tests/resize.udf | 35 + python/strings_udf/cpp/tests/run_tests.sh | 16 + python/strings_udf/cpp/tests/search.udf | 30 + python/strings_udf/cpp/tests/split.udf | 32 + python/strings_udf/cpp/tests/starts_ends.udf | 35 + python/strings_udf/cpp/tests/strip.udf | 59 + python/strings_udf/cpp/tests/substr.udf | 35 + python/strings_udf/cpp/tests/utilities.cuh | 43 + python/strings_udf/setup.py | 50 + python/strings_udf/strings_udf/__init__.py | 9 + .../strings_udf/strings_udf/_lib/__init__.pxd | 0 .../strings_udf/strings_udf/_lib/__init__.py | 0 .../strings_udf/_lib/cpp/__init__.pxd | 0 .../strings_udf/_lib/cpp/__init__.py | 0 .../strings_udf/_lib/cpp/strings_udf.pxd | 24 + .../strings_udf/_lib/cudf_jit_udf.cpp | 25684 ++++++++++++++++ .../strings_udf/_lib/cudf_jit_udf.pyx | 92 + python/strings_udf/strings_udf/_typing.py | 481 + python/strings_udf/strings_udf/lowering.py | 516 + .../strings_udf/strings_udf/tests/__init__.py | 6 + .../strings_udf/tests/test_cmpops.py | 71 + .../strings_udf/tests/test_contains.py | 15 + .../strings_udf/tests/test_count.py | 19 + .../strings_udf/tests/test_endswith.py | 19 + .../strings_udf/tests/test_find.py | 19 + .../strings_udf/tests/test_isalnum.py | 14 + .../strings_udf/tests/test_isdecimal.py | 14 + .../strings_udf/tests/test_isdigit.py | 14 + .../strings_udf/tests/test_islower.py | 14 + .../strings_udf/tests/test_isnumeric.py | 14 + .../strings_udf/tests/test_isspace.py | 14 + .../strings_udf/tests/test_isupper.py | 14 + .../strings_udf/tests/test_length.py | 15 + .../strings_udf/tests/test_rfind.py | 19 + .../strings_udf/tests/test_startswith.py | 19 + python/strings_udf/strings_udf/tests/utils.py | 46 + 87 files changed, 32280 insertions(+), 390 deletions(-) rename python/cudf/cudf/core/udf/{lowering.py => masked_lowering.py} (73%) rename python/cudf/cudf/core/udf/{typing.py => masked_typing.py} (76%) create mode 100644 python/cudf/cudf/core/udf/strings_lowering.py create mode 100644 python/cudf/cudf/core/udf/strings_typing.py create mode 100644 python/strings_udf/LICENSE create mode 100644 python/strings_udf/README.md create mode 100644 python/strings_udf/cpp/CMakeLists.txt create mode 100644 python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake create mode 100644 python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/search.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/split.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp create mode 100644 python/strings_udf/cpp/sample_udfs/copy.udf create mode 100644 python/strings_udf/cpp/sample_udfs/example.txt create mode 100644 python/strings_udf/cpp/sample_udfs/example.xml create mode 100644 python/strings_udf/cpp/sample_udfs/filter.udf create mode 100644 python/strings_udf/cpp/sample_udfs/integers.udf create mode 100644 python/strings_udf/cpp/sample_udfs/join.udf create mode 100644 python/strings_udf/cpp/sample_udfs/lower.udf create mode 100644 python/strings_udf/cpp/sample_udfs/print.udf create mode 100644 python/strings_udf/cpp/sample_udfs/split.udf create mode 100644 python/strings_udf/cpp/sample_udfs/starts_with.udf create mode 100644 python/strings_udf/cpp/sample_udfs/strip.udf create mode 100644 python/strings_udf/cpp/sample_udfs/xml.udf create mode 100644 python/strings_udf/cpp/src/strings/udf/shim.cu create mode 100644 python/strings_udf/cpp/src/strings/udf/udf_apis.cu create mode 100644 python/strings_udf/cpp/src/strings/udf/udf_cli.cpp create mode 100644 python/strings_udf/cpp/tests/append.udf create mode 100644 python/strings_udf/cpp/tests/char_types.udf create mode 100644 python/strings_udf/cpp/tests/ctors.udf create mode 100644 python/strings_udf/cpp/tests/done.txt create mode 100644 python/strings_udf/cpp/tests/erase.udf create mode 100644 python/strings_udf/cpp/tests/insert.udf create mode 100644 python/strings_udf/cpp/tests/integers.udf create mode 100644 python/strings_udf/cpp/tests/replace.udf create mode 100644 python/strings_udf/cpp/tests/resize.udf create mode 100755 python/strings_udf/cpp/tests/run_tests.sh create mode 100644 python/strings_udf/cpp/tests/search.udf create mode 100644 python/strings_udf/cpp/tests/split.udf create mode 100644 python/strings_udf/cpp/tests/starts_ends.udf create mode 100644 python/strings_udf/cpp/tests/strip.udf create mode 100644 python/strings_udf/cpp/tests/substr.udf create mode 100644 python/strings_udf/cpp/tests/utilities.cuh create mode 100644 python/strings_udf/setup.py create mode 100644 python/strings_udf/strings_udf/__init__.py create mode 100644 python/strings_udf/strings_udf/_lib/__init__.pxd create mode 100644 python/strings_udf/strings_udf/_lib/__init__.py create mode 100644 python/strings_udf/strings_udf/_lib/cpp/__init__.pxd create mode 100644 python/strings_udf/strings_udf/_lib/cpp/__init__.py create mode 100644 python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd create mode 100644 python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp create mode 100644 python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx create mode 100644 python/strings_udf/strings_udf/_typing.py create mode 100644 python/strings_udf/strings_udf/lowering.py create mode 100644 python/strings_udf/strings_udf/tests/__init__.py create mode 100644 python/strings_udf/strings_udf/tests/test_cmpops.py create mode 100644 python/strings_udf/strings_udf/tests/test_contains.py create mode 100644 python/strings_udf/strings_udf/tests/test_count.py create mode 100644 python/strings_udf/strings_udf/tests/test_endswith.py create mode 100644 python/strings_udf/strings_udf/tests/test_find.py create mode 100644 python/strings_udf/strings_udf/tests/test_isalnum.py create mode 100644 python/strings_udf/strings_udf/tests/test_isdecimal.py create mode 100644 python/strings_udf/strings_udf/tests/test_isdigit.py create mode 100644 python/strings_udf/strings_udf/tests/test_islower.py create mode 100644 python/strings_udf/strings_udf/tests/test_isnumeric.py create mode 100644 python/strings_udf/strings_udf/tests/test_isspace.py create mode 100644 python/strings_udf/strings_udf/tests/test_isupper.py create mode 100644 python/strings_udf/strings_udf/tests/test_length.py create mode 100644 python/strings_udf/strings_udf/tests/test_rfind.py create mode 100644 python/strings_udf/strings_udf/tests/test_startswith.py create mode 100644 python/strings_udf/strings_udf/tests/utils.py diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 4608cae3228..62db19401b5 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -1 +1 @@ -from . import typing, lowering +from . import masked_typing, masked_lowering, strings_typing, strings_lowering diff --git a/python/cudf/cudf/core/udf/lowering.py b/python/cudf/cudf/core/udf/masked_lowering.py similarity index 73% rename from python/cudf/cudf/core/udf/lowering.py rename to python/cudf/cudf/core/udf/masked_lowering.py index 67cee4127d0..26f4040a56a 100644 --- a/python/cudf/cudf/core/udf/lowering.py +++ b/python/cudf/cudf/core/udf/masked_lowering.py @@ -19,24 +19,16 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.typing import ( +from cudf.core.udf.masked_typing import ( MaskedType, NAType, ) -from strings_udf._typing import string_view -from strings_udf.lowering import ( - string_view_len_impl, - string_view_startswith_impl, - string_view_endswith_impl, - string_view_find_impl, - string_view_rfind_impl, - string_view_contains_impl, -) - import operator +from strings_udf._typing import string_view + @cuda_lowering_registry.lower_constant(NAType) def constant_na(context, builder, ty, pyval): # This handles None, etc. @@ -385,131 +377,3 @@ def lower_constant_masked(context, builder, ty, val): masked.value = context.get_constant(ty.value_type, val.value) masked.valid = context.get_constant(types.boolean, val.valid) return masked._getvalue() - -@cuda_lower(len, MaskedType(string_view)) -def masked_string_view_len_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - result = string_view_len_impl(context, builder, types.int32(string_view), (masked_sv.value,)) - ret.value = result - ret.valid = masked_sv.valid - - return ret._getvalue() - - -@cuda_lower( - "MaskedType.startswith", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_startswith_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_startswith_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - - -@cuda_lower( - "MaskedType.endswith", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_endswith_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_endswith_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - -@cuda_lower( - "MaskedType.find", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_find_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_find_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - -@cuda_lower( - "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_rfind_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_rfind_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - -@cuda_lower(operator.contains, MaskedType(string_view), MaskedType(string_view)) -def masked_string_view_contains_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_contains_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/typing.py b/python/cudf/cudf/core/udf/masked_typing.py similarity index 76% rename from python/cudf/cudf/core/udf/typing.py rename to python/cudf/cudf/core/udf/masked_typing.py index 64a0d002058..f3a25231839 100644 --- a/python/cudf/cudf/core/udf/typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -37,9 +37,7 @@ import operator -from strings_udf._typing import StringView, string_view - - +from strings_udf._typing import string_view, StringView # Masked scalars of all types class MaskedType(types.Type): @@ -163,7 +161,6 @@ class MaskedConstructor(ConcreteTemplate): # Provide access to `m.value` and `m.valid` in a kernel for a Masked `m`. make_attribute_wrapper(MaskedType, "value", "value") make_attribute_wrapper(MaskedType, "valid", "valid") -make_attribute_wrapper(StringView, "data", "data") # Typing for `api.Masked` @cuda_decl_registry.register_attr @@ -367,124 +364,6 @@ def generic(self, args, kws): return nb_signature(return_type, args[0]) -# String functions -@cuda_decl_registry.register_global(len) -class MaskedStringViewLength(AbstractTemplate): - """ - provide the length of a cudf::string_view like struct - """ - - def generic(self, args, kws): - if isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView - ): - return nb_signature(MaskedType(types.int32), args[0]) - -@cuda_decl_registry.register_global(operator.contains) -class MaskedStringViewContains(AbstractTemplate): - """ - return a boolean indicating if a substring is found in a string - """ - - def generic(self, args, kws): - if (isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView - ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( - args[1].value_type, StringView - ) or isinstance(args[1], types.StringLiteral)): - return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) - -class MaskedStringViewCmpOp(AbstractTemplate): - """ - return the boolean result of `cmpop` between to strings - since the typing is the same for every comparison operator, - we can reuse this class for all of them. - """ - - def generic(self, args, kws): - if (isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView - ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( - args[1].value_type, StringView - ) or isinstance(args[1], types.StringLiteral)): - return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) - -@cuda_decl_registry.register_global(len) -class StringLiteralLength(AbstractTemplate): - """ - provide the length of a python string literal by first - converting to a cudf::string_view first - """ - - def generic(self, args, kws): - if isinstance(args[0], types.StringLiteral) and len(args) == 1: - return nb_signature(types.int32, args[0]) - -class MaskedStringViewStartsWith(AbstractTemplate): - key = "MaskedType.startswith" - - def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), MaskedType(string_view), recvr=self.this - ) - -class MaskedStringViewEndsWith(AbstractTemplate): - key = "MaskedType.endswith" - - def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), MaskedType(string_view), recvr=self.this - ) - -class MaskedStringViewFind(AbstractTemplate): - key = "MaskedType.find" - - def generic(self, args, kws): - return nb_signature( - MaskedType(types.int32), MaskedType(string_view), recvr=self.this - ) - -class MaskedStringViewRFind(AbstractTemplate): - key = "MaskedType.rfind" - - def generic(self, args, kws): - return nb_signature( - MaskedType(types.int32), MaskedType(string_view), recvr=self.this - ) - -@cuda_decl_registry.register_attr -class MaskedStringViewAttrs(AttributeTemplate): - key = MaskedType(string_view) - - def resolve_startswith(self, mod): - return types.BoundFunction( - MaskedStringViewStartsWith, MaskedType(string_view) - ) - - def resolve_endswith(self, mod): - return types.BoundFunction( - MaskedStringViewEndsWith, MaskedType(string_view) - ) - - def resolve_find(self, mod): - return types.BoundFunction( - MaskedStringViewFind, MaskedType(string_view) - ) - - def resolve_rfind(self, mod): - return types.BoundFunction( - MaskedStringViewRFind, MaskedType(string_view) - ) - - def resolve_value(self, mod): - return string_view - - def resolve_valid(self, mod): - return types.boolean - -for op in comparison_ops: - cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) - for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 7eb9d3741fe..d5c86c393a8 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -13,7 +13,7 @@ row_kernel_template, unmasked_input_initializer_template, ) -from cudf.core.udf.typing import MaskedType +from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.utils import ( _all_dtypes_from_frame, _construct_signature, diff --git a/python/cudf/cudf/core/udf/scalar_function.py b/python/cudf/cudf/core/udf/scalar_function.py index a7b887dd2d5..26d88fca7a5 100644 --- a/python/cudf/cudf/core/udf/scalar_function.py +++ b/python/cudf/cudf/core/udf/scalar_function.py @@ -9,7 +9,7 @@ scalar_kernel_template, unmasked_input_initializer_template, ) -from cudf.core.udf.typing import MaskedType +from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.utils import ( _construct_signature, _get_kernel, diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py new file mode 100644 index 00000000000..43f613b791d --- /dev/null +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -0,0 +1,151 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from strings_udf._typing import string_view +from strings_udf.lowering import ( + string_view_len_impl, + string_view_startswith_impl, + string_view_endswith_impl, + string_view_find_impl, + string_view_rfind_impl, + string_view_contains_impl, +) + +from numba import types +from cudf.core.udf.masked_typing import MaskedType + +from numba.cuda.cudaimpl import ( + lower as cuda_lower, + registry as cuda_lowering_registry, +) + +from numba.core import cgutils +import operator + + +@cuda_lower(len, MaskedType(string_view)) +def masked_string_view_len_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + result = string_view_len_impl(context, builder, types.int32(string_view), (masked_sv.value,)) + ret.value = result + ret.valid = masked_sv.valid + + return ret._getvalue() + + +@cuda_lower( + "MaskedType.startswith", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_startswith_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_startswith_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + + +@cuda_lower( + "MaskedType.endswith", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_endswith_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_endswith_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + +@cuda_lower( + "MaskedType.find", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_find_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_find_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + +@cuda_lower( + "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_rfind_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_rfind_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + +@cuda_lower(operator.contains, MaskedType(string_view), MaskedType(string_view)) +def masked_string_view_contains_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_contains_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value) + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py new file mode 100644 index 00000000000..2fce695ed5b --- /dev/null +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -0,0 +1,137 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + + +#make_attribute_wrapper(StringView, "data", "data") +from numba.core.typing.templates import ( + AbstractTemplate, + AttributeTemplate, +) + +import operator + +from cudf.core.udf.masked_typing import MaskedType + +from strings_udf._typing import StringView, string_view +from numba.cuda.cudadecl import registry as cuda_decl_registry +from numba import types +from numba.core.typing import signature as nb_signature + +from cudf.core.udf._ops import comparison_ops + +# String functions +@cuda_decl_registry.register_global(len) +class MaskedStringViewLength(AbstractTemplate): + """ + provide the length of a cudf::string_view like struct + """ + + def generic(self, args, kws): + if isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ): + return nb_signature(MaskedType(types.int32), args[0]) + +@cuda_decl_registry.register_global(operator.contains) +class MaskedStringViewContains(AbstractTemplate): + """ + return a boolean indicating if a substring is found in a string + """ + + def generic(self, args, kws): + if (isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( + args[1].value_type, StringView + ) or isinstance(args[1], types.StringLiteral)): + return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) + +class MaskedStringViewCmpOp(AbstractTemplate): + """ + return the boolean result of `cmpop` between to strings + since the typing is the same for every comparison operator, + we can reuse this class for all of them. + """ + + def generic(self, args, kws): + if (isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( + args[1].value_type, StringView + ) or isinstance(args[1], types.StringLiteral)): + return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) + +@cuda_decl_registry.register_global(len) +class StringLiteralLength(AbstractTemplate): + """ + provide the length of a python string literal by first + converting to a cudf::string_view first + """ + + def generic(self, args, kws): + if isinstance(args[0], types.StringLiteral) and len(args) == 1: + return nb_signature(types.int32, args[0]) + +class MaskedStringViewStartsWith(AbstractTemplate): + key = "MaskedType.startswith" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), MaskedType(string_view), recvr=self.this + ) + +class MaskedStringViewEndsWith(AbstractTemplate): + key = "MaskedType.endswith" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), MaskedType(string_view), recvr=self.this + ) + +class MaskedStringViewFind(AbstractTemplate): + key = "MaskedType.find" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.int32), MaskedType(string_view), recvr=self.this + ) + +class MaskedStringViewRFind(AbstractTemplate): + key = "MaskedType.rfind" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.int32), MaskedType(string_view), recvr=self.this + ) + +@cuda_decl_registry.register_attr +class MaskedStringViewAttrs(AttributeTemplate): + key = MaskedType(string_view) + + def resolve_startswith(self, mod): + return types.BoundFunction( + MaskedStringViewStartsWith, MaskedType(string_view) + ) + + def resolve_endswith(self, mod): + return types.BoundFunction( + MaskedStringViewEndsWith, MaskedType(string_view) + ) + + def resolve_find(self, mod): + return types.BoundFunction( + MaskedStringViewFind, MaskedType(string_view) + ) + + def resolve_rfind(self, mod): + return types.BoundFunction( + MaskedStringViewRFind, MaskedType(string_view) + ) + + def resolve_value(self, mod): + return string_view + + def resolve_valid(self, mod): + return types.boolean + +for op in comparison_ops: + cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 6cdee2a48cd..b19543cf651 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -11,7 +11,7 @@ import cupy as cp from cudf.core.dtypes import CategoricalDtype -from cudf.core.udf.typing import MaskedType +from cudf.core.udf.masked_typing import MaskedType from cudf.core.column.column import as_column from cudf.utils import cudautils from cudf.utils.dtypes import ( @@ -22,9 +22,9 @@ STRING_TYPES, ) from cudf.api.types import is_string_dtype -from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view from strings_udf import ptxpath +from strings_udf._lib.cudf_jit_udf import to_string_view_array from cudf.utils.utils import _cudf_nvtx_annotate diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index c462ffc2a62..14d83e8564f 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -840,126 +840,3 @@ def func(row): return cmpop(st, other) run_masked_udf_test(func, data, check_dtype=False) - - - -@pytest.mark.parametrize('data', [ - { - 'str_col': ["abc", "ABC", "aBc", "123", ""] - } -]) -def test_string_udf_upper(data): - # tests the `upper` method of strings - - data = cudf.DataFrame(data) - def func(row): - st = row['str_col'] - return st.upper() - - run_masked_udf_test(func, data, check_dtype=False) - -@pytest.mark.parametrize('data', [ - { - 'str_col': ["abc", "ABC", "aBc", "123", ""] - } -]) -def test_string_udf_lower(data): - # tests the `lower` method of strings - - data = cudf.DataFrame(data) - def func(row): - st = row['str_col'] - return st.lower() - - run_masked_udf_test(func, data, check_dtype=False) - -@pytest.mark.parametrize('data', [ - { - 'str_col': ['abc', 'a', '', '123AbC'] - } -]) -@pytest.mark.parametrize("idx", [0, 1, 2, -1]) -def test_string_udf_indexing(data, idx): - # tests indexing into strings with an int - - data = cudf.DataFrame(data) - - def func(row): - st = row['str_col'] - return row[idx] - - run_masked_udf_test(func, data) - -@pytest.mark.parametrize('data', [ - { - 'str_col': ['abc', 'a', '', '123AbC'] - } -]) -@pytest.mark.parametrize("slc", [ - slice(0, 1), - slice(0, -1), - slice(None, 2), - slice(2, None), - slice(0, 0) -]) -def test_string_udf_substring(data, slc): - # tests indexing into strings with an int - - data = cudf.DataFrame(data) - - def func(row): - st = row['str_col'] - return row[slc] - - run_masked_udf_test(func, data) - -@pytest.mark.parametrize('data', [ - { - 'str_col': ['abcd', 'AbCd', 'ABCD', '123AbC'] - } -]) -@pytest.mark.parametrize('chars', ['a', 'b', 'C', 'cd']) -def test_string_udf_strip(data, chars): - # tests str.strip() - - data = cudf.DataFrame(data) - - def func(row): - st = row['str_col'] - return st.strip(chars) - - run_masked_udf_test(func, data) - -@pytest.mark.parametrize('data', [ - { - 'str_col': ['abcdd', 'AbCd', 'ABCD', '123AbC'] - } -]) -@pytest.mark.parametrize('chars', ['a', 'b', 'C', 'cd']) -def test_string_udf_lstrip(data, chars): - # tests str.lstrip() - - data = cudf.DataFrame(data) - - def func(row): - st = row['str_col'] - return st.lstrip(chars) - - run_masked_udf_test(func, data) - -@pytest.mark.parametrize('data', [ - { - 'str_col': ['abcd', 'AbCd', 'ABCD', '123AbC'] - } -]) -@pytest.mark.parametrize('chars', ['a', 'b', 'C', 'cd']) -def test_string_udf_rstrip(data, chars): - # tests str.rstrip() - - data = cudf.DataFrame(data) - - def func(row): - st = row['str_col'] - return st.rstrip(chars) - - run_masked_udf_test(func, data) diff --git a/python/cudf/cudf/utils/cudautils.py b/python/cudf/cudf/utils/cudautils.py index d83aa90243a..85e40b20264 100755 --- a/python/cudf/cudf/utils/cudautils.py +++ b/python/cudf/cudf/utils/cudautils.py @@ -250,7 +250,7 @@ def compile_udf(udf, type_signature): ptx_code, return_type = cuda.compile_ptx_for_current_device( udf, type_signature, device=True ) - if not isinstance(return_type, cudf.core.udf.typing.MaskedType): + if not isinstance(return_type, cudf.core.udf.masked_typing.MaskedType): output_type = numpy_support.as_dtype(return_type).type else: output_type = return_type diff --git a/python/strings_udf/LICENSE b/python/strings_udf/LICENSE new file mode 100644 index 00000000000..18bcb4316e6 --- /dev/null +++ b/python/strings_udf/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2018 NVIDIA Corporation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/python/strings_udf/README.md b/python/strings_udf/README.md new file mode 100644 index 00000000000..4b35c0ad923 --- /dev/null +++ b/python/strings_udf/README.md @@ -0,0 +1,140 @@ +# strings_udf +User Defined Function (UDF) prototype for operating against a libcudf strings column. + +UDFs are custom kernel/device CUDA code that execute in parallel threads on an NVIDIA GPU. +The libcudf library contains fixed operation primitives written in CUDA/C++ for strings. +Strings are variable length and libcudf is optimized to minimize costly memory allocations +when operations modify strings. This pattern can make custom UDF logic very difficult to write. + +## Strings UDF device library + +To make it easier to write UDFs, a device string class [dstring](cpp/include/cudf/strings/udf/dstring.hpp) has been created to perform specific operations on +individual strings. +The libcudf strings column strings are read-only but an individual `cudf::string_view` instance can be copied to a `dstring` and this copy can be modified using the `dstring` methods. +Once the UDF has been executed on each string, the resulting strings +can be converted back into a libcudf strings column. +Note that `dstring` uses CUDA malloc/free in device code to manage its string data. +We are hoping to improve this high cost memory allocation and deallocation in the future. + +## Dependencies +The libcudf strings implementation is available here: https://github.com/rapidsai/cudf. +To build the artifacts in this repo requires an existing developer install of libcudf. +This means libcudf and its appropriate dependencies must be available for include and link from the CUDA compiler (nvcc). +Further, it is expected cuDF and libcudf are installed in a Conda +environment and there is a `CONDA_PREFIX` environment variable set to that conda environment directory. + +Follow the [instructions to install cudf](https://github.com/rapidsai/cudf/#conda) + +The CUDA toolkit must be installed and include [NVRTC](https://docs.nvidia.com/cuda/nvrtc/index.html) to build and launch the UDFs. +The code here has only been tested on CUDA 11.5 but may work on 11.x or later versions as well. + +## Building +Make sure the `CONDA_PREFIX` environment variable points to the conda environment directory +containing cuDF and libcudf (e.g. `/conda/env/rapids`). + +### CUDA/C++ +The CUDA/C++ code is built using `cmake` which is expected to be version `3.20.1` or higher. + +From the `cpp` directory create a `build` directory and run `cmake` as follows: +``` +cd cpp +mkdir build +cd build +cmake .. -DCONDA_PREFIX=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX +make +make install +``` + +This will build the `libcudf_strings_udf.so` functions library and the `udf_cli` command-line interface. + +### Python +The `libcudf_strings_udf.so` must be built first since the Python library here depends on it for executing UDFs. +Follow the instructions in the [Python](python) directory to build the python library. + + +## Command Line Interface (CLI) + +A CLI is included here to demonstrate executing a UDF on a libcudf strings column instance. +The strings column is by created from a text file with new-line delimiters for each string or from a CSV file. +The cudf cuIO CSV reader is used to load the text file into a libcudf strings column. + +The UDF CUDA kernel is launched with the number of threads equal to the number of input strings (rows). +And each thread can work on a single row to produce a single output string. +After the threads complete, the resulting strings are gathered into a libcudf strings column. + +Create the UDF function in a text file to pass to the CLI. +The output result can be written to a specified file or to the console. + +The CLI parameters are as follows + +| Parameter | Description | Default | +|:---------:| ----------- | ------- | +| -u | Text file contain UDF kernel function in CUDA/C++ | (required) | +| -n | Kernel function name in the UDF file | "udf_kernel" | +| -t | Text or CSV-file for creating strings column | (required) | +| -i | Include directory for libcudf | default is $CONDA_PREFIX/include | +| -c | 0-based column number if CSV file | 0 (first column) | +| -r | Number of rows to read from file | 0 (entire file) | +| -f | Output file name/path | default output is stdout | +| -m | Maximum malloc heap size in MB | 1000 | + +Note that to run this CLI you might need to add paths to your `LD_LIBRARY_PATH`. For example: +``` +export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH:$CONDA_PREFIX/lib +``` +Note this also prepends the `.` path so that the current directory is included when locating dependent shared objects to load. + +### Example +The following example shows parsing an XML file to retrieve the `name` attribute of each `entry`. + +Here is the example XML file [`example.xml`](cpp/sample_udfs/example.xml) +``` + + + + + + +``` + +Example UDF file [`xml.udf`](cpp/sample_udfs/xml.udf) +``` +#include + +__device__ cudf::string_view find_attr( cudf::string_view const& input, + cudf::string_view const& name ) +{ + auto pos = input.find(name); + if( pos < 0 ) return cudf::string_view{"",0}; + + cudf::string_view quote("\"",1); + auto begin = input.find(quote, pos) + 1; + auto end = input.find(quote, begin); + + return input.substr(begin, end-begin); +} + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid >= count ) return; + + auto input_str = d_in_strs[tid]; + + auto name = find_attr(input_str, cudf::string_view("name",4)); + + d_out_strs[tid] = name; // makes a copy here +} +``` + +Example CLI: +``` +$ ./udf_cli -u ../sample_udfs/xml.udf -t ../sample_udfs/example.xml + +Toby +David +Bill +Ted +Jane +``` diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt new file mode 100644 index 00000000000..afb9c383b0e --- /dev/null +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -0,0 +1,158 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +cmake_minimum_required(VERSION 3.20.1) + +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake + ${CMAKE_BINARY_DIR}/RAPIDS.cmake +) +include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) + +include(rapids-cmake) +include(rapids-cpm) +include(rapids-cuda) +include(rapids-export) +include(rapids-find) + +rapids_cpm_init() +include(cmake/thirdparty/get_jitify.cmake) + +# set the project name and version +project( + cudf_strings_udf + VERSION 0.1 + DESCRIPTION "cudf strings-udf library" + LANGUAGES C CXX CUDA +) + +if(NOT CONDA_PREFIX) + message(FATAL_ERROR " CONDA_PREFIX must be set") +endif() + +message(STATUS "CONDA_PREFIX=${CONDA_PREFIX}" ) + +find_package(CUDAToolkit REQUIRED) + +# depends on an installed cudf dev env +set(UDF_INCLUDES ${CONDA_PREFIX}/include) +list(APPEND UDF_INCLUDES ${CONDA_PREFIX}/include/rapids/libcudacxx) +list(APPEND UDF_INCLUDES ${CMAKE_SOURCE_DIR}/build/_deps/jitify-src) + +set(UDF_LIBS ${CONDA_PREFIX}/lib/libcudf.so nvrtc) + +set(UDF_CXX_FLAGS "") +set(UDF_CUDA_FLAGS "") +set(SHIM_CUDA_FLAGS "") + +list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) +list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true -keep) + +add_library( + cudf_strings_udf SHARED + src/strings/udf/udf_apis.cu +) + +add_library( + shim OBJECT + src/strings/udf/shim.cu +) + +set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) + +target_include_directories( + shim + PRIVATE include + PUBLIC ${CMAKE_SOURCE_DIR}/include +) + +target_include_directories( + shim + PRIVATE include + PUBLIC ${CONDA_PREFIX}/include +) + + +set_target_properties( + cudf_strings_udf + PROPERTIES + BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON +) + +target_compile_options( + cudf_strings_udf PRIVATE + "$<$:${UDF_CXX_FLAGS}>" + "$<$:${UDF_CUDA_FLAGS}>" +) + +target_compile_options( + shim PRIVATE + "$<$:${SHIM_CUDA_FLAGS}>" +) + +target_include_directories( + cudf_strings_udf + PRIVATE include + PUBLIC ${UDF_INCLUDES} +) +target_link_libraries( + cudf_strings_udf + PUBLIC ${UDF_LIBS} +) + +add_executable( + udf_cli + src/strings/udf/udf_cli.cpp +) +target_include_directories( + udf_cli + PRIVATE include + PUBLIC ${UDF_INCLUDES} + CUDA::cudart +) +target_link_libraries( + udf_cli + PUBLIC cudf_strings_udf + PUBLIC ${UDF_LIBS} + CUDA::cudart +) +set_target_properties( + udf_cli + PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON +) + + +install(TARGETS cudf_strings_udf) +install(TARGETS udf_cli) + +add_custom_command( + OUTPUT dstring_test + COMMAND ../tests/run_tests.sh + VERBATIM + COMMENT "Running dstring tests." +) + +add_custom_target( + test + DEPENDS dstring_test + COMMENT "Run dstring tests." +) diff --git a/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake b/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake new file mode 100644 index 00000000000..ad334caee3b --- /dev/null +++ b/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake @@ -0,0 +1,33 @@ + +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +# Jitify doesn't have a version :/ + +# This function finds Jitify and sets any additional necessary environment variables. +function(find_and_configure_jitify) + rapids_cpm_find( + jitify 2.0.0 + GIT_REPOSITORY https://github.com/rapidsai/jitify.git + GIT_TAG cudf_0.19 + GIT_SHALLOW TRUE + DOWNLOAD_ONLY TRUE + ) + set(JITIFY_INCLUDE_DIR + "${jitify_SOURCE_DIR}" + PARENT_SCOPE + ) +endfunction() + +find_and_configure_jitify() diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh new file mode 100644 index 00000000000..241203213fa --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh @@ -0,0 +1,165 @@ + +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +#include +#include + +namespace cudf { +namespace strings { +namespace detail { + +/** + * @brief Returns true if input contains the not-a-number string. + * + * The following are valid for this function: "NAN" and "NaN" + * @param d_str input string + * @return true if input is as valid NaN string. + */ +inline __device__ bool is_nan_str(string_view const& d_str) +{ + auto const ptr = d_str.data(); + return (d_str.size_bytes() == 3) && (ptr[0] == 'N' || ptr[0] == 'n') && + (ptr[1] == 'A' || ptr[1] == 'a') && (ptr[2] == 'N' || ptr[2] == 'n'); +} + +/** + * @brief Returns true if input contains the infinity string. + * + * The following are valid for this function: "INF", "INFINITY", and "Inf" + * @param d_str input string + * @return true if input is as valid Inf string. + */ +inline __device__ bool is_inf_str(string_view const& d_str) +{ + auto const ptr = d_str.data(); + auto const size = d_str.size_bytes(); + + if (size != 3 && size != 8) return false; + + auto const prefix_valid = (ptr[0] == 'I' || ptr[0] == 'i') && (ptr[1] == 'N' || ptr[1] == 'n') && + (ptr[2] == 'F' || ptr[2] == 'f'); + + return prefix_valid && + ((size == 3) || ((ptr[3] == 'I' || ptr[3] == 'i') && (ptr[4] == 'N' || ptr[4] == 'n') && + (ptr[5] == 'I' || ptr[5] == 'i') && (ptr[6] == 'T' || ptr[6] == 't') && + (ptr[7] == 'Y' || ptr[7] == 'y'))); +} + +__device__ inline double stod(string_view const& d_str) +{ + const char* in_ptr = d_str.data(); + const char* end = in_ptr + d_str.size_bytes(); + if (end == in_ptr) return 0.0; + double sign{1.0}; + if (*in_ptr == '-' || *in_ptr == '+') { + sign = (*in_ptr == '-' ? -1 : 1); + ++in_ptr; + } + + // could not find INFINITY and std::numeric_limits::infinity() does not work; + // same for std::numeric_limits::quiet_NaN() but looks like nan() works ok + constexpr double infinity = (1.0 / 0.0); + + // special strings: NaN, Inf + if ((in_ptr < end) && *in_ptr > '9') { + auto const inf_nan = string_view(in_ptr, static_cast(end - in_ptr)); + if (is_nan_str(inf_nan)) return nan(""); + if (is_inf_str(inf_nan)) return sign * infinity; + } + + // Parse and store the mantissa as much as we can, + // until we are about to exceed the limit of uint64_t + constexpr uint64_t max_holding = (18446744073709551615U - 9U) / 10U; + uint64_t digits = 0; + int exp_off = 0; + bool decimal = false; + while (in_ptr < end) { + char ch = *in_ptr; + if (ch == '.') { + decimal = true; + ++in_ptr; + continue; + } + if (ch < '0' || ch > '9') break; + if (digits > max_holding) + exp_off += (int)!decimal; + else { + digits = (digits * 10L) + static_cast(ch - '0'); + if (digits > max_holding) { + digits = digits / 10L; + exp_off += (int)!decimal; + } else + exp_off -= (int)decimal; + } + ++in_ptr; + } + if (digits == 0) return sign * static_cast(0); + + // check for exponent char + int exp_ten = 0; + int exp_sign = 1; + if (in_ptr < end) { + char ch = *in_ptr++; + if (ch == 'e' || ch == 'E') { + if (in_ptr < end) { + ch = *in_ptr; + if (ch == '-' || ch == '+') { + exp_sign = (ch == '-' ? -1 : 1); + ++in_ptr; + } + while (in_ptr < end) { + ch = *in_ptr++; + if (ch < '0' || ch > '9') break; + exp_ten = (exp_ten * 10) + (int)(ch - '0'); + } + } + } + } + + int const num_digits = static_cast(log10((double)digits)) + 1; + exp_ten *= exp_sign; + exp_ten += exp_off; + exp_ten += num_digits - 1; + if (exp_ten > std::numeric_limits::max_exponent10) { + return sign > 0 ? infinity : -infinity; + } + + double base = sign * static_cast(digits); + + exp_ten += 1 - num_digits; + // If 10^exp_ten would result in a subnormal value, the base and + // exponent should be adjusted so that 10^exp_ten is a normal value + auto const subnormal_shift = std::numeric_limits::min_exponent10 - exp_ten; + if (subnormal_shift > 0) { + // Handle subnormal values. Ensure that both base and exponent are + // normal values before computing their product. + base = base / exp10(static_cast(num_digits - 1 + subnormal_shift)); + exp_ten += num_digits - 1; // adjust exponent + auto const exponent = exp10(static_cast(exp_ten + subnormal_shift)); + return base * exponent; + } + + double const exponent = exp10(static_cast(std::abs(exp_ten))); + return exp_ten < 0 ? base / exponent : base * exponent; +} + +} // namespace detail +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh new file mode 100644 index 00000000000..460887449f5 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh @@ -0,0 +1,149 @@ + +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +#include +#include + +namespace cudf { +namespace strings { +namespace detail { + +/** + * @brief Converts a single string into an integer. + * + * The '+' and '-' are allowed but only at the beginning of the string. + * The string is expected to contain base-10 [0-9] characters only. + * Any other character will end the parse. + * Overflow of the int64 type is not detected. + */ +__device__ inline int64_t string_to_integer(string_view const& d_str) +{ + int64_t value = 0; + auto bytes = d_str.size_bytes(); + if (bytes == 0) return value; + auto ptr = d_str.data(); + auto sign = 1; + if (*ptr == '-' || *ptr == '+') { + sign = (*ptr == '-' ? -1 : 1); + ++ptr; + --bytes; + } + for (size_type idx = 0; idx < bytes; ++idx) { + char chr = *ptr++; + if (chr < '0' || chr > '9') break; + value = (value * 10) + static_cast(chr - '0'); + } + return value * static_cast(sign); +} + +/** + * @brief Converts an integer into string + * + * @tparam IntegerType integer type to convert from + * @param value integer value to convert + * @param d_buffer character buffer to store the converted string + */ +template +__device__ inline size_type integer_to_string(IntegerType value, char* d_buffer) +{ + if (value == 0) { + *d_buffer = '0'; + return 1; + } + bool const is_negative = std::is_signed() ? (value < 0) : false; + + constexpr IntegerType base = 10; + // largest 64-bit integer is 20 digits; largest 128-bit integer is 39 digits + constexpr int MAX_DIGITS = std::numeric_limits::digits10 + 1; + char digits[MAX_DIGITS]; // place-holder for digit chars + int digits_idx = 0; + while (value != 0) { + assert(digits_idx < MAX_DIGITS); + digits[digits_idx++] = '0' + abs(value % base); + // next digit + value = value / base; + } + size_type const bytes = digits_idx + static_cast(is_negative); + + char* ptr = d_buffer; + if (is_negative) *ptr++ = '-'; + // digits are backwards, reverse the string into the output + while (digits_idx-- > 0) *ptr++ = digits[digits_idx]; + return bytes; +} + +/** + * @brief Counts number of digits in a integer value including '-' sign + * + * @tparam IntegerType integer type of input value + * @param value input value to count the digits of + * @return size_type number of digits in input value + */ +template +constexpr size_type count_digits(IntegerType value) +{ + if (value == 0) return 1; + bool const is_negative = std::is_signed() ? (value < 0) : false; + // std::numeric_limits::min() is negative; + // for all integer types, the max() and min() values have the same number of digits + value = (value == std::numeric_limits::min()) + ? std::numeric_limits::max() + : abs(value); + + auto const digits = [value] { + // largest 8-byte unsigned value is 18446744073709551615 (20 digits) + // largest 16-byte unsigned value is 340282366920938463463374607431768211455 (39 digits) + auto constexpr max_digits = std::numeric_limits::digits10 + 1; + + size_type digits = 1; + int64_t pow10 = 10; + for (; digits < max_digits; ++digits, pow10 *= 10) + if (value < pow10) break; + return digits; + }(); + + return digits + static_cast(is_negative); +} + +__device__ int64_t hex_to_integer(string_view const& d_str) +{ + int64_t result = 0; + int64_t base = 1; + auto const str = d_str.data(); + auto index = d_str.size_bytes(); + while (index-- > 0) { + auto const ch = str[index]; + if (ch >= '0' && ch <= '9') { + result += static_cast(ch - 48) * base; + base *= 16; + } else if (ch >= 'A' && ch <= 'F') { + result += static_cast(ch - 55) * base; + base *= 16; + } else if (ch >= 'a' && ch <= 'f') { + result += static_cast(ch - 87) * base; + base *= 16; + } + } + return result; +} + +} // namespace detail +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh new file mode 100644 index 00000000000..5d8d9240988 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh @@ -0,0 +1,101 @@ + +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +namespace cudf { +namespace strings { + +enum class strip_type { + LEFT, ///< strip characters from the beginning of the string + RIGHT, ///< strip characters from the end of the string + BOTH ///< strip characters from the beginning and end of the string +}; + +namespace detail { + +__device__ cudf::string_view strip(cudf::string_view const d_str, + cudf::string_view const d_to_strip, + strip_type stype = strip_type::BOTH) +{ + auto is_strip_character = [d_to_strip = d_to_strip](char_utf8 chr) -> bool { + if (d_to_strip.empty()) return chr <= ' '; // whitespace check + for (auto c : d_to_strip) { + if (c == chr) return true; + } + return false; + }; + + size_type const left_offset = [&] { + if (stype != strip_type::LEFT && stype != strip_type::BOTH) return 0; + for (auto itr = d_str.begin(); itr < d_str.end(); ++itr) { + if (!is_strip_character(*itr)) return itr.byte_offset(); + } + return d_str.size_bytes(); + }(); + + size_type const right_offset = [&] { + if (stype != strip_type::RIGHT && stype != strip_type::BOTH) return d_str.size_bytes(); + for (auto itr = d_str.end(); itr > d_str.begin(); --itr) { + if (!is_strip_character(*(itr - 1))) return itr.byte_offset(); + } + return 0; + }(); + + auto const bytes = (right_offset > left_offset) ? right_offset - left_offset : 0; + return cudf::string_view{d_str.data() + left_offset, bytes}; +} + +__device__ cudf::string_view strip(cudf::string_view const d_str, + char const* to_strip, + cudf::size_type bytes, + strip_type stype = strip_type::BOTH) +{ + auto const sv = cudf::string_view{to_strip, bytes}; + return strip(d_str, sv, stype); +} + +__device__ cudf::string_view lstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) +{ + return strip(d_str, d_to_strip, strip_type::LEFT); +} + +__device__ cudf::string_view lstrip(cudf::string_view const d_str, + char const* to_strip, + cudf::size_type bytes) +{ + auto const sv = cudf::string_view{to_strip, bytes}; + return strip(d_str, sv, strip_type::LEFT); +} + +__device__ cudf::string_view rstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) +{ + return strip(d_str, d_to_strip, strip_type::RIGHT); +} + +__device__ cudf::string_view rstrip(cudf::string_view const d_str, + char const* to_strip, + cudf::size_type bytes) +{ + auto const sv = cudf::string_view{to_strip, bytes}; + return strip(d_str, sv, strip_type::RIGHT); +} + +} // namespace detail +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh new file mode 100644 index 00000000000..af5e9c16bf7 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +namespace cudf { +namespace strings { +namespace detail { + +using position_pair = struct { + size_type first, second; +}; + +/** + * @brief Instantiated for each string to manage navigating tokens from + * the beginning or the end of that string. + */ +struct whitespace_string_tokenizer { + /** + * @brief Identifies the position range of the next token in the given + * string at the specified iterator position. + * + * Tokens are delimited by one or more whitespace characters. + * + * @return true if a token has been found + */ + __device__ bool next_token() + { + if (itr != d_str.begin()) { // skip these 2 lines the first time through + ++itr; + start_position = itr.byte_offset(); // end_position + 1; + } + if (start_position >= d_str.size_bytes()) return false; + // continue search for the next token + end_position = d_str.size_bytes(); + for (; itr < d_str.end(); ++itr) { + if (spaces == (*itr <= ' ')) { + if (spaces) + start_position = (itr + 1).byte_offset(); + else + end_position = (itr + 1).byte_offset(); + continue; + } + spaces = !spaces; + if (spaces) { + end_position = itr.byte_offset(); + break; + } + } + return start_position < end_position; + } + + /** + * @brief Identifies the position range of the previous token in the given + * string at the specified iterator position. + * + * Tokens are delimited by one or more whitespace characters. + * + * @return true if a token has been found + */ + __device__ bool prev_token() + { + end_position = start_position - 1; + --itr; + if (end_position <= 0) return false; + // continue search for the next token + start_position = 0; + for (; itr >= d_str.begin(); --itr) { + if (spaces == (*itr <= ' ')) { + if (spaces) + end_position = itr.byte_offset(); + else + start_position = itr.byte_offset(); + continue; + } + spaces = !spaces; + if (spaces) { + start_position = (itr + 1).byte_offset(); + break; + } + } + return start_position < end_position; + } + + __device__ position_pair get_token() const { return position_pair{start_position, end_position}; } + + __device__ whitespace_string_tokenizer(string_view const& d_str, bool reverse = false) + : d_str{d_str}, + spaces(true), + start_position{reverse ? d_str.size_bytes() + 1 : 0}, + end_position{d_str.size_bytes()}, + itr{reverse ? d_str.end() : d_str.begin()} + { + } + + private: + string_view const d_str; + bool spaces; // true if current position is whitespace + cudf::string_view::const_iterator itr; + size_type start_position; + size_type end_position; +}; + +} // namespace detail +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh new file mode 100644 index 00000000000..efc778e156a --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include "type_traits_patch.hpp" // must be included before char_types_enum.hpp + +#include +#include +#include +#include "dstring.cuh" + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Returns true if all characters in the string are of the type specified. + * + * The output will false if the string is empty or has at least one character + * not of the specified type. If all characters fit the type then true is returned. + * + * To ignore all but specific types, set the `verify_types` to those types + * which should be checked. Otherwise, the default `ALL_TYPES` will verify all + * characters match `types`. + * + * @code{.pseudo} + * Examples: + * s = ['ab', 'a b', 'a7', 'a B'] + * all_characters_of_type('ab', LOWER) => true + * all_characters_of_type('a b', LOWER) => false + * all_characters_of_type('a7b', LOWER) => false + * all_characters_of_type('aB', LOWER) => false + * all_characters_of_type('ab', LOWER, LOWER|UPPER) => true + * all_characters_of_type('a b', LOWER, LOWER|UPPER) => true + * all_characters_of_type('a7', LOWER, LOWER|UPPER) => true + * all_characters_of_type('a B', LOWER, LOWER|UPPER) => false + * @endcode + * + * @param flags_table Table of character-type flags + * @param d_str String for this operation + * @param types The character types to check in the string + * @param verify_types Only verify against these character types. + * Default `ALL_TYPES` means return `true` + * iff all characters match `types`. + * @return True if all characters match the type conditions + */ +__device__ inline bool all_characters_of_type( + cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str, + string_character_types types, + string_character_types verify_types = string_character_types::ALL_TYPES) +{ + bool check = !d_str.empty(); // require at least one character + size_type check_count = 0; + for (auto itr = d_str.begin(); check && (itr != d_str.end()); ++itr) { + auto code_point = cudf::strings::detail::utf8_to_codepoint(*itr); + // lookup flags in table by code-point + auto flag = code_point <= 0x00FFFF ? flags_table[code_point] : 0; + if ((verify_types & flag) || // should flag be verified + (flag == 0 && verify_types == ALL_TYPES)) // special edge case + { + check = (types & flag) > 0; + ++check_count; + } + } + return check && (check_count > 0); +} + +/** + * @brief Returns true if all characters are alphabetic only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters alphabetic + */ +__device__ inline bool is_alpha(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type(flags_table, d_str, string_character_types::ALPHA); +} + +/** + * @brief Returns true if all characters are alpha-numeric only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters are alpha-numeric + */ +__device__ inline bool is_alpha_numeric( + cudf::strings::detail::character_flags_table_type* flags_table, string_view d_str) +{ + return all_characters_of_type(flags_table, d_str, string_character_types::ALPHANUM); +} + +/** + * @brief Returns true if all characters are numeric only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters are numeric + */ +__device__ inline bool is_numeric(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type(flags_table, d_str, string_character_types::NUMERIC); +} + +/** + * @brief Returns true if all characters are digits only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters are digits + */ +__device__ inline bool is_digit(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type(flags_table, d_str, string_character_types::DIGIT); +} + +/** + * @brief Returns true if all characters are decimal only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters are decimal + */ +__device__ inline bool is_decimal(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type(flags_table, d_str, string_character_types::DECIMAL); +} + +/** + * @brief Returns true if all characters are spaces only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters spaces + */ +__device__ inline bool is_space(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type(flags_table, d_str, string_character_types::SPACE); +} + +/** + * @brief Returns true if all characters are upper case only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters are upper case + */ +__device__ inline bool is_upper(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type( + flags_table, d_str, string_character_types::UPPER, string_character_types::CASE_TYPES); +} + +/** + * @brief Returns true if all characters are lower case only + * + * @param flags_table Table required for checking character types + * @param d_str Input string to check + * @return True if characters are lower case + */ +__device__ inline bool is_lower(cudf::strings::detail::character_flags_table_type* flags_table, + string_view d_str) +{ + return all_characters_of_type( + flags_table, d_str, string_character_types::LOWER, string_character_types::CASE_TYPES); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh new file mode 100644 index 00000000000..922dd68f108 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh @@ -0,0 +1,460 @@ +/* + * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "dstring.hpp" + +#include +#include + +#include +#include +#include + +namespace cudf { +namespace strings { +namespace udf { +namespace detail { + +__device__ inline static cudf::size_type bytes_in_null_terminated_string(char const* str) +{ + if (!str) return 0; + cudf::size_type bytes = 0; + while (*str++) ++bytes; + return bytes; +} + +} // namespace detail + +__device__ inline char* dstring::allocate(cudf::size_type bytes) +{ + char* data = static_cast(malloc(bytes + 1)); + data[bytes] = 0; // add null-terminator so we can printf strings in device code + return data; +} + +__device__ inline void dstring::deallocate(char* data) +{ + if (data) free(data); +} + +__device__ void dstring::reallocate(cudf::size_type bytes) +{ + m_capacity = bytes; + auto new_data = allocate(m_capacity); + memcpy(new_data, m_data, std::min(m_bytes, bytes)); + deallocate(m_data); + m_data = new_data; +} + +__device__ inline dstring::dstring(char const* data, cudf::size_type bytes) + : m_bytes(bytes), m_capacity(bytes) +{ + m_data = allocate(m_capacity); + memcpy(m_data, data, bytes); +} + +__device__ dstring::dstring(cudf::size_type count, cudf::char_utf8 chr) +{ + if (count <= 0) { return; } + m_bytes = m_capacity = cudf::strings::detail::bytes_in_char_utf8(chr) * count; + m_data = allocate(m_capacity); + auto out_ptr = m_data; + for (auto idx = 0; idx < count; ++idx) { + out_ptr += cudf::strings::detail::from_char_utf8(chr, out_ptr); + } +} + +__device__ inline dstring::dstring(char const* data) +{ + m_bytes = m_capacity = detail::bytes_in_null_terminated_string(data); + m_data = allocate(m_capacity); + memcpy(m_data, data, m_bytes); +} + +__device__ inline dstring::dstring(dstring const& src) + : m_bytes(src.m_bytes), m_capacity(src.m_bytes) +{ + m_data = allocate(m_capacity); + memcpy(m_data, src.m_data, m_bytes); +} + +__device__ inline dstring::dstring(dstring&& src) + : m_data(src.m_data), m_bytes(src.m_bytes), m_capacity(src.m_capacity) +{ + src.m_data = nullptr; + src.m_bytes = 0; + src.m_capacity = 0; +} + +__device__ inline dstring::dstring(cudf::string_view const str) + : m_bytes(str.size_bytes()), m_capacity(str.size_bytes()) +{ + m_data = allocate(m_capacity); + memcpy(m_data, str.data(), m_bytes); +} + +__device__ inline dstring::~dstring() { deallocate(m_data); } + +__device__ inline dstring& dstring::operator=(dstring const& str) { return assign(str); } + +__device__ inline dstring& dstring::operator=(dstring&& str) { return assign(std::move(str)); } + +__device__ inline dstring& dstring::operator=(cudf::string_view const str) { return assign(str); } + +__device__ inline dstring& dstring::operator=(char const* str) { return assign(str); } + +__device__ dstring& dstring::assign(dstring&& str) +{ + if (this == &str) { return *this; } + m_data = str.m_data; + m_bytes = str.m_bytes; + m_capacity = str.m_capacity; + str.m_data = nullptr; + str.m_bytes = 0; + str.m_capacity = 0; + return *this; +} + +__device__ dstring& dstring::assign(cudf::string_view const str) +{ + return assign(str.data(), str.size_bytes()); +} + +__device__ dstring& dstring::assign(char const* str) +{ + return assign(str, detail::bytes_in_null_terminated_string(str)); +} + +__device__ dstring& dstring::assign(char const* str, cudf::size_type bytes) +{ + if (bytes >= m_capacity) { + deallocate(m_data); + m_capacity = bytes; + m_data = allocate(m_capacity); + } + m_bytes = bytes; + memcpy(m_data, str, bytes); + m_data[m_bytes] = 0; + return *this; +} + +__device__ inline cudf::size_type dstring::size_bytes() const { return m_bytes; } + +__device__ inline cudf::size_type dstring::length() const +{ + return cudf::strings::detail::characters_in_string(m_data, m_bytes); +} + +__device__ cudf::size_type dstring::max_size() const +{ + return std::numeric_limits::max() - 1; +} + +__device__ inline char* dstring::data() { return m_data; } + +__device__ inline char const* dstring::data() const { return m_data; } + +__device__ inline bool dstring::is_empty() const { return m_bytes == 0; } + +__device__ inline bool dstring::is_null() const { return m_data == nullptr; } + +__device__ inline cudf::string_view::const_iterator dstring::begin() const +{ + return cudf::string_view::const_iterator(cudf::string_view(m_data, m_bytes), 0); +} + +__device__ inline cudf::string_view::const_iterator dstring::end() const +{ + return cudf::string_view::const_iterator(cudf::string_view(m_data, m_bytes), length()); +} + +__device__ inline cudf::char_utf8 dstring::at(cudf::size_type pos) const +{ + auto const offset = byte_offset(pos); + auto chr = cudf::char_utf8{0}; + if (offset < m_bytes) { cudf::strings::detail::to_char_utf8(data() + offset, chr); } + return chr; +} + +__device__ inline cudf::char_utf8 dstring::operator[](cudf::size_type pos) const { return at(pos); } + +__device__ inline cudf::size_type dstring::byte_offset(cudf::size_type pos) const +{ + cudf::size_type offset = 0; + + auto sptr = m_data; + auto eptr = sptr + m_bytes; + while ((pos > 0) && (sptr < eptr)) { + auto const byte = static_cast(*sptr++); + auto const char_bytes = cudf::strings::detail::bytes_in_utf8_byte(byte); + if (char_bytes) { --pos; } + offset += char_bytes; + } + return offset; +} + +__device__ inline int dstring::compare(cudf::string_view const in) const +{ + return compare(in.data(), in.size_bytes()); +} + +__device__ inline int dstring::compare(char const* data, cudf::size_type bytes) const +{ + auto const view = static_cast(*this); + return view.compare(data, bytes); +} + +__device__ inline bool dstring::operator==(cudf::string_view const rhs) const +{ + return m_bytes == rhs.size_bytes() && compare(rhs) == 0; +} + +__device__ inline bool dstring::operator!=(cudf::string_view const rhs) const +{ + return compare(rhs) != 0; +} + +__device__ inline bool dstring::operator<(cudf::string_view const rhs) const +{ + return compare(rhs) < 0; +} + +__device__ inline bool dstring::operator>(cudf::string_view const rhs) const +{ + return compare(rhs) > 0; +} + +__device__ inline bool dstring::operator<=(cudf::string_view const rhs) const +{ + int rc = compare(rhs); + return (rc == 0) || (rc < 0); +} + +__device__ inline bool dstring::operator>=(cudf::string_view const rhs) const +{ + int rc = compare(rhs); + return (rc == 0) || (rc > 0); +} + +__device__ inline void dstring::clear() +{ + deallocate(m_data); + m_data = nullptr; + m_bytes = 0; + m_capacity = 0; +} + +__device__ inline void dstring::resize(cudf::size_type count) +{ + if (count > max_size()) { return; } + if (count > m_capacity) { reallocate(count); } + + // add padding if necessary (null chars) + if (count > m_bytes) { memset(m_data + m_bytes, 0, count - m_bytes); } + + m_bytes = count; + m_data[m_bytes] = 0; +} + +__device__ void dstring::reserve(cudf::size_type count) +{ + if (count < max_size() && count > m_capacity) { reallocate(count); } +} + +__device__ cudf::size_type dstring::capacity() const { return m_capacity; } + +__device__ void dstring::shrink_to_fit() +{ + if (m_bytes < m_capacity) { reallocate(m_bytes); } +} + +__device__ inline dstring& dstring::append(char const* str, cudf::size_type in_bytes) +{ + if (in_bytes <= 0) { return *this; } + auto const nbytes = m_bytes + in_bytes; + if (nbytes > m_capacity) { reallocate(2 * nbytes); } + memcpy(m_data + m_bytes, str, in_bytes); + m_bytes = nbytes; + m_data[m_bytes] = 0; + return *this; +} + +__device__ inline dstring& dstring::append(char const* str) +{ + return append(str, detail::bytes_in_null_terminated_string(str)); +} + +__device__ inline dstring& dstring::append(cudf::char_utf8 chr, cudf::size_type count) +{ + if (count <= 0) { return *this; } + auto const char_bytes = cudf::strings::detail::bytes_in_char_utf8(chr) * count; + auto const nbytes = m_bytes + char_bytes; + if (nbytes > m_capacity) { reallocate(2 * nbytes); } + auto out_ptr = m_data + m_bytes; + for (auto idx = 0; idx < count; ++idx) { + out_ptr += cudf::strings::detail::from_char_utf8(chr, out_ptr); + } + m_bytes = nbytes; + m_data[m_bytes] = 0; + return *this; +} + +__device__ inline dstring& dstring::append(cudf::string_view const in) +{ + return append(in.data(), in.size_bytes()); +} + +__device__ inline dstring& dstring::operator+=(cudf::string_view const in) { return append(in); } + +__device__ inline dstring& dstring::operator+=(cudf::char_utf8 chr) { return append(chr); } + +__device__ inline dstring& dstring::operator+=(char const* str) { return append(str); } + +__device__ inline dstring& dstring::insert(cudf::size_type pos, + char const* str, + cudf::size_type in_bytes) +{ + return replace(pos, 0, str, in_bytes); +} + +__device__ inline dstring& dstring::insert(cudf::size_type pos, char const* str) +{ + return insert(pos, str, detail::bytes_in_null_terminated_string(str)); +} + +__device__ inline dstring& dstring::insert(cudf::size_type pos, cudf::string_view const in) +{ + return insert(pos, in.data(), in.size_bytes()); +} + +__device__ inline dstring& dstring::insert(cudf::size_type pos, + cudf::size_type count, + cudf::char_utf8 chr) +{ + return replace(pos, 0, count, chr); +} + +__device__ inline dstring dstring::substr(cudf::size_type pos, cudf::size_type count) const +{ + if (pos < 0) { return dstring{"", 0}; } + auto const spos = byte_offset(pos); + if (spos >= m_bytes) { return dstring{"", 0}; } + auto const epos = count < 0 ? m_bytes : std::min(byte_offset(pos + count), m_bytes); + return dstring{data() + spos, epos - spos}; +} + +// utility for replace() +__device__ void dstring::shift_bytes(cudf::size_type spos, + cudf::size_type epos, + cudf::size_type nbytes) +{ + if (nbytes < m_bytes) { + // shift bytes to the left [...wxyz] -> [wxyzxyz] + auto src = epos; + auto tgt = spos; + while (tgt < nbytes) { m_data[tgt++] = m_data[src++]; } + } else if (nbytes > m_bytes) { + // shift bytes to the right [abcd...] -> [abcabcd] + auto src = m_bytes; + auto tgt = nbytes; + while (src > epos) { m_data[--tgt] = m_data[--src]; } + } +} + +__device__ inline dstring& dstring::replace(cudf::size_type pos, + cudf::size_type count, + char const* str, + cudf::size_type in_bytes) +{ + if (pos < 0 || in_bytes < 0) { return *this; } + auto const spos = byte_offset(pos); + if (spos > m_bytes) { return *this; } + auto const epos = count < 0 ? m_bytes : std::min(byte_offset(pos + count), m_bytes); + + // compute new size + auto const nbytes = m_bytes + in_bytes - (epos - spos); + if (nbytes > m_capacity) { reallocate(2 * nbytes); } + + // move bytes -- make room for replacement + shift_bytes(spos + in_bytes, epos, nbytes); + + // insert the replacement + memcpy(m_data + spos, str, in_bytes); + + m_bytes = nbytes; + m_data[m_bytes] = 0; + return *this; +} + +__device__ inline dstring& dstring::replace(cudf::size_type pos, + cudf::size_type count, + char const* str) +{ + return replace(pos, count, str, detail::bytes_in_null_terminated_string(str)); +} + +__device__ inline dstring& dstring::replace(cudf::size_type pos, + cudf::size_type count, + cudf::string_view const in) +{ + return replace(pos, count, in.data(), in.size_bytes()); +} + +__device__ inline dstring& dstring::replace(cudf::size_type pos, + cudf::size_type count, + cudf::size_type chr_count, + cudf::char_utf8 chr) +{ + if (pos < 0 || chr_count < 0) { return *this; } + auto const spos = byte_offset(pos); + if (spos > m_bytes) { return *this; } + auto const epos = count < 0 ? m_bytes : std::min(byte_offset(pos + count), m_bytes); + + // compute input size + auto const char_bytes = cudf::strings::detail::bytes_in_char_utf8(chr) * chr_count; + // compute new output size + auto const nbytes = m_bytes + char_bytes - (epos - spos); + if (nbytes > m_capacity) { reallocate(2 * nbytes); } + + // move bytes -- make room for the new character(s) + shift_bytes(spos + char_bytes, epos, nbytes); + + // copy chr chr_count times + auto out_ptr = m_data + spos; + for (auto idx = 0; idx < chr_count; ++idx) { + out_ptr += cudf::strings::detail::from_char_utf8(chr, out_ptr); + } + + m_bytes = nbytes; + m_data[m_bytes] = 0; + return *this; +} + +__device__ dstring& dstring::erase(cudf::size_type pos, cudf::size_type count) +{ + return replace(pos, count, nullptr, 0); +} + +__device__ inline cudf::size_type dstring::char_offset(cudf::size_type bytepos) const +{ + return cudf::strings::detail::characters_in_string(data(), bytepos); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp new file mode 100644 index 00000000000..115bc6aca5c --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp @@ -0,0 +1,521 @@ +/* + * Copyright (c) 2020-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include + +namespace cudf { +namespace strings { +namespace udf { + +class dstring { + public: + /** + * @brief Represents unknown character position or length. + */ + static constexpr cudf::size_type npos = static_cast(-1); + + /** + * @brief Cast to cudf::string_view operator + */ + __device__ operator cudf::string_view() const { return cudf::string_view(m_data, m_bytes); } + + /** + * @brief Create an empty string. + */ + dstring() = default; + + /** + * @brief Create a string using existing device memory. + * + * The given memory is copied into the instance returned. + * + * @param data Device pointer to UTF-8 encoded string + * @param bytes Number of bytes in `data` + */ + __device__ dstring(char const* data, cudf::size_type bytes); + + /** + * @brief Create a string object from a null-terminated character array. + * + * The given memory is copied into the instance returned. + * + * @param data Device pointer to UTF-8 encoded null-terminated + * character array. + */ + __device__ dstring(char const* data); + + /** + * @brief Create a string object from a cudf::string_view. + * + * The input string data is copied into the instance returned. + * + * @param str String to copy + */ + __device__ dstring(cudf::string_view const str); + + /** + * @brief Create a string object with `count` copies of character `chr`. + * + * @param count Number of times to copy `chr` + * @param chr Character from which to create the string + */ + __device__ dstring(cudf::size_type count, cudf::char_utf8 chr); + + /** + * @brief Create a string object from another instance. + * + * The string data is copied from the `src` into the instance returned. + * + * @param src String to copy + */ + __device__ dstring(dstring const& src); + + /** + * @brief Create a string object from a move reference. + * + * The string data is moved from `src` into the instance returned. + * The `src` will have no content. + * + * @param src String to copy + */ + __device__ dstring(dstring&& src); + + __device__ ~dstring(); + + __device__ dstring& operator=(dstring const&); + __device__ dstring& operator=(dstring&&); + __device__ dstring& operator=(cudf::string_view const); + __device__ dstring& operator=(char const*); + + /** + * @brief Return the number of bytes in this string. + */ + __device__ cudf::size_type size_bytes() const; + + /** + * @brief Return the number of characters in this string. + */ + __device__ cudf::size_type length() const; + + /** + * @brief Return the maximum number of bytes a dstring can hold. + */ + __device__ cudf::size_type max_size() const; + + /** + * @brief Return the internal pointer to the character array for this object. + */ + __device__ char* data(); + __device__ char const* data() const; + + /** + * @brief Returns true if there are no characters in this string. + */ + __device__ bool is_empty() const; + + /** + * @brief Returns true if `data()==nullptr` + * + * This is experimental and may be removed in the futre. + */ + __device__ bool is_null() const; + + /** + * @brief Returns an iterator that can be used to navigate through + * the UTF-8 characters in this string. + * + * This returns a `cudf::string_view::const_iterator` which is read-only. + */ + __device__ cudf::string_view::const_iterator begin() const; + __device__ cudf::string_view::const_iterator end() const; + + /** + * @brief Returns the character at the specified position. + * + * This will return 0 if `pos >= length()`. + * + * @param pos Index position of character to return + * @return Character at position `pos` + */ + __device__ cudf::char_utf8 at(cudf::size_type pos) const; + + /** + * @brief Returns the character at the specified index. + * + * This will return 0 if `pos >= length()`. + * Note this is read-only. Use replace() to modify a character. + * + * @param pos Index position of character to return + * @return Character at position `pos` + */ + __device__ cudf::char_utf8 operator[](cudf::size_type pos) const; + + /** + * @brief Return the byte offset for a given character position. + * + * The byte offset for the character at `pos` such that + * `data() + byte_offset(pos)` points to the memory location + * the character at position `pos`. + * + * @param pos Index position of character to return byte offset. + * @return Byte offset for character at `pos` + */ + __device__ cudf::size_type byte_offset(cudf::size_type pos) const; + + /** + * @brief Comparing target string with this string + * + * @param str Target string to compare with this string + * @return 0 If they compare equal + * <0 Either the value of the first character of this string that does + * not match is ordered before the corresponding character in `str`, + * or all compared characters match but the `str` string is shorter. + * >0 Either the value of the first character of this string that does + * not match is ordered after the corresponding character in `str`, + * or all compared characters match but the `str` string is longer. + */ + __device__ int compare(cudf::string_view const str) const; + + /** + * @brief Comparing target character array with this string + * + * @param str Target array of UTF-8 characters. + * @param bytes Number of bytes in `str`. + * @return 0 If they compare equal + * <0 Either the value of the first character of this string that does + * not match is ordered before the corresponding character in `str`, + * or all compared characters match but `bytes < size_bytes()`. + * >0 Either the value of the first character of this string that does + * not match is ordered after the corresponding character in `str`, + * or all compared characters match but `bytes > size_bytes()`. + */ + __device__ int compare(char const* str, cudf::size_type bytes) const; + + /** + * @brief Returns true if `rhs` matches this string exactly + */ + __device__ bool operator==(cudf::string_view const rhs) const; + + /** + * @brief Returns true if `rhs` does not match this string + */ + __device__ bool operator!=(cudf::string_view const rhs) const; + + /** + * @brief Returns true if this string is ordered before `rhs` + */ + __device__ bool operator<(cudf::string_view const rhs) const; + + /** + * @brief Returns true if `rhs` is ordered before this string + */ + __device__ bool operator>(cudf::string_view const rhs) const; + + /** + * @brief Returns true if this string matches or is ordered before `rhs` + */ + __device__ bool operator<=(cudf::string_view const rhs) const; + + /** + * @brief Returns true if `rhs` matches or is ordered before this string + */ + __device__ bool operator>=(cudf::string_view const rhs) const; + + /** + * @brief Remove all bytes from this string. + * + * All pointers, references, and iterators are invalidated. + */ + __device__ void clear(); + + /** + * @brief Resizes string to contain `count` bytes. + * + * If `count > size_bytes()` then zero-padding is added. + * If `count < size_bytes()` then the string is truncated to size `count`. + * + * All pointers, references, and iterators may be invalidated. + * + * @param count Size in bytes of this string. + */ + __device__ void resize(cudf::size_type count); + + /** + * @brief Reserve `count` bytes in this string. + * + * If `count > capacity()`, new memory is allocated and `capacity()` will + * be greater than or equal to `count`. + * There is no effect if `count <= capacity()`. + * + * @param count Total number of bytes to reserve for this string + */ + __device__ void reserve(cudf::size_type count); + + /** + * @brief Returns the number of bytes that the string has allocated. + */ + __device__ cudf::size_type capacity() const; + + /** + * @brief Reduces internal allocation to just `size_bytes()`. + * + * All pointers, references, and iterators may be invalidated. + */ + __device__ void shrink_to_fit(); + + /** + * @brief Moves the contents of `str` into this string instance + * + * @param str String to move + * @return This string new contents + */ + __device__ dstring& assign(dstring&& str); + + /** + * @brief Replaces the contents of this string with contents of `str` + * + * @param str String to copy + * @return This string new contents + */ + __device__ dstring& assign(cudf::string_view const str); + + /** + * @brief Replaces the contents of this string with contents of `str` + * + * @param str Null-terminated UTF-8 character array + * @return This string new contents + */ + __device__ dstring& assign(char const* str); + + /** + * @brief Replaces the contents of this string with contents of `str` + * + * @param str UTF-8 character array + * @param bytes Number of bytes to copy from `str` + * @return This string new contents + */ + __device__ dstring& assign(char const* str, cudf::size_type bytes); + + /** + * @brief Append a string to the end of this string. + * + * @param str String to append + * @return This string with the appended argument + */ + __device__ dstring& operator+=(cudf::string_view const str); + + /** + * @brief Append a character to the end of this string. + * + * @param str Character to append + * @return This string with the appended argument + */ + __device__ dstring& operator+=(cudf::char_utf8 chr); + + /** + * @brief Append a null-terminated device memory character array + * to the end of this string. + * + * @param str String to append + * @return This string with the appended argument + */ + __device__ dstring& operator+=(char const* str); + + /** + * @brief Append a null-terminated character array to the end of this string. + * + * @param str String to append + * @return This string with the appended argument + */ + __device__ dstring& append(char const* str); + + /** + * @brief Append a character array to the end of this string. + * + * @param str Character array to append + * @param bytes Number of bytes from `str` to append. + * @return This string with the appended argument + */ + __device__ dstring& append(char const* str, cudf::size_type bytes); + + /** + * @brief Append a string to the end of this string. + * + * @param str String to append + * @return This string with the appended argument + */ + __device__ dstring& append(cudf::string_view const str); + + /** + * @brief Append a character to the end of this string + * a specified number of times. + * + * @param chr Character to append + * @param count Number of times to append `chr` + * @return This string with the append character(s) + */ + __device__ dstring& append(cudf::char_utf8 chr, cudf::size_type count = 1); + + /** + * @brief Insert a string into the character position specified. + * + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Character position to begin insert + * @param str String to insert into this one + * @return This string with the inserted argument + */ + __device__ dstring& insert(cudf::size_type pos, cudf::string_view const str); + + /** + * @brief Insert a null-terminated character array into the character position specified. + * + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Character position to begin insert + * @param data Null-terminated character array to insert + * @return This string with the inserted argument + */ + __device__ dstring& insert(cudf::size_type pos, char const* data); + + /** + * @brief Insert a character array into the character position specified. + * + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Character position to begin insert + * @param data Character array to insert + * @param bytes Number of bytes from `data` to insert + * @return This string with the inserted argument + */ + __device__ dstring& insert(cudf::size_type pos, char const* data, cudf::size_type bytes); + + /** + * @brief Insert a character one or more times into the character position specified. + * + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Character position to begin insert + * @param count Number of times to insert `chr` + * @param chr Character to insert + * @return This string with the inserted argument + */ + __device__ dstring& insert(cudf::size_type pos, cudf::size_type count, cudf::char_utf8 chr); + + /** + * @brief Returns a substring of this string. + * + * An empty string is returned if `pos < 0 or pos >= length()`. + * + * @param pos Character position to start the substring + * @param count Number of characters for the substring; + * This can be greater than the number of available characters. + * Default npos returns characters in range `[pos, length())`. + * @return New string with the specified characters + */ + __device__ dstring substr(cudf::size_type pos, cudf::size_type count = npos) const; + + /** + * @brief Replace a range of characters with a given string. + * + * Replaces characters in range `[pos, pos + count]` with `str`. + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Position of first character to replace + * @param count Number of characters to replace + * @param str String to replace the given range + * @return This string modified with the replacement + */ + __device__ dstring& replace(cudf::size_type pos, + cudf::size_type count, + cudf::string_view const str); + + /** + * @brief Replace a range of characters with a null-terminated character array. + * + * Replaces characters in range `[pos, pos + count)` with `data`. + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Position of first character to replace + * @param count Number of characters to replace + * @param data Null-terminated character array to replace the given range + * @return This string modified with the replacement + */ + __device__ dstring& replace(cudf::size_type pos, cudf::size_type count, char const* data); + + /** + * @brief Replace a range of characters with a given character array. + * + * Replaces characters in range `[pos, pos + count)` with `[data, data + bytes)`. + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Position of first character to replace + * @param count Number of characters to replace + * @param data String to replace the given range + * @param bytes Number of bytes from data to use for replacement + * @return This string modified with the replacement + */ + __device__ dstring& replace(cudf::size_type pos, + cudf::size_type count, + char const* data, + cudf::size_type bytes); + + /** + * @brief Replace a range of characters with a character one or more times. + * + * Replaces characters in range `[pos, pos + count)` with `chr` `chr_count` times. + * There is no effect if `pos < 0 or pos > length()`. + * + * @param pos Position of first character to replace + * @param count Number of characters to replace + * @param chr_count Number of times `chr` will repeated + * @param chr Character to use for replacement + * @return This string modified with the replacement + */ + __device__ dstring& replace(cudf::size_type pos, + cudf::size_type count, + cudf::size_type chr_count, + cudf::char_utf8 chr); + + /** + * @brief Removes specified characters from this string. + * + * Removes `min(count, length() - pos)` characters starting at `pos`. + * There is no effect if `pos < 0 or pos >= length()`. + * + * @param pos Character position to begin insert + * @param count Number of characters to remove starting at `pos` + * @return This string with remove characters + */ + __device__ dstring& erase(cudf::size_type pos, cudf::size_type count = npos); + + private: + char* m_data{}; + cudf::size_type m_bytes{}; + cudf::size_type m_capacity{}; + + // utilities + __device__ char* allocate(cudf::size_type bytes); + __device__ void deallocate(char* data); + __device__ void reallocate(cudf::size_type bytes); + __device__ cudf::size_type char_offset(cudf::size_type bytepos) const; + __device__ void shift_bytes(cudf::size_type spos, cudf::size_type epos, cudf::size_type nbytes); +}; + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh new file mode 100644 index 00000000000..20b7358d3e6 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh @@ -0,0 +1,67 @@ + +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include "../detail/convert/floats.cuh" +#include "../detail/convert/integers.cuh" +#include "dstring.cuh" + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Converts a string into an integer. + * + * The '+' and '-' are allowed but only at the beginning of the string. + * The string is expected to contain base-10 [0-9] characters only. + * Any other character will end the parse. + * Overflow of the int64 type is not detected. + */ +__device__ inline int64_t stoi(string_view const& d_str) +{ + return cudf::strings::detail::string_to_integer(d_str); +} + +/** + * @brief Converts an integer into string + * + * @param value integer value to convert + */ +__device__ inline dstring to_string(int64_t value) +{ + auto digits = cudf::strings::detail::count_digits(value); + dstring result; + result.resize(digits); + cudf::strings::detail::integer_to_string(value, result.data()); + return result; +} + +/** + * @brief Converts a string into a double. + * + * Support scientific notation as well. + * Overflow goes to inf or -inf and underflow may go to 0. + */ +__device__ inline double stod(string_view const& d_str) +{ + return cudf::strings::detail::stod(d_str); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh new file mode 100644 index 00000000000..2863ace6fdd --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -0,0 +1,82 @@ + +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include "dstring.cuh" + +#include + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Returns the number of times that the target string appears + * in the source string. + * + * @param source Source string to search + * @param target String to match within source + * @param start First character position within source to start the search + * @param end Last character position (exclusive) within source to search + * @return Number of matches + */ +__device__ inline cudf::size_type count(string_view const source, + string_view const target, + cudf::size_type start = 0, + cudf::size_type end = -1) +{ + auto const tgt_length = target.length(); + if (tgt_length == 0) return 0; + auto const src_length = source.length(); + + start = start < 0 ? 0 : start; + end = end < 0 || end > src_length ? src_length : end; + + cudf::size_type count = 0; + cudf::size_type pos = start; + while (pos != cudf::string_view::npos) { + pos = source.find(target, pos, end - pos); + if (pos != cudf::string_view::npos) { + count++; + pos += tgt_length; + } + } + return count; +} + +/** + * @brief Returns the number of times that the target string appears + * in the source string. + * + * @param source String to search + * @param target Null-terminated string to match within source + * @param start First character position within source to start the search + * @param end Last character position (exclusive) within source to search + * @return Number of matches + */ +__device__ inline cudf::size_type count(string_view const source, + char const* target, + cudf::size_type start = 0, + cudf::size_type end = -1) +{ + return count( + source, cudf::string_view{target, detail::bytes_in_null_terminated_string(target)}, start, end); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/split.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/split.cuh new file mode 100644 index 00000000000..4b79ecf8bb9 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/split.cuh @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "../split/split_utils.cuh" +#include "dstring.cuh" + +#include + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Split string using given string. + * + * @code{.cpp} + * auto d_str = cudf::string_view{"the best of times ", 19}; + * auto tgt = cudf::string_view{}; // empty string + * auto token_count = split(d_str, tgt, nullptr); + * auto result = new cudf::string_view[token_count]; + * split(d_str, tgt, result); + * // result is array like ["the", "best", "of", "times"] + * @endcode + * + * @param d_str String to split + * @param tgt String to split on + * @param result Empty array to populate with output objects. + * Pass `nullptr` to just get the token count. + * @return Number of tokens returned + */ +__device__ inline cudf::size_type split(cudf::string_view const d_str, + cudf::string_view const tgt, + cudf::string_view* result) +{ + auto const nchars = d_str.length(); + cudf::size_type count = 0; + + cudf::size_type last_pos = 0; + while (last_pos <= nchars) { + cudf::size_type const pos = d_str.find(tgt, last_pos); + auto const length = (pos < 0 ? nchars : pos) - last_pos; + if (result) { *result++ = d_str.substr(last_pos, length); } + last_pos = pos + tgt.length(); + ++count; + if (pos < 0) { break; } + } + + return count; +} + +/** + * @brief Split string using given target array. + * + * @param d_str String to split + * @param tgt Character array encoded in UTF-8 used for identifying split points + * @param bytes Number of bytes to read from `tgt` + * @param result Empty array to populate with output objects. + * Pass `nullptr` to just get the token count. + * @return Number of tokens returned + */ +__device__ inline int split(cudf::string_view const d_str, + char const* tgt, + cudf::size_type bytes, + cudf::string_view* result) +{ + return split(d_str, cudf::string_view{tgt, bytes}, result); +} + +/** + * @brief Split string using given target array. + * + * @param d_str String to split + * @param tgt Null-terminated character array encoded in UTF-8 used for identifying split points + * @param result Empty array to populate with output objects. + * Pass `nullptr` to just get the token count. + * @return Number of tokens returned + */ +__device__ inline int split(cudf::string_view const d_str, + char const* tgt, + cudf::string_view* result) +{ + return split(d_str, tgt, detail::bytes_in_null_terminated_string(tgt), result); +} + +/** + * @brief Split string on whitespace. + * + * This will create tokens by splitting on one or more consecutive whitespace characters + * found in `d_str`. + * + * @param d_str String to split + * @param result Empty array to populate with output objects. + * Pass `nullptr` to just get the token count. + * @return Number of tokens returned + */ +__device__ inline cudf::size_type split(cudf::string_view const d_str, cudf::string_view* result) +{ + cudf::strings::detail::whitespace_string_tokenizer tokenizer{d_str}; + cudf::size_type count = 0; + while (tokenizer.next_token()) { + auto token = tokenizer.get_token(); + if (result) { *result++ = d_str.substr(token.first, token.second - token.first); } + ++count; + } + return count; +} + +/** + * @brief Join an array of strings with a separator. + * + * @code{.cpp} + * auto separator = cudf::string_view{"::", 2}; + * cudf::string_view input[] = { + * cudf::string_view{"hello", 5}, + * cudf::string_view{"goodbye", 7}, + * cudf::string_view{"world", 5} }; + * + * auto result = join(separator, input, 3); + * // result is "hello::goodbye::world" + * @endcode + * + * @param separator Separator string + * @param input An array of strings to join + * @param count Number of elements in `input` + * @return New string + */ +__device__ inline dstring join(cudf::string_view const separator, + cudf::string_view* input, + cudf::size_type count) +{ + dstring result{""}; + while (count-- > 0) { + result += *input++; + if (count > 0) { result += separator; } + } + return result; +} + +/** + * @brief Join an array of strings with a separator. + * + * @param separator Null-terminated UTF-8 string + * @param bytes Number of bytes to read from `separator` + * @param input An array of strings to join + * @param count Number of elements in `input` + * @return New string + */ +__device__ inline dstring join(char const* separator, + cudf::size_type bytes, + cudf::string_view* input, + cudf::size_type count) +{ + return join(cudf::string_view{separator, bytes}, input, count); +} + +/** + * @brief Join an array of strings with a separator. + * + * @param separator Null-terminated UTF-8 string + * @param input An array of strings to join + * @param count Number of elements in `input` + * @return New string + */ +__device__ inline dstring join(char const* separator, + cudf::string_view* input, + cudf::size_type count) +{ + return join(separator, detail::bytes_in_null_terminated_string(separator), input, count); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh new file mode 100644 index 00000000000..c5a7f24563a --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include "dstring.cuh" + +#include + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Returns true if the beginning of the specified string + * matches the given character array. + * + * @param dstr String to check + * @param tgt Character array encoded in UTF-8 + * @param bytes Number of bytes to read from `tgt` + * @return true if `tgt` matches the beginning of `dstr` + */ +__device__ inline bool starts_with(cudf::string_view const dstr, + char const* tgt, + cudf::size_type bytes) +{ + if (bytes > dstr.size_bytes()) { return false; } + auto const start_str = cudf::string_view{dstr.data(), bytes}; + return start_str.compare(tgt, bytes) == 0; +} + +/** + * @brief Returns true if the beginning of the specified string + * matches the given character array. + * + * @param dstr String to check + * @param tgt Null-terminated character array encoded in UTF-8 + * @return true if `tgt` matches the beginning of `dstr` + */ +__device__ inline bool starts_with(cudf::string_view const dstr, char const* tgt) +{ + return starts_with(dstr, tgt, detail::bytes_in_null_terminated_string(tgt)); +} + +/** + * @brief Returns true if the beginning of the specified string + * matches the given target string. + * + * @param dstr String to check + * @param tgt String to match + * @return true if `tgt` matches the beginning of `dstr` + */ +__device__ inline bool starts_with(cudf::string_view const dstr, cudf::string_view const& tgt) +{ + return starts_with(dstr, tgt.data(), tgt.size_bytes()); +} + +/** + * @brief Returns true if the end of the specified string + * matches the given character array. + * + * @param dstr String to check + * @param tgt Character array encoded in UTF-8 + * @param bytes Number of bytes to read from `tgt` + * @return true if `tgt` matches the end of `dstr` + */ +__device__ inline bool ends_with(cudf::string_view const dstr, + char const* tgt, + cudf::size_type bytes) +{ + if (bytes > dstr.size_bytes()) { return false; } + auto const end_str = cudf::string_view{dstr.data() + dstr.size_bytes() - bytes, bytes}; + return end_str.compare(tgt, bytes) == 0; +} + +/** + * @brief Returns true if the end of the specified string + * matches the given character array. + * + * @param dstr String to check + * @param tgt Null-terminated character array encoded in UTF-8 + * @return true if `tgt` matches the end of `dstr` + */ +__device__ inline bool ends_with(cudf::string_view const dstr, char const* tgt) +{ + return ends_with(dstr, tgt, detail::bytes_in_null_terminated_string(tgt)); +} + +/** + * @brief Returns true if the end of the specified string + * matches the given target` string. + * + * @param dstr String to check + * @param tgt String to match + * @return true if `tgt` matches the end of `dstr` + */ +__device__ inline bool ends_with(cudf::string_view const dstr, cudf::string_view const& tgt) +{ + return ends_with(dstr, tgt.data(), tgt.size_bytes()); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh new file mode 100644 index 00000000000..3d2e9e4d84f --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh @@ -0,0 +1,272 @@ + +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +#include "../detail/strip_utils.cuh" +#include "dstring.cuh" + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Strip characters from the beginning and/or end of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" aba ", 5}; + * auto d_to_strip = cudf::string_view{}; // empty string + * auto result = strip(d_str, d_to_strip); + * // result is "aba" + * d_to_strip = cudf::string_view{" a", 2}; // space and 'a' + * result = strip(d_str, d_to_strip); + * // result is "b" ('a' or ' ' removed from the ends) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Characters to remove + * @param stype From where to strip the characters; + * Default `BOTH` indicates stripping characters from the + * beginning and the end of the input string `d_str` + * @return New string with characters removed + */ +__device__ dstring strip(cudf::string_view const d_str, + cudf::string_view const d_to_strip, + strip_type stype = strip_type::BOTH) +{ + return dstring{cudf::strings::detail::strip(d_str, d_to_strip, stype)}; +} + +/** + * @brief Strip characters from the beginning and/or end of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" abaa a ", 8}; + * auto result = strip(d_str, " ", 1); + * // result is "abaa a" + * result = strip(d_str, "a ", 2); // 'a' and space + * // result is "b" ('a' or ' ' removed from the ends) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Array of characters encoded in UTF-8 to remove + * @param bytes Number of bytes to read from `d_to_strip` + * @param stype From where to strip the characters; + * Default `BOTH` indicates stripping characters from the + * beginning and the end of the input string `d_str` + * @return New string with characters removed + */ +__device__ dstring strip(cudf::string_view const d_str, + char const* d_to_strip, + cudf::size_type bytes, + strip_type stype = strip_type::BOTH) +{ + auto const sv = cudf::string_view{d_to_strip, bytes}; + return strip(d_str, sv, stype); +} + +/** + * @brief Strip characters from the beginning and/or end of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" abca a ", 8}; + * auto result = strip(d_str); + * // result is "abca a" + * result = strip(d_str, "a b"); // 'a', 'b', and space + * // result is "c" ('a', ' ', or 'b' is removed from the ends) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Null-terminated array of characters encoded in UTF-8 + * to remove + * @param stype From where to strip the characters; + * Default `BOTH` indicates stripping characters from the + * beginning and the end of the input string `d_str` + * @return New string with characters removed + */ +__device__ dstring strip(cudf::string_view const d_str, + char const* d_to_strip = "", + strip_type stype = strip_type::BOTH) +{ + return strip(d_str, d_to_strip, detail::bytes_in_null_terminated_string(d_to_strip), stype); +} + +/** + * @brief Strip characters from the beginning of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" aba ", 5}; + * auto d_to_strip = cudf::string_view{}; // empty string + * auto result = lstrip(d_str, d_to_strip); + * // result is "aba " + * d_to_strip = cudf::string_view{"a ", 2}; // space and 'a' + * result = lstrip(d_str, d_to_strip); + * // result is "ba " ('a' or ' ' removed from the beginning) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Characters to remove + * @return New string with characters removed + */ +__device__ dstring lstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) +{ + return strip(d_str, d_to_strip, strip_type::LEFT); +} + +/** + * @brief Strip characters from the beginning of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" abaa a ", 8}; + * auto result = lstrip(d_str, " ", 1); + * // result is "abaa a " + * result = lstrip(d_str, "a ", 2); // 'a' and space + * // result is "baa a " ('a' or ' ' removed from the beginning) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Array of characters encoded in UTF-8 to remove + * @param bytes Number of bytes to read from `d_to_strip` + * @return New string with characters removed + */ +__device__ dstring lstrip(cudf::string_view const d_str, + char const* d_to_strip, + cudf::size_type bytes) +{ + auto const sv = cudf::string_view{d_to_strip, bytes}; + return strip(d_str, sv, strip_type::LEFT); +} + +/** + * @brief Strip characters from the beginning of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" abca a ", 8}; + * auto result = lstrip(d_str); + * // result is "abca a " + * result = lstrip(d_str, "a b"); // 'a', 'b', and space + * // result is "ca a " ('a', ' ', or 'b' removed from the beginning) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Null-terminated array of characters encoded in UTF-8 + * to remove + * @return New string with characters removed + */ +__device__ dstring lstrip(cudf::string_view const d_str, char const* d_to_strip = "") +{ + return strip( + d_str, d_to_strip, detail::bytes_in_null_terminated_string(d_to_strip), strip_type::LEFT); +} + +/** + * @brief Strip characters from the end of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" aba ", 5}; + * auto d_to_strip = cudf::string_view{}; // empty string + * auto result = rstrip(d_str, d_to_strip); + * // result is " aba" + * d_to_strip = cudf::string_view{" a", 2}; // space and 'a' + * result = rstrip(d_str, d_to_strip); + * // result is " ab" ('a' or ' ' removed from the end) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Characters to remove + * @return New string with characters removed + */ +__device__ dstring rstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) +{ + return strip(d_str, d_to_strip, strip_type::RIGHT); +} + +/** + * @brief Strip characters from the end of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" abaa a ", 8}; + * auto result = rstrip(d_str, " ", 1); + * // result is " abaa a" + * result = rstrip(d_str, " a", 2); // 'a' and space + * // result is " ab" ('a' or ' ' removed from the end) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Array of characters encoded in UTF-8 to remove + * @param bytes Number of bytes to read from `d_to_strip` + * @return New string with characters removed + */ +__device__ dstring rstrip(cudf::string_view const d_str, + char const* d_to_strip, + cudf::size_type bytes) +{ + auto const sv = cudf::string_view{d_to_strip, bytes}; + return strip(d_str, sv, strip_type::RIGHT); +} + +/** + * @brief Strip characters from the end of the given string. + * + * The `d_to_strip` is interpretted as an array of characters to be removed. + * If `d_to_strip` is an empty string, whitespace characters are stripped. + * + * @code{.cpp} + * auto d_str = cudf::string_view{" acba a ", 8}; + * auto result = rstrip(d_str); + * // result is " acba a" + * result = rstrip(d_str, "a b"); // 'a', 'b', and space + * // result is " ac" ('a', ' ', or 'b' removed from the end) + * @endcode + * + * @param d_str String to strip characters from + * @param d_to_strip Null-terminated array of characters encoded in UTF-8 + * to remove + * @return New string with characters removed + */ +__device__ dstring rstrip(cudf::string_view const d_str, char const* d_to_strip = "") +{ + return strip( + d_str, d_to_strip, detail::bytes_in_null_terminated_string(d_to_strip), strip_type::RIGHT); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp new file mode 100644 index 00000000000..9d274d09691 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +// Patch for the that is setup by jitify.hpp. +// The source below supports the std::underlying_type_t which is +// missing from the jitify.hpp implementation of + +#ifdef CUDF_JIT_UDF + +namespace std { +/// integral_constant +// the 'udf' prefix prevents collision with jitify.hpp definition +// which is incompatible with how is-enum and underlying_type needs +template +struct udf_integral_constant { + static constexpr _Tp value = __v; + typedef _Tp value_type; + typedef udf_integral_constant<_Tp, __v> type; + constexpr operator value_type() const noexcept { return value; } + constexpr value_type operator()() const noexcept { return value; } +}; +template +constexpr _Tp udf_integral_constant<_Tp, __v>::value; + +/// is_enum +template +struct is_enum : public udf_integral_constant { +}; + +template ::value> +struct __underlying_type_impl { + using type = __underlying_type(_Tp); +}; + +template +struct __underlying_type_impl<_Tp, false> { +}; + +/// The underlying type of an enum. +template +struct underlying_type : public __underlying_type_impl<_Tp> { +}; + +/// Alias template for underlying_type +template +using underlying_type_t = typename underlying_type<_Tp>::type; +} // namespace std + +#endif \ No newline at end of file diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp new file mode 100644 index 00000000000..ec4522d8962 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +#include + +#include +#include +#include + +// somewhat iffy forward reference +namespace jitify { +class Program; +} + +/** + * @brief Module instance returned by create_udf_module + */ +struct udf_module { + jitify::Program *program{}; + udf_module(jitify::Program *p) : program(p) {} + ~udf_module(); +}; + +/** + * @brief Build UDF module with kernel source and compile options. + * + * @param udf String containing kernel source code + * @param options Compile options for the jitify compiler + * @return udf module to pass to `call_udf` + */ +std::unique_ptr create_udf_module(std::string const &udf, + std::vector const &options); + +/** + * @brief Launch kernel named `udf_name` in UDF module. + * + * @param udf Returned from `create_udf_module` + * @param udf_name Name of global device function to execute in UDF module + * @param output_size Output strings column size. + * Also used to computing the thread block size. + * @param input libcudf columns to pass to the kernel + * @param heap_size Size in bytes to reserve for device-side malloc. + * @return New libcudf strings column created by the kernel logic. + */ +std::unique_ptr call_udf(udf_module const &udf, + std::string const &udf_name, + cudf::size_type output_size, + std::vector input, + size_t heap_size = 1073741824); + +/** + * @brief Return a cudf::string_view array for the given strings column + * + * @throw cudf::logic_error if input is not a strings column. + */ +std::unique_ptr to_string_view_array(cudf::column_view const input); + +/** + * @brief Return a cudf::column given an array of dstring objects. + * + * @param d_buffer Pointer to device memory of dstring objects + * @param d_size The number of bytes in the d_buffer + * @return A strings column copy of the dstring objects + */ +std::unique_ptr from_dstring_array(void *d_buffer, std::size_t size); + diff --git a/python/strings_udf/cpp/sample_udfs/copy.udf b/python/strings_udf/cpp/sample_udfs/copy.udf new file mode 100644 index 00000000000..1bbf5743f18 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/copy.udf @@ -0,0 +1,16 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +// This illustrates a simple copy of the input. +// The input string_view object is converted to a dstring and returned. + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid < count ) + { + d_out_strs[tid] = d_in_strs[tid]; + } +} diff --git a/python/strings_udf/cpp/sample_udfs/example.txt b/python/strings_udf/cpp/sample_udfs/example.txt new file mode 100644 index 00000000000..37e10de75b9 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/example.txt @@ -0,0 +1,5 @@ +Example text: +"Pears £12" +"Plums $34" +"Temp 72℉" +"100K℧" diff --git a/python/strings_udf/cpp/sample_udfs/example.xml b/python/strings_udf/cpp/sample_udfs/example.xml new file mode 100644 index 00000000000..f8a0e2d42fd --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/example.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/python/strings_udf/cpp/sample_udfs/filter.udf b/python/strings_udf/cpp/sample_udfs/filter.udf new file mode 100644 index 00000000000..1cd781c9bb1 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/filter.udf @@ -0,0 +1,42 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +// +// Example text: +// "pears £12" +// "plums $34" +// "Temp 72℉" +// "100K℧" +// +// Output from this udf: +// "pears 12" +// "plums 34" +// "Temp 72 " +// "100K " +// + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid >= count ) return; + + cudf::string_view str = d_in_strs[tid]; + char const* sptr = str.data(); + char const* eptr = sptr + str.size_bytes(); + + cudf::strings::udf::dstring out; + while( sptr < eptr ) + { + char ch = *sptr++; + if( ((ch < '0') || (ch > 'z')) || + ((ch > '9') && (ch < 'A')) || + ((ch > 'Z') && (ch < 'a')) ) + out.append(' '); + else + out.append(ch); + } + d_out_strs[tid] = out; +} + diff --git a/python/strings_udf/cpp/sample_udfs/integers.udf b/python/strings_udf/cpp/sample_udfs/integers.udf new file mode 100644 index 00000000000..bd9018da99f --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/integers.udf @@ -0,0 +1,19 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +using dstring = cudf::strings::udf::dstring; + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid < count ) + { + auto input = d_in_strs[tid]; + auto end = input.substr( input.length()-2, 2 ); + auto value = cudf::strings::udf::stoi(end); + dstring out = cudf::strings::udf::to_string(value); + d_out_strs[tid] = out; + } +} diff --git a/python/strings_udf/cpp/sample_udfs/join.udf b/python/strings_udf/cpp/sample_udfs/join.udf new file mode 100644 index 00000000000..8cc68f3a575 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/join.udf @@ -0,0 +1,34 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +// +// Example input string: +// "peaches 12" +// +// Splits on ' ' space to get array like: +// ['peaches', '12'] +// +// Joins with ':::' to get a final string: +// "peaches:::12" +// + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid >= count ) return; + + cudf::string_view str = d_in_strs[tid]; + cudf::string_view entries[2]; // 2 is the max split for the example + + // split on whitespace + auto splits = cudf::strings::udf::split( str, entries ); + + // join with new separator + cudf::string_view separator(":::", 3); + auto out = cudf::strings::udf::join(separator, entries, splits); + + d_out_strs[tid] = out; +} + diff --git a/python/strings_udf/cpp/sample_udfs/lower.udf b/python/strings_udf/cpp/sample_udfs/lower.udf new file mode 100644 index 00000000000..fe558ee2ac5 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/lower.udf @@ -0,0 +1,49 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +using dstring = cudf::strings::udf::dstring; + +// supports lower-case conversion for ASCII characters only +__device__ dstring to_lower_a(cudf::string_view const d_str) +{ + dstring result = d_str; + // ASCII case conversion can be done in-place + auto ptr = result.data(); + auto end = ptr + result.size_bytes(); + while( ptr < end ) { + auto chr = *ptr; + if( chr >= 'A' && chr <= 'Z' ) + chr = chr + 32; // lower-case in the ASCII table + *ptr++ = chr; + } + return result; +} + +// supports upper-case conversion for ASCII characters only +__device__ dstring to_upper_a(cudf::string_view const d_str) +{ + dstring result = d_str; + // ASCII case conversion can be done in-place + auto ptr = result.data(); + auto end = ptr + result.size_bytes(); + while( ptr < end ) { + auto chr = *ptr; + if( chr >= 'a' && chr <= 'z' ) + chr = chr - 32; // upper-case in the ASCII table + *ptr++ = chr; + } + return result; +} + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid < count ) + { + dstring out = to_lower_a(d_in_strs[tid]); + // dstring out = to_upper_a(d_in_strs[tid]); + d_out_strs[tid] = out; + } +} diff --git a/python/strings_udf/cpp/sample_udfs/print.udf b/python/strings_udf/cpp/sample_udfs/print.udf new file mode 100644 index 00000000000..0bf2c696d7f --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/print.udf @@ -0,0 +1,17 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +using dstring = cudf::strings::udf::dstring; + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid < count ) + { + dstring str = d_in_strs[tid]; + printf("%d:[%s]\n", tid, str.data()); + d_out_strs[tid] = str; + } +} diff --git a/python/strings_udf/cpp/sample_udfs/split.udf b/python/strings_udf/cpp/sample_udfs/split.udf new file mode 100644 index 00000000000..a27166265e0 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/split.udf @@ -0,0 +1,47 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +// +// Example input string: +// +// +// Splits on ' ' space to get array like: +// [''] +// +// Splits each try on '=' to find the one with 'name': +// ['name', '"Ted"'] +// +// Finally, splits the value to remove the double-quotes: +// ['"', 'Ted', '"'] --> output is element 1 +// + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid >= count ) return; + + cudf::string_view str = d_in_strs[tid]; + cudf::string_view entries[5]; // 5 is the max split for the example + + // first, split on whitespace + auto splits = cudf::strings::udf::split( str, entries ); + + cudf::strings::udf::dstring out{""}; // empty if name is not found + + cudf::string_view name("name", 4); + for( int idx=1; idx < splits; ++idx ) { + cudf::string_view attrs[2]; // looking for 'name="value"' + cudf::strings::udf::split( entries[idx], "=", attrs ); + if( attrs[0] == name ) { + // extract value from the double-quotes + cudf::string_view values[3]; + cudf::strings::udf::split( attrs[1], "\"", values ); + out = values[1]; // actual name is entry 1 + } + } + + d_out_strs[tid] = out; +} + diff --git a/python/strings_udf/cpp/sample_udfs/starts_with.udf b/python/strings_udf/cpp/sample_udfs/starts_with.udf new file mode 100644 index 00000000000..09a4e424261 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/starts_with.udf @@ -0,0 +1,21 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid < count ) + { + auto const d_str = d_in_strs[tid]; + cudf::strings::udf::dstring d_out = d_str; + if( cudf::strings::udf::ends_with(d_str, "/>") ) + d_out += " <------- entry"; + else if( cudf::strings::udf::ends_with(d_str, "/>") ) + d_out += " <------- last entry"; + if( cudf::strings::udf::starts_with(d_str, " + +using dstring = cudf::strings::udf::dstring; + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid < count ) + { + dstring out = cudf::strings::udf::strip(d_in_strs[tid]); + out.insert(0,"["); + out.append("]"); + d_out_strs[tid] = out; + } +} diff --git a/python/strings_udf/cpp/sample_udfs/xml.udf b/python/strings_udf/cpp/sample_udfs/xml.udf new file mode 100644 index 00000000000..52fdb5112d3 --- /dev/null +++ b/python/strings_udf/cpp/sample_udfs/xml.udf @@ -0,0 +1,29 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +__device__ cudf::string_view find_attr( cudf::string_view const& input, + cudf::string_view const& name ) +{ + auto pos = input.find(name); + if( pos < 0 ) return cudf::string_view{"",0}; + + cudf::string_view quote("\"",1); + auto begin = input.find(quote, pos) + 1; + auto end = input.find(quote, begin); + + return input.substr(begin, end-begin); +} + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid >= count ) return; + + auto input_str = d_in_strs[tid]; + + auto name = find_attr(input_str, cudf::string_view("name",4)); + + d_out_strs[tid] = name; // makes a copy here +} diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu new file mode 100644 index 00000000000..9d5cd6684c1 --- /dev/null +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +using namespace cudf::strings::udf; + +/* +len +*/ + +extern "C" +__device__ int len(int* nb_retval, void* str) { + cudf::string_view* sv = reinterpret_cast(str); + *nb_retval = sv->length(); + return 0; +} + + +/* +startswith +*/ + +extern "C" +__device__ int startswith(bool* nb_retval, void* str, void* substr) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = starts_with(*str_view, *substr_view); + return 0; +} + +extern "C" +__device__ int endswith(bool* nb_retval, void* str, void* substr) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = ends_with(*str_view, *substr_view); + return 0; +} + +/* +contains +*/ + +extern "C" +__device__ int contains(bool* nb_retval, void* str, void* substr) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = (str_view->find(*substr_view) != cudf::string_view::npos); + return 0; +} + +/* +find +*/ +extern "C" +__device__ int find(int* nb_retval, void* str, void* substr) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = str_view->find(*substr_view); + return 0; +} + +/* +rfind +*/ +extern "C" +__device__ int rfind(int* nb_retval, void* str, void* substr) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = str_view->rfind(*substr_view); + return 0; +} + +/* +== +*/ + +extern "C" +__device__ int eq(bool* nb_retval, void* str, void* rhs) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); + + *nb_retval = (*str_view == *rhs_view); + return 0; +} + +/* +!= +*/ + +extern "C" +__device__ int ne(bool* nb_retval, void* str, void* rhs) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); + + *nb_retval = (*str_view != *rhs_view); + return 0; +} + +/* +>= +*/ + +extern "C" +__device__ int ge(bool* nb_retval, void* str, void* rhs) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); + + *nb_retval = (*str_view >= *rhs_view); + return 0; +} + +/* +<= +*/ + +extern "C" +__device__ int le(bool* nb_retval, void* str, void* rhs) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); + + *nb_retval = (*str_view <= *rhs_view); + return 0; +} + +/* +> +*/ + +extern "C" +__device__ int gt(bool* nb_retval, void* str, void* rhs) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); + + *nb_retval = (*str_view > *rhs_view); + return 0; +} + +/* +< +*/ + +extern "C" +__device__ int lt(bool* nb_retval, void* str, void* rhs) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); + + *nb_retval = (*str_view < *rhs_view); + return 0; +} + +/* +islower +*/ + +extern "C" +__device__ int pyislower(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_lower(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +isupper +*/ + +extern "C" +__device__ int pyisupper(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_upper(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +isspace +*/ + +extern "C" +__device__ int pyisspace(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_space(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +isdecimal +*/ + +extern "C" +__device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_decimal(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +isnumeric +*/ + +extern "C" +__device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_numeric(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +isdigit +*/ + +extern "C" +__device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_digit(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +isalnum +*/ + +extern "C" +__device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_alpha_numeric(reinterpret_cast(chars_table), *str_view); + return 0; +} + +/* +count +*/ + +extern "C" +__device__ int pycount(int* nb_retval, void* str, void* substr) { + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = count(*str_view, *substr_view); + return 0; +} diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu new file mode 100644 index 00000000000..7189557ec42 --- /dev/null +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "jitify.hpp" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +namespace { + +rmm::device_buffer create_dstring_array(cudf::size_type size, rmm::cuda_stream_view stream) +{ + auto const output_vector_size = size * sizeof(cudf::strings::udf::dstring); + rmm::device_buffer result(output_vector_size, stream); + cudaMemset(result.data(), 0, output_vector_size); + return result; +} + +struct free_dstring_fn { + cudf::strings::udf::dstring *d_strings; + __device__ void operator()(cudf::size_type idx) { d_strings[idx].clear(); } +}; + +void free_dstring_array(void *d_buffer, std::size_t buffer_size, rmm::cuda_stream_view stream) +{ + auto const size = static_cast(buffer_size / sizeof(cudf::strings::udf::dstring)); + auto d_strings = reinterpret_cast(d_buffer); + thrust::for_each_n( + rmm::exec_policy(stream), thrust::make_counting_iterator(0), size, free_dstring_fn{d_strings}); +} + +void set_malloc_heap_size(size_t heap_size) +{ + size_t max_malloc_heap_size = 0; + cudaDeviceGetLimit(&max_malloc_heap_size, cudaLimitMallocHeapSize); + if (max_malloc_heap_size < heap_size) { + max_malloc_heap_size = heap_size; + if (cudaDeviceSetLimit(cudaLimitMallocHeapSize, max_malloc_heap_size) != cudaSuccess) { + fprintf(stderr, "could not set malloc heap size to %ldMB\n", (heap_size / (1024 * 1024))); + throw std::runtime_error(""); + } + } +} + +struct dstring_to_string_view_transform_fn { + __device__ cudf::string_view operator()(cudf::strings::udf::dstring const &dstr) + { + return cudf::string_view{dstr.data(), dstr.size_bytes()}; + } +}; + +} // namespace + +static jitify::JitCache kernel_cache; + +std::unique_ptr create_udf_module(std::string const &udf_code, + std::vector const &options) +{ + std::vector jitify_options; + jitify_options.push_back("-std=c++17"); + jitify_options.push_back("-DCUDF_JIT_UDF"); + jitify_options.push_back("-I../include"); + jitify_options.push_back("-I../cpp/include"); + std::copy(options.begin(), options.end(), std::back_inserter(jitify_options)); + // nvrtc did not recognize --expt-relaxed-constexpr + // also it has trouble including thrust headers + + try { + auto program = kernel_cache.program(udf_code.c_str(), 0, jitify_options); + return std::make_unique(new jitify::Program(std::move(program))); + } catch (std::runtime_error &exc) { + return nullptr; + } +} + +udf_module::~udf_module() { delete program; } + +namespace { + +using column_span = std::pair; + +struct udf_data_fn { + cudf::column_view const input; + + template ()> * = nullptr> + column_span operator()(std::vector> &) + { + return std::make_pair((void *)input.data(), input.size()); + } + + template > * = nullptr> + column_span operator()(std::vector> &strings_vectors) + { + auto sv = + cudf::strings::detail::create_string_vector_from_column(cudf::strings_column_view(input)); + strings_vectors.emplace_back(std::move(sv)); + auto const &sv_ref = strings_vectors.back(); + return std::make_pair((void *)sv_ref.data(), (cudf::size_type)sv_ref.size()); + } + + template ::value and + !cudf::is_fixed_width()> * = nullptr> + column_span operator()(std::vector> &) + { + return column_span{nullptr, 0}; // throw error here? + } +}; + +std::unique_ptr to_string_view_array(cudf::column_view const input, + rmm::cuda_stream_view stream) +{ + return std::make_unique( + std::move(cudf::strings::detail::create_string_vector_from_column( + cudf::strings_column_view(input), stream) + .release())); +} + +std::unique_ptr from_dstring_array(void *d_buffer, + std::size_t buffer_size, + rmm::cuda_stream_view stream) +{ + auto const size = static_cast(buffer_size / sizeof(cudf::strings::udf::dstring)); + auto d_input = reinterpret_cast(d_buffer); + + // create string_views of the dstrings + auto indices = rmm::device_uvector(size, stream); + thrust::transform(rmm::exec_policy(stream), + d_input, + d_input + size, + indices.data(), + dstring_to_string_view_transform_fn{}); + + auto results = cudf::make_strings_column(indices, cudf::string_view(nullptr, 0), stream); + + // free the individual dstring elements + free_dstring_array(d_buffer, buffer_size, stream); + + // return new column + return results; +} + +template +void set_global_variables(KernelType &kernel) +{ + try { + // set global variable data needed for the is-char-type functions + if (kernel.get_global_ptr("cudf::strings::udf::g_character_flags_table")) { + auto flags_table = cudf::strings::detail::get_character_flags_table(); + kernel.set_global_array("cudf::strings::udf::g_character_flags_table", &flags_table, 1); + } + } catch (...) { + // this global variable is optional + } + try { + // set global variable data needed for upper/lower functions + if (kernel.get_global_ptr("cudf::strings::udf::g_character_cases_table")) { + auto cases_table = cudf::strings::detail::get_character_cases_table(); + kernel.set_global_array("cudf::strings::udf::g_character_cases_table", &cases_table, 1); + } + if (kernel.get_global_ptr("cudf::strings::udf::g_special_case_mapping_table")) { + auto special_cases_table = cudf::strings::detail::get_special_case_mapping_table(); + kernel.set_global_array( + "cudf::strings::udf::g_special_case_mapping_table", &special_cases_table, 1); + } + } catch (...) { + // these global variables are optional + } +} + +} // namespace + +std::unique_ptr call_udf(udf_module const &udf, + std::string const &udf_name, + cudf::size_type output_size, + std::vector input, + size_t heap_size) +{ + set_malloc_heap_size(heap_size); + + rmm::cuda_stream_view stream = rmm::cuda_stream_default; + + // setup kernel parameters + std::vector> strings_vectors; // for strings columns + std::vector args; // holds column pointers and sizes; + jitify::detail::vector arg_types; // this parameter is not strictly required + // create args for each input column + for (int col = 0; col < (int)input.size(); ++col) { + column_span data = cudf::type_dispatcher( + input[col].type(), udf_data_fn{input[col]}, strings_vectors); + args.push_back(data.first); + arg_types.push_back(jitify::reflection::reflect()); + args.push_back((void *)(long)data.second); + arg_types.push_back(jitify::reflection::reflect()); + } + // transform required because jit launch() args are expected to be pointers to pointers + std::vector jitargs; + std::transform( + args.begin(), args.end(), std::back_inserter(jitargs), [](auto &pv) { return &pv; }); + + // allocate an output array + rmm::device_buffer output = create_dstring_array(output_size, stream); + + // add the output strings column parameter + void *d_out = output.data(); + jitargs.push_back(&d_out); + arg_types.push_back(jitify::reflection::reflect()); + // add the kernel thread count parameter + jitargs.push_back(reinterpret_cast(&output_size)); + arg_types.push_back(jitify::reflection::reflect()); + + // setup kernel launch parameters + auto const num_blocks = ((output_size - 1) / 128) + 1; + dim3 grid(num_blocks); + dim3 block(128); + + jitify::Program *pp = udf.program; + auto kernel = pp->kernel(udf_name.c_str()).instantiate(); + set_global_variables(kernel); + auto launcher = kernel.configure(grid, block); + // launch the kernel passing the parameters + CUresult result = launcher.launch(jitargs, arg_types); + if (result) { + const char *result_str = "ok"; + cuGetErrorName(result, &result_str); + fprintf(stderr, "launch result = %d [%s]\n", (int)result, result_str); + } + auto const err = cudaDeviceSynchronize(); + if (err) { fprintf(stderr, "%s=(%d) ", udf_name.c_str(), (int)err); } + + // convert the output array into a strings column + // this also frees the individual dstring objects + return from_dstring_array(output.data(), output.size(), stream); +} + +std::unique_ptr to_string_view_array(cudf::column_view const input) +{ + return to_string_view_array(input, rmm::cuda_stream_default); +} + +std::unique_ptr from_dstring_array(void *d_buffer, std::size_t buffer_size) +{ + return from_dstring_array(d_buffer, buffer_size, rmm::cuda_stream_default); +} diff --git a/python/strings_udf/cpp/src/strings/udf/udf_cli.cpp b/python/strings_udf/cpp/src/strings/udf/udf_cli.cpp new file mode 100644 index 00000000000..02422a57abb --- /dev/null +++ b/python/strings_udf/cpp/src/strings/udf/udf_cli.cpp @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +double GetTime() +{ + timeval tv; + gettimeofday(&tv, NULL); + return (double)(tv.tv_sec * 1000000 + tv.tv_usec) / 1000000.0; +} + +std::string load_udf(std::ifstream &input) +{ + std::stringstream udf; + std::string line; + while (std::getline(input, line)) udf << line << "\n"; + return udf.str(); +} + +void print_column(cudf::strings_column_view const &input) +{ + if (input.chars_size() == 0) { + printf("empty\n"); + return; + } + + auto offsets = input.offsets(); + std::vector h_offsets(offsets.size()); + auto chars = input.chars(); + std::vector h_chars(chars.size()); + cudaMemcpy(h_offsets.data(), + offsets.data(), + offsets.size() * sizeof(int32_t), + cudaMemcpyDeviceToHost); + cudaMemcpy(h_chars.data(), chars.data(), chars.size(), cudaMemcpyDeviceToHost); + + for (int idx = 0; idx < input.size(); ++idx) { + int offset = h_offsets[idx]; + const char *str = h_chars.data() + offset; + int length = h_offsets[idx + 1] - offset; + std::string output(str, length); + std::cout << output << "\n"; + } +} + +std::map parse_cli_parms(int argc, const char **argv) +{ + std::map parms; + while (argc > 1) { + const char *value = argv[argc - 1]; + const char *key = (argv[argc - 2]) + 1; + parms[key] = value; + argc -= 2; + } + return parms; +} + +int main(int argc, const char **argv) +{ + if (argc < 3) { + printf("parameters:\n"); + printf("-u UDF text file\n"); + printf("-n kernel name (default is 'udf_kernel')\n"); + printf("-i libcudf include dir (default is $CONDA_PREFIX/include)\n"); + printf("-t text/csv file\n"); + printf("-c 0-based column number if csv file (default is 0=first column)\n"); + printf("-r number of rows to read from file (default is 0=entire file)\n"); + printf("-f output file (default is stdout)\n"); + printf("-m malloc heap size (default is 1GB)\n"); + return 0; + } + + std::map parms = parse_cli_parms(argc, argv); + + std::string const udf_text = parms["u"]; + std::string const csv_file = parms["t"]; + if (udf_text.empty() || csv_file.empty()) { + printf("UDF file (-u) and text file (-t) are required parameters.\n"); + return 0; + } + + std::string const cudf_include = [parms] { + if (parms.find("i") != parms.end()) return parms.at("i"); + std::string conda_prefix = + std::getenv("CONDA_PREFIX") ? std::getenv("CONDA_PREFIX") : "/conda/envs/rapids"; + return conda_prefix + "/include"; + }(); + + std::string const udf_name = parms.find("n") != parms.end() ? parms["n"] : "udf_kernel"; + + int const column = parms.find("c") != parms.end() ? std::atoi(parms["c"].c_str()) : 0; + int const rows = parms.find("r") != parms.end() ? std::atoi(parms["r"].c_str()) : 0; + auto const verbose = parms.find("v") != parms.end(); + size_t const heap_size = + (parms.find("m") != parms.end() ? std::atoi(parms["m"].c_str()) : 1024) * 1024 * 1024; + + // load the udf source code + std::ifstream udf_stream(udf_text); + if (!udf_stream.is_open()) { + printf("could not open file [%s]\n", udf_text.c_str()); + return 0; + } + std::string udf_code = load_udf(udf_stream); + // adding the filename to the top of the source code + // helps with jitify displaying compile errors + udf_code = udf_text + "\n" + udf_code; + + // load the text file using the CSV reader + double st_load_data = GetTime(); + cudf::io::csv_reader_options in_opts = + cudf::io::csv_reader_options::builder(cudf::io::source_info{csv_file}).header(-1); + in_opts.set_use_cols_indexes({column}); + if (rows > 0) in_opts.set_nrows(rows); + in_opts.set_dtypes({cudf::data_type{cudf::type_id::STRING}}); + auto csv_result = cudf::io::read_csv(in_opts); + auto input = cudf::strings_column_view(csv_result.tbl->view().column(0)); + + double et_load_data = GetTime() - st_load_data; + if (verbose) fprintf(stderr, "Load data: %g seconds\n", et_load_data); + + auto const strings_count = input.size(); + if (verbose) fprintf(stderr, "input strings count = %d\n", strings_count); + + // create UDF module + std::vector options; + options.push_back("-I" + cudf_include); + double st_compile = GetTime(); + auto module = create_udf_module(udf_code, options); + double et_compile = GetTime() - st_compile; + if (module == nullptr || module->program == nullptr) { + printf("compile error\n"); + return 0; + } + if (verbose) fprintf(stderr, "Compile UDF: %g seconds\n", et_compile); + + // run UDF module + double st_run = GetTime(); + auto results = call_udf(*module, udf_name, strings_count, {input.parent()}, heap_size); + double et_run = GetTime() - st_run; + if (verbose) fprintf(stderr, "Run UDF: %g seconds\n", et_run); + + auto scv = cudf::strings_column_view(results->view()); + // output results + std::string out_filename = parms["f"]; + if (out_filename.empty()) { + print_column(scv); + return 0; + } + + // write csv file + double st_output_data = GetTime(); + auto output_table = cudf::table_view{std::vector{results->view()}}; + cudf::io::sink_info const sink{out_filename}; + cudf::io::csv_writer_options writer_options = + cudf::io::csv_writer_options::builder(sink, output_table).include_header(false); + cudf::io::write_csv(writer_options); + double et_output_data = GetTime() - st_output_data; + + if (verbose) fprintf(stderr, "Output to file: %g seconds\n", et_output_data); + + return 0; +} diff --git a/python/strings_udf/cpp/tests/append.udf b/python/strings_udf/cpp/tests/append.udf new file mode 100644 index 00000000000..1159a145bc1 --- /dev/null +++ b/python/strings_udf/cpp/tests/append.udf @@ -0,0 +1,45 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const hello = cudf::string_view{"hello", 5}; + auto const hello_space = cudf::string_view{"hello ", 6}; + auto const world = cudf::string_view{"world", 5}; + auto const hello_world = cudf::string_view{"hello world", 11}; + + dstring d_str; + + d_str.append("hello"); + verify(d_str, hello, "append(char*)"); + + d_str.append(' '); + verify(d_str, hello_space, "append(char)"); + + d_str.append(world); + verify(d_str, hello_world, "append(string_view)"); + + d_str.append(" goodbye", 5); + verify(d_str, cudf::string_view{"hello world good", 16}, "append(char*,size)"); + + d_str.clear(); + + d_str += "hello"; + verify(d_str, hello, "operator+=(char*)"); + + d_str += ' '; + verify(d_str, hello_space, "operator+=(char)"); + + d_str += world; + verify(d_str, hello_world, "operator+=(string_view)"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/char_types.udf b/python/strings_udf/cpp/tests/char_types.udf new file mode 100644 index 00000000000..bd73c6cbe7e --- /dev/null +++ b/python/strings_udf/cpp/tests/char_types.udf @@ -0,0 +1,59 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +namespace cudf::strings::udf { +// global variable with character-type flags +__device__ cudf::strings::detail::character_flags_table_type* g_character_flags_table; +} + +using namespace cudf::strings; + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + auto const alpha = cudf::string_view{"Hello", 5}; + auto const alpha_num = cudf::string_view{"Hello123", 8}; + auto const numeric = cudf::string_view{"17¼", 4}; + auto const digit = cudf::string_view{"2³", 3}; + auto const decimal = cudf::string_view{"156789", 6}; + auto const space = cudf::string_view{" \t\n\r", 4}; + auto const upper = cudf::string_view{"123XYZ", 6}; + auto const lower = cudf::string_view{"xyz123", 6}; + + check_result(udf::is_alpha(udf::g_character_flags_table, alpha), "alpha"); + check_result(!udf::is_alpha(udf::g_character_flags_table, alpha_num), "!alpha"); + + check_result(udf::is_alpha_numeric(udf::g_character_flags_table, alpha_num), "alpha_num"); + check_result(!udf::is_alpha_numeric(udf::g_character_flags_table, space), "!alpha_num"); + + check_result(udf::is_numeric(udf::g_character_flags_table, numeric), "numeric"); + check_result(!udf::is_numeric(udf::g_character_flags_table, alpha), "!numeric"); + + check_result(udf::is_digit(udf::g_character_flags_table, digit), "digit"); + check_result(!udf::is_digit(udf::g_character_flags_table, alpha), "!digit"); + + check_result(udf::is_decimal(udf::g_character_flags_table, decimal), "decimal"); + check_result(!udf::is_decimal(udf::g_character_flags_table, alpha), "!decimal"); + + check_result(udf::is_space(udf::g_character_flags_table, space), "space"); + check_result(!udf::is_space(udf::g_character_flags_table, alpha), "!space"); + + check_result(udf::is_lower(udf::g_character_flags_table, lower), "lower"); + check_result(!udf::is_lower(udf::g_character_flags_table, alpha), "!lower"); + + check_result(udf::is_upper(udf::g_character_flags_table, upper), "upper"); + check_result(!udf::is_upper(udf::g_character_flags_table, alpha), "!upper"); + + // + auto alpha_space_type = string_character_types::ALPHA | string_character_types::SPACE; + auto const test1 = cudf::string_view{"Hello world", 11}; + check_result(udf::all_characters_of_type(udf::g_character_flags_table, test1, alpha_space_type), "alpha+space"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/ctors.udf b/python/strings_udf/cpp/tests/ctors.udf new file mode 100644 index 00000000000..0e1cd1bbfde --- /dev/null +++ b/python/strings_udf/cpp/tests/ctors.udf @@ -0,0 +1,61 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + auto null_string = cudf::string_view{nullptr,0}; + + dstring def; + verify(def, null_string, "default ctor"); + + dstring literal{"hello"}; + verify(literal, cudf::string_view{"hello",5}, "null-terminated ctor" ); + + dstring chr_array{"goodbye", 4}; + verify(chr_array, cudf::string_view{"good",4}, "char array ctor"); + + dstring chr_str{4, 'X'}; + verify(chr_str, cudf::string_view{"XXXX",4}, "char ctor"); + + auto world = cudf::string_view{"world",5}; + dstring d_str{world}; + verify(d_str, world, "string_view ctor"); + + dstring copied{d_str}; + verify(copied, d_str, "copy ctor"); + + dstring moved{std::move(d_str)}; + verify(moved, copied, "move ctor"); + verify(d_str, null_string, "move ctor arg check"); + + d_str = literal; + verify(d_str, literal, "assignment dstring"); + + d_str = world; + verify(d_str, world, "assignment string_view "); + + moved = std::move(d_str); + verify(moved, world, "move assignment"); + verify(d_str, null_string, "move assignment arg check"); + + d_str.assign(literal); + verify(d_str, literal, "assign()"); + d_str.assign("abcdefghijklmnopqrstuvwxyz"); + verify(d_str, cudf::string_view{"abcdefghijklmnopqrstuvwxyz",26}, "assign(char*)"); + d_str.assign("abcdefghijklmnopqrstuvwxyz", 10); + verify(d_str, cudf::string_view{"abcdefghij",10}, "assign(char*,size)"); + d_str.assign(world); + verify(d_str, world, "assign(string_view)"); + moved.assign(std::move(d_str)); + verify(moved, world, "assign(&&)"); + verify(d_str, null_string, "assign(&&) arg check"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/done.txt b/python/strings_udf/cpp/tests/done.txt new file mode 100644 index 00000000000..a965a70ed4e --- /dev/null +++ b/python/strings_udf/cpp/tests/done.txt @@ -0,0 +1 @@ +Done diff --git a/python/strings_udf/cpp/tests/erase.udf b/python/strings_udf/cpp/tests/erase.udf new file mode 100644 index 00000000000..09b7348ee00 --- /dev/null +++ b/python/strings_udf/cpp/tests/erase.udf @@ -0,0 +1,33 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"0123456789", 10}; + + dstring d_str{test_data}; + + d_str.erase(5, 5); + verify(d_str, cudf::string_view{"01234", 5}, "erase(5,5)"); + d_str = test_data; + d_str.erase(5); + verify(d_str, cudf::string_view{"01234", 5}, "erase(5)"); + + d_str = test_data; + d_str.erase(0,5); + verify(d_str, cudf::string_view{"56789", 5}, "erase(0,5)"); + + d_str = test_data; + d_str.erase(0); + verify(d_str, cudf::string_view{"", 0}, "erase(0)"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/insert.udf b/python/strings_udf/cpp/tests/insert.udf new file mode 100644 index 00000000000..1ddadb029c3 --- /dev/null +++ b/python/strings_udf/cpp/tests/insert.udf @@ -0,0 +1,40 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const helloworld = cudf::string_view{"helloworld", 10}; + auto const hello_world = cudf::string_view{"hello world", 11}; + auto const hello_world2 = cudf::string_view{"hello, world", 12}; + + dstring d_str{helloworld}; + + d_str.insert(5, 1, ' '); + verify(d_str, hello_world, "insert(char)"); + + d_str = helloworld; + d_str.insert(5, cudf::string_view{", ",2}); + verify(d_str, hello_world2, "insert(string_view)"); + + d_str = helloworld; + d_str.insert(5, ", "); + verify(d_str, hello_world2, "insert(char*)"); + + d_str = helloworld; + d_str.insert(5, ", there", 2); + verify(d_str, hello_world2, "insert(char*,size)"); + + d_str = helloworld; + d_str.insert(10, "!"); + verify(d_str, cudf::string_view{"helloworld!", 11}, "insert() end"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/integers.udf b/python/strings_udf/cpp/tests/integers.udf new file mode 100644 index 00000000000..153783c2ede --- /dev/null +++ b/python/strings_udf/cpp/tests/integers.udf @@ -0,0 +1,34 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"-1234567890A", 12}; + + auto value = cudf::strings::udf::stoi(test_data); + dstring d_str = cudf::strings::udf::to_string(value); + verify(d_str, test_data.substr(0,11), "-1234567890"); + + value = cudf::strings::udf::stoi(test_data.substr(0,1)); + d_str = cudf::strings::udf::to_string(value); + verify(d_str, cudf::string_view("0",1), "sign"); + + value = cudf::strings::udf::stoi(test_data.substr(0,0)); + d_str = cudf::strings::udf::to_string(value); + verify(d_str, cudf::string_view("0",1), ""); + + value = cudf::strings::udf::stoi(test_data.substr(11,1)); + d_str = cudf::strings::udf::to_string(value); + verify(d_str, cudf::string_view("0",1), "A"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/replace.udf b/python/strings_udf/cpp/tests/replace.udf new file mode 100644 index 00000000000..39a6ae5e26f --- /dev/null +++ b/python/strings_udf/cpp/tests/replace.udf @@ -0,0 +1,73 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"0123456789", 10}; + + dstring d_str{test_data}; + + auto const expected_same = cudf::string_view{"01234 6789", 10}; + d_str.replace(5, 1, 1, ' '); + verify(d_str, expected_same, "replace(char) same size"); + d_str.replace(5, 1, " "); + verify(d_str, expected_same, "replace(char*) same size"); + d_str.replace(5, 1, " !", 1); + verify(d_str, expected_same, "replace(char*,size) same size"); + d_str.replace(5, 1, cudf::string_view{" ", 1}); + verify(d_str, expected_same, "replace(string_view) same size"); + + auto const expected_small = cudf::string_view{"01 789", 7}; + d_str = test_data; + d_str.replace(2, 5, 2, ' '); + verify(d_str, expected_small, "replace(char) smaller"); + d_str = test_data; + d_str.replace(2, 5, " "); + verify(d_str, expected_small, "replace(char*) smaller"); + d_str = test_data; + d_str.replace(2, 5, " !", 2); + verify(d_str, expected_small, "replace(char*,size) smaller"); + d_str = test_data; + d_str.replace(2, 5, cudf::string_view{" ", 2}); + verify(d_str, expected_small, "replace(string_view) smaller"); + + auto const expected_large = cudf::string_view{"0 456789", 12}; + d_str = test_data; + d_str.replace(1, 3, 5, ' '); + verify(d_str, expected_large, "replace(char) larger"); + d_str = test_data; + d_str.replace(1, 3, " "); + verify(d_str, expected_large, "replace(char*) larger"); + d_str = test_data; + d_str.replace(1, 3, " !", 5); + verify(d_str, expected_large, "replace(char*,size) larger"); + d_str = test_data; + d_str.replace(1, 3, cudf::string_view{" ", 5}); + verify(d_str, expected_large, "replace(string_view) larger"); + + d_str = test_data; + d_str.replace(5, -1, ""); + verify(d_str, cudf::string_view{"01234",5}, "replace(5,end)"); + + d_str = test_data; + d_str.replace(5, 0, " "); + verify(d_str, cudf::string_view{"01234 56789",11}, "replace(5,0)"); + + d_str = test_data; + d_str.replace(-1, -1, " "); + verify(d_str, d_str, "replace(-1)"); + d_str.replace(45, -1, " "); + verify(d_str, d_str, "replace(pos>end)"); + d_str.replace(0, -1, " ", -1); + verify(d_str, d_str, "replace(char*,size<0)"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/resize.udf b/python/strings_udf/cpp/tests/resize.udf new file mode 100644 index 00000000000..9bc7e355783 --- /dev/null +++ b/python/strings_udf/cpp/tests/resize.udf @@ -0,0 +1,35 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"0123456789", 10}; + + dstring d_str{test_data}; + + d_str.reserve(5); + verify(d_str, test_data, "reserve(5)"); + d_str.reserve(25); + verify(d_str, test_data, "reserve(5)"); + + d_str.shrink_to_fit(); + verify(d_str, test_data, "shrink_to_fit"); + + d_str.resize(12); + verify(d_str, cudf::string_view{"0123456789\0\0", 12}, "resize(12)"); + d_str.resize(4); + verify(d_str, cudf::string_view{"0123", 4}, "resize(4)"); + + d_str.clear(); + verify(d_str, cudf::string_view{nullptr, 0}, "clear()"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/run_tests.sh b/python/strings_udf/cpp/tests/run_tests.sh new file mode 100755 index 00000000000..ab8ebaca6c1 --- /dev/null +++ b/python/strings_udf/cpp/tests/run_tests.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +./udf_cli -u ../tests/ctors.udf -t ../tests/done.txt +./udf_cli -u ../tests/append.udf -t ../tests/done.txt +./udf_cli -u ../tests/insert.udf -t ../tests/done.txt +./udf_cli -u ../tests/replace.udf -t ../tests/done.txt +./udf_cli -u ../tests/substr.udf -t ../tests/done.txt +./udf_cli -u ../tests/erase.udf -t ../tests/done.txt +./udf_cli -u ../tests/resize.udf -t ../tests/done.txt + +./udf_cli -u ../tests/integers.udf -t ../tests/done.txt +./udf_cli -u ../tests/split.udf -t ../tests/done.txt +./udf_cli -u ../tests/strip.udf -t ../tests/done.txt + +./udf_cli -u ../tests/starts_ends.udf -t ../tests/done.txt +./udf_cli -u ../tests/char_types.udf -t ../tests/done.txt diff --git a/python/strings_udf/cpp/tests/search.udf b/python/strings_udf/cpp/tests/search.udf new file mode 100644 index 00000000000..e9b3e0c24db --- /dev/null +++ b/python/strings_udf/cpp/tests/search.udf @@ -0,0 +1,30 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +using namespace cudf::strings; + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + auto const test_data = cudf::string_view{"Here is an orange and an apple", 30}; + auto const empty = cudf::string_view{}; + + check_result(udf::count(test_data, "an")==4, "count(an)=4"); + check_result(udf::count(test_data, "a", 10, 40)==4, "count(a,10,40)=4"); + check_result(udf::count(test_data, "g", 1, 10)==0, "count(g,1,10)=0"); + check_result(udf::count(test_data, "g")==1, "count(g)=1"); + check_result(udf::count(test_data, "orange", 15, 25)==0, "count(orange,15,25)=0"); + check_result(udf::count(test_data, "an orange")==1, "count(an orange)=1"); + check_result(udf::count(test_data, "banana")==0, "count(banana)=0"); + + check_result(udf::count(test_data, empty)==0, "count('')=0"); + check_result(udf::count(empty, empty)==0, "count('','')=0"); + check_result(udf::count(empty, "a")==0, "count('',a)=0"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/split.udf b/python/strings_udf/cpp/tests/split.udf new file mode 100644 index 00000000000..f39ae546276 --- /dev/null +++ b/python/strings_udf/cpp/tests/split.udf @@ -0,0 +1,32 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, + cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"01 234 56789 ", 13}; + cudf::string_view tokens[4]; + + auto token_count = cudf::strings::udf::split(test_data, tokens); + auto d_str = cudf::strings::udf::join("::", tokens, token_count); + verify(d_str, cudf::string_view{"01::234::56789", 14}, "split().join('::')"); + + token_count = cudf::strings::udf::split(test_data, "4 ", tokens); + d_str = cudf::strings::udf::join("/", tokens, token_count); + verify(d_str, cudf::string_view{"01 23/56789 ", 12}, "split('4 ').join('/')"); + + token_count = cudf::strings::udf::split(test_data, " ", tokens); + d_str = cudf::strings::udf::join("xyz", tokens, token_count); + verify(d_str, cudf::string_view{"01xyz234xyz56789xyz", 19}, "split(' ').join('xyz')"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/starts_ends.udf b/python/strings_udf/cpp/tests/starts_ends.udf new file mode 100644 index 00000000000..8edf9665ee5 --- /dev/null +++ b/python/strings_udf/cpp/tests/starts_ends.udf @@ -0,0 +1,35 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"0123456789", 10}; + + dstring d_test{test_data}; + cudf::string_view first("012345",6); + cudf::string_view last("456789",6); + + check_result(cudf::strings::udf::starts_with(d_test, "0123"), "starts_with(0123)"); + check_result(!cudf::strings::udf::starts_with(d_test, "123"), "starts_with(123)"); + check_result(cudf::strings::udf::starts_with(d_test, "0123", 2), "starts_with(0123,2)"); + check_result(!cudf::strings::udf::starts_with(d_test, "123", 2), "starts_with(123,2)"); + check_result(cudf::strings::udf::starts_with(d_test, first), "starts_with(first)"); + check_result(!cudf::strings::udf::starts_with(d_test, last), "starts_with(last)"); + + check_result(cudf::strings::udf::ends_with(d_test, "6789"), "ends_with(6789)"); + check_result(!cudf::strings::udf::ends_with(d_test, "78"), "ends_with(78)"); + check_result(cudf::strings::udf::ends_with(d_test, "8901", 2), "ends_with(8901,2)"); + check_result(!cudf::strings::udf::ends_with(d_test, "8901", 3), "ends_with(890,2)"); + check_result(cudf::strings::udf::ends_with(d_test, last), "ends_with(last)"); + check_result(!cudf::strings::udf::ends_with(d_test, first), "ends_with(first)"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/strip.udf b/python/strings_udf/cpp/tests/strip.udf new file mode 100644 index 00000000000..2db45b8b158 --- /dev/null +++ b/python/strings_udf/cpp/tests/strip.udf @@ -0,0 +1,59 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include +#include +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto empty = cudf::string_view{}; + cudf::string_view tests[] = { + empty, + cudf::string_view{" aaa ",5}, + cudf::string_view{"bbb ",5}, + cudf::string_view{" cccc",5}, + cudf::string_view{" a b c ",7}, + cudf::string_view{"a b c",5}, + cudf::string_view{" ",3}, + cudf::string_view{"aaaaa",5} }; + + auto d_str = cudf::strings::udf::strip(empty); + verify(d_str, empty, ""); + + d_str = cudf::strings::udf::strip(tests[1]); + verify(d_str, tests[1].substr(1,3), " aaa "); + + d_str = cudf::strings::udf::strip(tests[2]); + verify(d_str, tests[2].substr(0,3), "bbb "); + + d_str = cudf::strings::udf::strip(tests[3]); + verify(d_str, tests[3].substr(1,4), " cccc"); + + d_str = cudf::strings::udf::strip(tests[4]); + verify(d_str, tests[4].substr(1,5), " a b c "); + + d_str = cudf::strings::udf::strip(tests[5]); + verify(d_str, tests[5], "a b c"); + + d_str = cudf::strings::udf::strip(tests[6]); + verify(d_str, empty, ""); + + d_str = cudf::strings::udf::strip(tests[7]); + verify(d_str, tests[7], "aaaaa"); + + auto N = static_cast( sizeof(tests)/sizeof(cudf::string_view) ); + for( int i=0; i < N; ++i ) { + d_str = cudf::strings::udf::strip(tests[i], " abc"); + dstring name = cudf::strings::udf::to_string(i); + verify(d_str, empty, name.data()); + } + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/substr.udf b/python/strings_udf/cpp/tests/substr.udf new file mode 100644 index 00000000000..27992a3ed7a --- /dev/null +++ b/python/strings_udf/cpp/tests/substr.udf @@ -0,0 +1,35 @@ +// Copyright (c) 2022, NVIDIA CORPORATION. + +#include + +#include "../tests/utilities.cuh" + +__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) +{ + int tid = (blockDim.x * blockIdx.x) + threadIdx.x; + if( tid > 0 ) return; + + using dstring = cudf::strings::udf::dstring; + + auto const test_data = cudf::string_view{"0123456789", 10}; + + dstring d_test{test_data}; + + auto d_str = d_test.substr(0, 5); + verify(d_str, cudf::string_view{"01234", 5}, "substr(0,5)"); + + d_str = d_test.substr(5); + verify(d_str, cudf::string_view{"56789", 5}, "substr(5)"); + d_str = d_test.substr(5, 45); + verify(d_str, cudf::string_view{"56789", 5}, "substr(5, 45)"); + + d_str = d_test.substr(0); + verify(d_str, test_data, "substr(0)"); + d_str = d_test.substr(-1); + verify(d_str, cudf::string_view("",0), "substr(-1)"); + + d_str = d_test.substr(3,0); + verify(d_str, cudf::string_view("",0), "substr(3,0)"); + + d_out_strs[tid] = d_in_strs[tid]; +} diff --git a/python/strings_udf/cpp/tests/utilities.cuh b/python/strings_udf/cpp/tests/utilities.cuh new file mode 100644 index 00000000000..01a071c7e26 --- /dev/null +++ b/python/strings_udf/cpp/tests/utilities.cuh @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#pragma once + +__device__ void print_debug(cudf::strings::udf::dstring const& d_str, char const* name = "") +{ + printf( + "%s:(%p,%d,%d)=[%s]\n", name, d_str.data(), d_str.size_bytes(), d_str.capacity(), d_str.data()); +} + +__device__ void verify(cudf::strings::udf::dstring const& d_str, + cudf::string_view const expected, + char const* name = 0) +{ + if (d_str.compare(expected) == 0) { + printf("\x1B[32mOK\x1B[0m: %s\n", name); + } else { + auto exp_str = cudf::strings::udf::dstring(expected); + printf("\x1B[31mError\x1B[0m: %s [%s]!=[%s]\n", name, d_str.data(), exp_str.data()); + } +} + +__device__ void check_result(bool result, char const* str = 0) +{ + if (result) { + printf("\x1B[32mOK\x1B[0m: %s\n", str); + } else { + printf("\x1B[31mError\x1B[0m: %s\n", str); + } +} diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py new file mode 100644 index 00000000000..a3718590ee5 --- /dev/null +++ b/python/strings_udf/setup.py @@ -0,0 +1,50 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. + +import os +from distutils.sysconfig import get_python_lib + +from Cython.Build import cythonize +from setuptools import find_packages, setup +from setuptools.extension import Extension + +CUDA_HOME = "/usr/local/cuda" +cuda_include_dir = os.path.join(CUDA_HOME, "include") +cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") + +CONDA_PREFIX = os.environ.get("CONDA_PREFIX") +print(CONDA_PREFIX) +extensions = [ + Extension( + "*", + sources=["strings_udf/_lib/*.pyx"], + include_dirs=[ + os.path.abspath(os.path.join(CONDA_PREFIX, "include/cudf")), + os.path.join(CONDA_PREFIX, "include/rapids/libcudacxx"), + "./cpp/include", + cuda_include_dir, + ], + library_dirs=( + [ + get_python_lib(), + os.path.join(os.sys.prefix, "lib"), + cuda_lib_dir, + "cpp/build", + ] + ), + libraries=["cudart", "cudf", "nvrtc", "cudf_strings_udf"], + language="c++", + extra_compile_args=["-std=c++17"], + ) +] + +directives = dict(profile=False, language_level=3, embedsignature=True) + +setup( + name="strings_udf", + description="cudf strings udf library", + author="NVIDIA Corporation", + setup_requires=["cython"], + ext_modules=cythonize(extensions, compiler_directives=directives), + zip_safe=False, + packages=find_packages(), +) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py new file mode 100644 index 00000000000..5d7b2a89d17 --- /dev/null +++ b/python/strings_udf/strings_udf/__init__.py @@ -0,0 +1,9 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from strings_udf import lowering + +from pathlib import Path + +here = str(Path(__file__).parent.absolute()) +relative = "/../cpp/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx" +ptxpath = here + relative diff --git a/python/strings_udf/strings_udf/_lib/__init__.pxd b/python/strings_udf/strings_udf/_lib/__init__.pxd new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/strings_udf/strings_udf/_lib/__init__.py b/python/strings_udf/strings_udf/_lib/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/strings_udf/strings_udf/_lib/cpp/__init__.pxd b/python/strings_udf/strings_udf/_lib/cpp/__init__.pxd new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/strings_udf/strings_udf/_lib/cpp/__init__.py b/python/strings_udf/strings_udf/_lib/cpp/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd new file mode 100644 index 00000000000..4b3c6de4b2d --- /dev/null +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -0,0 +1,24 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. + +from libcpp.vector cimport vector +from libcpp.string cimport string +from libcpp.memory cimport unique_ptr +from libc.stdint cimport uint8_t + +from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view + +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + +# +cdef extern from "cudf/strings/udf/udf_apis.hpp": + cdef cppclass udf_module + # + cdef unique_ptr[udf_module] create_udf_module(string, vector[string]) + cdef unique_ptr[column] call_udf(udf_module, string, size_type, vector[column_view]) + cdef unique_ptr[device_buffer] to_string_view_array(column_view) + cdef unique_ptr[column] from_dstring_array(void*, size_t) + +cdef extern from "cudf/strings/detail/char_tables.hpp" namespace "cudf::strings::detail": + cdef const uint8_t* get_character_flags_table() except + diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp new file mode 100644 index 00000000000..b23779aef4d --- /dev/null +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp @@ -0,0 +1,25684 @@ +/* Generated by Cython 0.29.30 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [ + "../../cpp/include/cudf/column/column.hpp", + "../../cpp/include/cudf/column/column_view.hpp", + "../../cpp/include/cudf/strings/detail/char_tables.hpp", + "../../cpp/include/cudf/types.hpp", + "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib/python3.8/site-packages/cuda" + ], + "extra_compile_args": [ + "-std=c++17" + ], + "include_dirs": [ + "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib/python3.8/site-packages/cuda", + "/home/nfs/brmiller/anaconda3/envs/cudf_dev/include/cudf", + "/home/nfs/brmiller/anaconda3/envs/cudf_dev/include/rapids/libcudacxx", + "../../cpp/include", + "/usr/local/cuda/include" + ], + "language": "c++", + "libraries": [ + "cudart", + "cudf", + "nvrtc", + "cudf_strings_udf" + ], + "library_dirs": [ + "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib/python3.8/site-packages", + "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib", + "/usr/local/cuda/lib64", + "../../cpp/build" + ], + "name": "strings_udf._lib.cudf_jit_udf", + "sources": [ + "strings_udf/_lib/cudf_jit_udf.pyx" + ] + }, + "module_name": "strings_udf._lib.cudf_jit_udf" +} +END: Cython Metadata */ + +#ifndef PY_SSIZE_T_CLEAN +#define PY_SSIZE_T_CLEAN +#endif /* PY_SSIZE_T_CLEAN */ +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. +#else +#define CYTHON_ABI "0_29_30" +#define CYTHON_HEX_VERSION 0x001D1EF0 +#define CYTHON_FUTURE_DIVISION 1 +#include +#ifndef offsetof + #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION + #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900) + #endif +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 + #undef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS 0 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 + #endif +#else + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #elif !defined(CYTHON_FAST_THREAD_STATE) + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000) + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif + #ifndef CYTHON_USE_DICT_VERSIONS + #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) + #endif + #if PY_VERSION_HEX >= 0x030B00A4 + #undef CYTHON_USE_EXC_INFO_STACK + #define CYTHON_USE_EXC_INFO_STACK 0 + #elif !defined(CYTHON_USE_EXC_INFO_STACK) + #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) + #endif + #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC + #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 + #endif +#endif +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) +#endif +#if CYTHON_USE_PYLONG_INTERNALS + #if PY_MAJOR_VERSION < 3 + #include "longintrepr.h" + #endif + #undef SHIFT + #undef BASE + #undef MASK + #ifdef SIZEOF_VOID_P + enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; + #endif +#endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif +template +void __Pyx_call_destructor(T& x) { + x.~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; } + template bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) + #define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_DefaultClassType PyType_Type +#if PY_VERSION_HEX >= 0x030B00A1 + static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, + PyObject *code, PyObject *c, PyObject* n, PyObject *v, + PyObject *fv, PyObject *cell, PyObject* fn, + PyObject *name, int fline, PyObject *lnos) { + PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; + PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; + const char *fn_cstr=NULL; + const char *name_cstr=NULL; + PyCodeObject* co=NULL; + PyObject *type, *value, *traceback; + PyErr_Fetch(&type, &value, &traceback); + if (!(kwds=PyDict_New())) goto end; + if (!(argcount=PyLong_FromLong(a))) goto end; + if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; + if (!(posonlyargcount=PyLong_FromLong(0))) goto end; + if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; + if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; + if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; + if (!(nlocals=PyLong_FromLong(l))) goto end; + if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; + if (!(stacksize=PyLong_FromLong(s))) goto end; + if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; + if (!(flags=PyLong_FromLong(f))) goto end; + if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; + if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; + if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; + if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; + if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; + if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; + if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here + if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; + Py_XDECREF((PyObject*)co); + co = (PyCodeObject*)call_result; + call_result = NULL; + if (0) { + cleanup_code_too: + Py_XDECREF((PyObject*)co); + co = NULL; + } + end: + Py_XDECREF(kwds); + Py_XDECREF(argcount); + Py_XDECREF(posonlyargcount); + Py_XDECREF(kwonlyargcount); + Py_XDECREF(nlocals); + Py_XDECREF(stacksize); + Py_XDECREF(replace); + Py_XDECREF(call_result); + Py_XDECREF(empty); + if (type) { + PyErr_Restore(type, value, traceback); + } + return co; + } +#else + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) +#endif + #define __Pyx_DefaultClassType PyType_Type +#endif +#ifndef Py_TPFLAGS_CHECKTYPES + #define Py_TPFLAGS_CHECKTYPES 0 +#endif +#ifndef Py_TPFLAGS_HAVE_INDEX + #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#ifndef Py_TPFLAGS_HAVE_NEWBUFFER + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#ifndef Py_TPFLAGS_HAVE_FINALIZE + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#ifndef METH_STACKLESS + #define METH_STACKLESS 0 +#endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 + #define PyMem_RawMalloc(n) PyMem_Malloc(n) + #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) + #define PyMem_RawFree(p) PyMem_Free(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #if defined(PyUnicode_IS_READY) + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #else + #define __Pyx_PyUnicode_READY(op) (0) + #endif + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) + #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) + #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) + #endif + #else + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) + #endif +#else + #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) + #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) + #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) + #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) + #define PyObject_ASCII(o) PyObject_Repr(o) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#ifndef PyObject_Unicode + #define PyObject_Unicode PyObject_Str +#endif +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#if PY_VERSION_HEX >= 0x030900A4 + #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) +#else + #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) + #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) +#endif +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) + #else + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) + #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL +#endif +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; +#endif + +#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) + #if !defined(_USE_MATH_DEFINES) + #define _USE_MATH_DEFINES + #endif +#endif +#include +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif + +#define __PYX_MARK_ERR_POS(f_index, lineno) \ + { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } +#define __PYX_ERR(f_index, lineno, Ln_error) \ + { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#define __PYX_HAVE__strings_udf___lib__cudf_jit_udf +#define __PYX_HAVE_API__strings_udf___lib__cudf_jit_udf +/* Early includes */ +#include +#include +#include "ios" +#include "new" +#include "stdexcept" +#include "typeinfo" +#include +#include +#include + + #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600) + // move should be defined for these versions of MSVC, but __cplusplus isn't set usefully + #include + + namespace cython_std { + template typename std::remove_reference::type&& move(T& t) noexcept { return std::move(t); } + template typename std::remove_reference::type&& move(T&& t) noexcept { return std::move(t); } + } + + #endif + +#include +#include "rmm/cuda_stream_view.hpp" +#include "rmm/mr/device/device_memory_resource.hpp" +#include "rmm/device_buffer.hpp" +#include "cudf/types.hpp" +#include "cudf/column/column_view.hpp" +#include "cudf/column/column.hpp" +#include "cudf/strings/udf/udf_apis.hpp" +#include "cudf/strings/detail/char_tables.hpp" +#include "pythread.h" +#include +#include +#include "pystate.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 1 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) +#define __PYX_DEFAULT_STRING_ENCODING "utf8" +#define __Pyx_PyObject_FromString __Pyx_PyUnicode_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#define __Pyx_uchar_cast(c) ((unsigned char)c) +#define __Pyx_long_cast(x) ((long)x) +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ + (sizeof(type) < sizeof(Py_ssize_t)) ||\ + (sizeof(type) > sizeof(Py_ssize_t) &&\ + likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX) &&\ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ + v == (type)PY_SSIZE_T_MIN))) ||\ + (sizeof(type) == sizeof(Py_ssize_t) &&\ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ + v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { + return (size_t) i < (size_t) limit; +} +#if defined (__cplusplus) && __cplusplus >= 201103L + #include + #define __Pyx_sst_abs(value) std::abs(value) +#elif SIZEOF_INT >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) abs(value) +#elif SIZEOF_LONG >= SIZEOF_SIZE_T + #define __Pyx_sst_abs(value) labs(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define __Pyx_sst_abs(value) llabs(value) +#elif defined (__GNUC__) + #define __Pyx_sst_abs(value) __builtin_llabs(value) +#else + #define __Pyx_sst_abs(value) ((value<0) ? -value : value) +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) +#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); +#if CYTHON_ASSUME_SAFE_MACROS +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) +#else +#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) +#endif +#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } + +static PyObject *__pyx_m = NULL; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime = NULL; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static PyObject *__pyx_empty_unicode; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + + +static const char *__pyx_f[] = { + "strings_udf/_lib/cudf_jit_udf.pyx", + "stringsource", + "stream.pxd", + "memory_resource.pxd", + "device_buffer.pxd", + "column.pxd", +}; +/* ForceInitThreads.proto */ +#ifndef __PYX_FORCE_INIT_THREADS + #define __PYX_FORCE_INIT_THREADS 0 +#endif + +/* NoFastGil.proto */ +#define __Pyx_PyGILState_Ensure PyGILState_Ensure +#define __Pyx_PyGILState_Release PyGILState_Release +#define __Pyx_FastGIL_Remember() +#define __Pyx_FastGIL_Forget() +#define __Pyx_FastGilFuncInit() + +/* BufferFormatStructs.proto */ +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; + struct __Pyx_StructField_* fields; + size_t size; + size_t arraysize[8]; + int ndim; + char typegroup; + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + +/* Atomics.proto */ +#include +#ifndef CYTHON_ATOMICS + #define CYTHON_ATOMICS 1 +#endif +#define __pyx_atomic_int_type int +#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\ + (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\ + !defined(__i386__) + #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1) + #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1) + #ifdef __PYX_DEBUG_ATOMICS + #warning "Using GNU atomics" + #endif +#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0 + #include + #undef __pyx_atomic_int_type + #define __pyx_atomic_int_type LONG + #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value) + #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value) + #ifdef __PYX_DEBUG_ATOMICS + #pragma message ("Using MSVC atomics") + #endif +#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0 + #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value) + #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value) + #ifdef __PYX_DEBUG_ATOMICS + #warning "Using Intel atomics" + #endif +#else + #undef CYTHON_ATOMICS + #define CYTHON_ATOMICS 0 + #ifdef __PYX_DEBUG_ATOMICS + #warning "Not using atomics" + #endif +#endif +typedef volatile __pyx_atomic_int_type __pyx_atomic_int; +#if CYTHON_ATOMICS + #define __pyx_add_acquisition_count(memview)\ + __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock) + #define __pyx_sub_acquisition_count(memview)\ + __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock) +#else + #define __pyx_add_acquisition_count(memview)\ + __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) + #define __pyx_sub_acquisition_count(memview)\ + __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) +#endif + +/* MemviewSliceStruct.proto */ +struct __pyx_memoryview_obj; +typedef struct { + struct __pyx_memoryview_obj *memview; + char *data; + Py_ssize_t shape[8]; + Py_ssize_t strides[8]; + Py_ssize_t suboffsets[8]; +} __Pyx_memviewslice; +#define __Pyx_MemoryView_Len(m) (m.shape[0]) + + +/* "cuda/ccudart.pxd":1058 + * cudaFormatModeAuto = 1 + * + * ctypedef unsigned long long cudaSurfaceObject_t # <<<<<<<<<<<<<< + * + * cdef enum cudaTextureAddressMode: + */ +typedef unsigned PY_LONG_LONG __pyx_t_4cuda_7ccudart_cudaSurfaceObject_t; + +/* "cuda/ccudart.pxd":1089 + * int seamlessCubemap + * + * ctypedef unsigned long long cudaTextureObject_t # <<<<<<<<<<<<<< + * + * cdef enum cudaDataType_t: + */ +typedef unsigned PY_LONG_LONG __pyx_t_4cuda_7ccudart_cudaTextureObject_t; + +/* "cuda/ccudart.pxd":1664 + * + * + * ctypedef unsigned int GLenum # <<<<<<<<<<<<<< + * + * ctypedef unsigned int GLuint + */ +typedef unsigned int __pyx_t_4cuda_7ccudart_GLenum; + +/* "cuda/ccudart.pxd":1666 + * ctypedef unsigned int GLenum + * + * ctypedef unsigned int GLuint # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef unsigned int __pyx_t_4cuda_7ccudart_GLuint; + +/* "cuda/ccudart.pxd":1678 + * ctypedef void* EGLStreamKHR + * + * ctypedef unsigned int EGLint # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef unsigned int __pyx_t_4cuda_7ccudart_EGLint; + +/* "cuda/ccudart.pxd":1685 + * ctypedef void* EGLSyncKHR + * + * ctypedef uint32_t VdpDevice # <<<<<<<<<<<<<< + * + * ctypedef unsigned long long VdpGetProcAddress + */ +typedef uint32_t __pyx_t_4cuda_7ccudart_VdpDevice; + +/* "cuda/ccudart.pxd":1687 + * ctypedef uint32_t VdpDevice + * + * ctypedef unsigned long long VdpGetProcAddress # <<<<<<<<<<<<<< + * + * ctypedef uint32_t VdpVideoSurface + */ +typedef unsigned PY_LONG_LONG __pyx_t_4cuda_7ccudart_VdpGetProcAddress; + +/* "cuda/ccudart.pxd":1689 + * ctypedef unsigned long long VdpGetProcAddress + * + * ctypedef uint32_t VdpVideoSurface # <<<<<<<<<<<<<< + * + * ctypedef uint32_t VdpOutputSurface + */ +typedef uint32_t __pyx_t_4cuda_7ccudart_VdpVideoSurface; + +/* "cuda/ccudart.pxd":1691 + * ctypedef uint32_t VdpVideoSurface + * + * ctypedef uint32_t VdpOutputSurface # <<<<<<<<<<<<<< + * + * cdef cudaError_t cudaVDPAUGetDevice(int* device, VdpDevice vdpDevice, VdpGetProcAddress* vdpGetProcAddress) nogil except ?cudaErrorCallRequiresNewerDriver + */ +typedef uint32_t __pyx_t_4cuda_7ccudart_VdpOutputSurface; + +/*--- Type declarations ---*/ +struct __pyx_obj_3rmm_5_cuda_6stream_Stream; +struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor; +struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_ManagedMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_PoolMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_CallbackMemoryResource; +struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor; +struct __pyx_obj_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor; +struct __pyx_obj_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor; +struct __pyx_obj_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor; +struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer; +struct __pyx_obj_4cudf_4_lib_6column_Column; +struct __pyx_array_obj; +struct __pyx_MemviewEnum_obj; +struct __pyx_memoryview_obj; +struct __pyx_memoryviewslice_obj; +struct __pyx_t_4cuda_7ccudart_dim3; +struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc; +struct __pyx_t_4cuda_7ccudart__cudaArraySparseProperties_tileExtent_s; +struct __pyx_t_4cuda_7ccudart_cudaArraySparseProperties; +struct __pyx_t_4cuda_7ccudart_cudaArrayMemoryRequirements; +struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr; +struct __pyx_t_4cuda_7ccudart_cudaExtent; +struct __pyx_t_4cuda_7ccudart_cudaPos; +struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DParms; +struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DPeerParms; +struct __pyx_t_4cuda_7ccudart_cudaMemsetParams; +struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow; +struct __pyx_t_4cuda_7ccudart_cudaHostNodeParams; +union __pyx_t_4cuda_7ccudart_cudaStreamAttrValue; +union __pyx_t_4cuda_7ccudart_cudaKernelNodeAttrValue; +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_array_s; +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_mipmap_s; +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_linear_s; +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_pitch2D_s; +union __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_u; +struct __pyx_t_4cuda_7ccudart_cudaResourceDesc; +struct __pyx_t_4cuda_7ccudart_cudaResourceViewDesc; +struct __pyx_t_4cuda_7ccudart_cudaPointerAttributes; +struct __pyx_t_4cuda_7ccudart_cudaFuncAttributes; +struct __pyx_t_4cuda_7ccudart_cudaMemLocation; +struct __pyx_t_4cuda_7ccudart_cudaMemAccessDesc; +struct __pyx_t_4cuda_7ccudart_cudaMemPoolProps; +struct __pyx_t_4cuda_7ccudart_cudaMemPoolPtrExportData; +struct __pyx_t_4cuda_7ccudart_cudaMemAllocNodeParams; +struct __pyx_t_4cuda_7ccudart_CUuuid_st; +struct __pyx_t_4cuda_7ccudart_cudaDeviceProp; +struct __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_st; +struct __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_st; +struct __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_handle_win32_s; +union __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_u; +struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleDesc; +struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryBufferDesc; +struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryMipmappedArrayDesc; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_handle_win32_s; +union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_u; +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleDesc; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_fence_s; +union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_s; +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalParams; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_fence_s; +union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s; +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_s; +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitParams; +struct __pyx_t_4cuda_7ccudart_cudaKernelNodeParams; +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalNodeParams; +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitNodeParams; +struct __pyx_t_4cuda_7ccudart_cudaTextureDesc; +struct __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc_st; +union __pyx_t_4cuda_7ccudart__cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u; +struct __pyx_t_4cuda_7ccudart_cudaEglFrame_st; + +/* "cuda/ccudart.pxd":9 + * # is strictly prohibited. + * + * cdef enum cudaRoundMode: # <<<<<<<<<<<<<< + * cudaRoundNearest = 0 + * cudaRoundZero = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaRoundMode { + __pyx_e_4cuda_7ccudart_cudaRoundNearest = 0, + __pyx_e_4cuda_7ccudart_cudaRoundZero = 1, + __pyx_e_4cuda_7ccudart_cudaRoundPosInf = 2, + __pyx_e_4cuda_7ccudart_cudaRoundMinInf = 3 +}; + +/* "cuda/ccudart.pxd":20 + * unsigned int z + * + * cdef enum cudaError: # <<<<<<<<<<<<<< + * cudaSuccess = 0 + * cudaErrorInvalidValue = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaError { + __pyx_e_4cuda_7ccudart_cudaSuccess = 0, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidValue = 1, + __pyx_e_4cuda_7ccudart_cudaErrorMemoryAllocation = 2, + __pyx_e_4cuda_7ccudart_cudaErrorInitializationError = 3, + __pyx_e_4cuda_7ccudart_cudaErrorCudartUnloading = 4, + __pyx_e_4cuda_7ccudart_cudaErrorProfilerDisabled = 5, + __pyx_e_4cuda_7ccudart_cudaErrorProfilerNotInitialized = 6, + __pyx_e_4cuda_7ccudart_cudaErrorProfilerAlreadyStarted = 7, + __pyx_e_4cuda_7ccudart_cudaErrorProfilerAlreadyStopped = 8, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidConfiguration = 9, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidPitchValue = 12, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidSymbol = 13, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidHostPointer = 16, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidDevicePointer = 17, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidTexture = 18, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidTextureBinding = 19, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidChannelDescriptor = 20, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidMemcpyDirection = 21, + __pyx_e_4cuda_7ccudart_cudaErrorAddressOfConstant = 22, + __pyx_e_4cuda_7ccudart_cudaErrorTextureFetchFailed = 23, + __pyx_e_4cuda_7ccudart_cudaErrorTextureNotBound = 24, + __pyx_e_4cuda_7ccudart_cudaErrorSynchronizationError = 25, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidFilterSetting = 26, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidNormSetting = 27, + __pyx_e_4cuda_7ccudart_cudaErrorMixedDeviceExecution = 28, + __pyx_e_4cuda_7ccudart_cudaErrorNotYetImplemented = 31, + __pyx_e_4cuda_7ccudart_cudaErrorMemoryValueTooLarge = 32, + __pyx_e_4cuda_7ccudart_cudaErrorStubLibrary = 34, + __pyx_e_4cuda_7ccudart_cudaErrorInsufficientDriver = 35, + __pyx_e_4cuda_7ccudart_cudaErrorCallRequiresNewerDriver = 36, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidSurface = 37, + __pyx_e_4cuda_7ccudart_cudaErrorDuplicateVariableName = 43, + __pyx_e_4cuda_7ccudart_cudaErrorDuplicateTextureName = 44, + __pyx_e_4cuda_7ccudart_cudaErrorDuplicateSurfaceName = 45, + __pyx_e_4cuda_7ccudart_cudaErrorDevicesUnavailable = 46, + __pyx_e_4cuda_7ccudart_cudaErrorIncompatibleDriverContext = 49, + __pyx_e_4cuda_7ccudart_cudaErrorMissingConfiguration = 52, + __pyx_e_4cuda_7ccudart_cudaErrorPriorLaunchFailure = 53, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchMaxDepthExceeded = 65, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchFileScopedTex = 66, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchFileScopedSurf = 67, + __pyx_e_4cuda_7ccudart_cudaErrorSyncDepthExceeded = 68, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchPendingCountExceeded = 69, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidDeviceFunction = 98, + __pyx_e_4cuda_7ccudart_cudaErrorNoDevice = 0x64, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidDevice = 0x65, + __pyx_e_4cuda_7ccudart_cudaErrorDeviceNotLicensed = 0x66, + __pyx_e_4cuda_7ccudart_cudaErrorSoftwareValidityNotEstablished = 0x67, + __pyx_e_4cuda_7ccudart_cudaErrorStartupFailure = 0x7F, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidKernelImage = 0xC8, + __pyx_e_4cuda_7ccudart_cudaErrorDeviceUninitialized = 0xC9, + __pyx_e_4cuda_7ccudart_cudaErrorMapBufferObjectFailed = 0xCD, + __pyx_e_4cuda_7ccudart_cudaErrorUnmapBufferObjectFailed = 0xCE, + __pyx_e_4cuda_7ccudart_cudaErrorArrayIsMapped = 0xCF, + __pyx_e_4cuda_7ccudart_cudaErrorAlreadyMapped = 0xD0, + __pyx_e_4cuda_7ccudart_cudaErrorNoKernelImageForDevice = 0xD1, + __pyx_e_4cuda_7ccudart_cudaErrorAlreadyAcquired = 0xD2, + __pyx_e_4cuda_7ccudart_cudaErrorNotMapped = 0xD3, + __pyx_e_4cuda_7ccudart_cudaErrorNotMappedAsArray = 0xD4, + __pyx_e_4cuda_7ccudart_cudaErrorNotMappedAsPointer = 0xD5, + __pyx_e_4cuda_7ccudart_cudaErrorECCUncorrectable = 0xD6, + __pyx_e_4cuda_7ccudart_cudaErrorUnsupportedLimit = 0xD7, + __pyx_e_4cuda_7ccudart_cudaErrorDeviceAlreadyInUse = 0xD8, + __pyx_e_4cuda_7ccudart_cudaErrorPeerAccessUnsupported = 0xD9, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidPtx = 0xDA, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidGraphicsContext = 0xDB, + __pyx_e_4cuda_7ccudart_cudaErrorNvlinkUncorrectable = 0xDC, + __pyx_e_4cuda_7ccudart_cudaErrorJitCompilerNotFound = 0xDD, + __pyx_e_4cuda_7ccudart_cudaErrorUnsupportedPtxVersion = 0xDE, + __pyx_e_4cuda_7ccudart_cudaErrorJitCompilationDisabled = 0xDF, + __pyx_e_4cuda_7ccudart_cudaErrorUnsupportedExecAffinity = 0xE0, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidSource = 0x12C, + __pyx_e_4cuda_7ccudart_cudaErrorFileNotFound = 0x12D, + __pyx_e_4cuda_7ccudart_cudaErrorSharedObjectSymbolNotFound = 0x12E, + __pyx_e_4cuda_7ccudart_cudaErrorSharedObjectInitFailed = 0x12F, + __pyx_e_4cuda_7ccudart_cudaErrorOperatingSystem = 0x130, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidResourceHandle = 0x190, + __pyx_e_4cuda_7ccudart_cudaErrorIllegalState = 0x191, + __pyx_e_4cuda_7ccudart_cudaErrorSymbolNotFound = 0x1F4, + __pyx_e_4cuda_7ccudart_cudaErrorNotReady = 0x258, + __pyx_e_4cuda_7ccudart_cudaErrorIllegalAddress = 0x2BC, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchOutOfResources = 0x2BD, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchTimeout = 0x2BE, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchIncompatibleTexturing = 0x2BF, + __pyx_e_4cuda_7ccudart_cudaErrorPeerAccessAlreadyEnabled = 0x2C0, + __pyx_e_4cuda_7ccudart_cudaErrorPeerAccessNotEnabled = 0x2C1, + __pyx_e_4cuda_7ccudart_cudaErrorSetOnActiveProcess = 0x2C4, + __pyx_e_4cuda_7ccudart_cudaErrorContextIsDestroyed = 0x2C5, + __pyx_e_4cuda_7ccudart_cudaErrorAssert = 0x2C6, + __pyx_e_4cuda_7ccudart_cudaErrorTooManyPeers = 0x2C7, + __pyx_e_4cuda_7ccudart_cudaErrorHostMemoryAlreadyRegistered = 0x2C8, + __pyx_e_4cuda_7ccudart_cudaErrorHostMemoryNotRegistered = 0x2C9, + __pyx_e_4cuda_7ccudart_cudaErrorHardwareStackError = 0x2CA, + __pyx_e_4cuda_7ccudart_cudaErrorIllegalInstruction = 0x2CB, + __pyx_e_4cuda_7ccudart_cudaErrorMisalignedAddress = 0x2CC, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidAddressSpace = 0x2CD, + __pyx_e_4cuda_7ccudart_cudaErrorInvalidPc = 0x2CE, + __pyx_e_4cuda_7ccudart_cudaErrorLaunchFailure = 0x2CF, + __pyx_e_4cuda_7ccudart_cudaErrorCooperativeLaunchTooLarge = 0x2D0, + __pyx_e_4cuda_7ccudart_cudaErrorNotPermitted = 0x320, + __pyx_e_4cuda_7ccudart_cudaErrorNotSupported = 0x321, + __pyx_e_4cuda_7ccudart_cudaErrorSystemNotReady = 0x322, + __pyx_e_4cuda_7ccudart_cudaErrorSystemDriverMismatch = 0x323, + __pyx_e_4cuda_7ccudart_cudaErrorCompatNotSupportedOnDevice = 0x324, + __pyx_e_4cuda_7ccudart_cudaErrorMpsConnectionFailed = 0x325, + __pyx_e_4cuda_7ccudart_cudaErrorMpsRpcFailure = 0x326, + __pyx_e_4cuda_7ccudart_cudaErrorMpsServerNotReady = 0x327, + __pyx_e_4cuda_7ccudart_cudaErrorMpsMaxClientsReached = 0x328, + __pyx_e_4cuda_7ccudart_cudaErrorMpsMaxConnectionsReached = 0x329, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureUnsupported = 0x384, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureInvalidated = 0x385, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureMerge = 0x386, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureUnmatched = 0x387, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureUnjoined = 0x388, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureIsolation = 0x389, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureImplicit = 0x38A, + __pyx_e_4cuda_7ccudart_cudaErrorCapturedEvent = 0x38B, + __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureWrongThread = 0x38C, + __pyx_e_4cuda_7ccudart_cudaErrorTimeout = 0x38D, + __pyx_e_4cuda_7ccudart_cudaErrorGraphExecUpdateFailure = 0x38E, + __pyx_e_4cuda_7ccudart_cudaErrorExternalDevice = 0x38F, + __pyx_e_4cuda_7ccudart_cudaErrorUnknown = 0x3E7, + __pyx_e_4cuda_7ccudart_cudaErrorApiFailureBase = 0x2710 +}; + +/* "cuda/ccudart.pxd":145 + * cudaErrorApiFailureBase = 10000 + * + * cdef enum cudaChannelFormatKind: # <<<<<<<<<<<<<< + * cudaChannelFormatKindSigned = 0 + * cudaChannelFormatKindUnsigned = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaChannelFormatKind { + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSigned = 0, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsigned = 1, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindFloat = 2, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindNone = 3, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindNV12 = 4, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized8X1 = 5, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized8X2 = 6, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized8X4 = 7, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized16X1 = 8, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized16X2 = 9, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized16X4 = 10, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized8X1 = 11, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized8X2 = 12, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized8X4 = 13, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized16X1 = 14, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized16X2 = 15, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized16X4 = 16, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed1 = 17, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed1SRGB = 18, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed2 = 19, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed2SRGB = 20, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed3 = 21, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed3SRGB = 22, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed4 = 23, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedBlockCompressed4 = 24, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed5 = 25, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedBlockCompressed5 = 26, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed6H = 27, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedBlockCompressed6H = 28, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed7 = 29, + __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed7SRGB = 30 +}; + +/* "cuda/ccudart.pxd":224 + * unsigned int reserved[4] + * + * cdef enum cudaMemoryType: # <<<<<<<<<<<<<< + * cudaMemoryTypeUnregistered = 0 + * cudaMemoryTypeHost = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemoryType { + __pyx_e_4cuda_7ccudart_cudaMemoryTypeUnregistered = 0, + __pyx_e_4cuda_7ccudart_cudaMemoryTypeHost = 1, + __pyx_e_4cuda_7ccudart_cudaMemoryTypeDevice = 2, + __pyx_e_4cuda_7ccudart_cudaMemoryTypeManaged = 3 +}; + +/* "cuda/ccudart.pxd":230 + * cudaMemoryTypeManaged = 3 + * + * cdef enum cudaMemcpyKind: # <<<<<<<<<<<<<< + * cudaMemcpyHostToHost = 0 + * cudaMemcpyHostToDevice = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemcpyKind { + __pyx_e_4cuda_7ccudart_cudaMemcpyHostToHost = 0, + __pyx_e_4cuda_7ccudart_cudaMemcpyHostToDevice = 1, + __pyx_e_4cuda_7ccudart_cudaMemcpyDeviceToHost = 2, + __pyx_e_4cuda_7ccudart_cudaMemcpyDeviceToDevice = 3, + __pyx_e_4cuda_7ccudart_cudaMemcpyDefault = 4 +}; + +/* "cuda/ccudart.pxd":282 + * size_t height + * + * cdef enum cudaAccessProperty: # <<<<<<<<<<<<<< + * cudaAccessPropertyNormal = 0 + * cudaAccessPropertyStreaming = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaAccessProperty { + __pyx_e_4cuda_7ccudart_cudaAccessPropertyNormal = 0, + __pyx_e_4cuda_7ccudart_cudaAccessPropertyStreaming = 1, + __pyx_e_4cuda_7ccudart_cudaAccessPropertyPersisting = 2 +}; + +/* "cuda/ccudart.pxd":300 + * void* userData + * + * cdef enum cudaStreamCaptureStatus: # <<<<<<<<<<<<<< + * cudaStreamCaptureStatusNone = 0 + * cudaStreamCaptureStatusActive = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaStreamCaptureStatus { + __pyx_e_4cuda_7ccudart_cudaStreamCaptureStatusNone = 0, + __pyx_e_4cuda_7ccudart_cudaStreamCaptureStatusActive = 1, + __pyx_e_4cuda_7ccudart_cudaStreamCaptureStatusInvalidated = 2 +}; + +/* "cuda/ccudart.pxd":305 + * cudaStreamCaptureStatusInvalidated = 2 + * + * cdef enum cudaStreamCaptureMode: # <<<<<<<<<<<<<< + * cudaStreamCaptureModeGlobal = 0 + * cudaStreamCaptureModeThreadLocal = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaStreamCaptureMode { + __pyx_e_4cuda_7ccudart_cudaStreamCaptureModeGlobal = 0, + __pyx_e_4cuda_7ccudart_cudaStreamCaptureModeThreadLocal = 1, + __pyx_e_4cuda_7ccudart_cudaStreamCaptureModeRelaxed = 2 +}; + +/* "cuda/ccudart.pxd":310 + * cudaStreamCaptureModeRelaxed = 2 + * + * cdef enum cudaSynchronizationPolicy: # <<<<<<<<<<<<<< + * cudaSyncPolicyAuto = 1 + * cudaSyncPolicySpin = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaSynchronizationPolicy { + __pyx_e_4cuda_7ccudart_cudaSyncPolicyAuto = 1, + __pyx_e_4cuda_7ccudart_cudaSyncPolicySpin = 2, + __pyx_e_4cuda_7ccudart_cudaSyncPolicyYield = 3, + __pyx_e_4cuda_7ccudart_cudaSyncPolicyBlockingSync = 4 +}; + +/* "cuda/ccudart.pxd":316 + * cudaSyncPolicyBlockingSync = 4 + * + * cdef enum cudaStreamAttrID: # <<<<<<<<<<<<<< + * cudaStreamAttributeAccessPolicyWindow = 1 + * cudaStreamAttributeSynchronizationPolicy = 3 + */ +enum __pyx_t_4cuda_7ccudart_cudaStreamAttrID { + __pyx_e_4cuda_7ccudart_cudaStreamAttributeAccessPolicyWindow = 1, + __pyx_e_4cuda_7ccudart_cudaStreamAttributeSynchronizationPolicy = 3 +}; + +/* "cuda/ccudart.pxd":324 + * cudaSynchronizationPolicy syncPolicy + * + * cdef enum cudaStreamUpdateCaptureDependenciesFlags: # <<<<<<<<<<<<<< + * cudaStreamAddCaptureDependencies = 0 + * cudaStreamSetCaptureDependencies = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaStreamUpdateCaptureDependenciesFlags { + __pyx_e_4cuda_7ccudart_cudaStreamAddCaptureDependencies = 0, + __pyx_e_4cuda_7ccudart_cudaStreamSetCaptureDependencies = 1 +}; + +/* "cuda/ccudart.pxd":328 + * cudaStreamSetCaptureDependencies = 1 + * + * cdef enum cudaUserObjectFlags: # <<<<<<<<<<<<<< + * cudaUserObjectNoDestructorSync = 1 + * + */ +enum __pyx_t_4cuda_7ccudart_cudaUserObjectFlags { + __pyx_e_4cuda_7ccudart_cudaUserObjectNoDestructorSync = 1 +}; + +/* "cuda/ccudart.pxd":331 + * cudaUserObjectNoDestructorSync = 1 + * + * cdef enum cudaUserObjectRetainFlags: # <<<<<<<<<<<<<< + * cudaGraphUserObjectMove = 1 + * + */ +enum __pyx_t_4cuda_7ccudart_cudaUserObjectRetainFlags { + __pyx_e_4cuda_7ccudart_cudaGraphUserObjectMove = 1 +}; + +/* "cuda/ccudart.pxd":335 + * + * + * cdef enum cudaGraphicsRegisterFlags: # <<<<<<<<<<<<<< + * cudaGraphicsRegisterFlagsNone = 0 + * cudaGraphicsRegisterFlagsReadOnly = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphicsRegisterFlags { + __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsNone = 0, + __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsReadOnly = 1, + __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsWriteDiscard = 2, + __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsSurfaceLoadStore = 4, + __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsTextureGather = 8 +}; + +/* "cuda/ccudart.pxd":342 + * cudaGraphicsRegisterFlagsTextureGather = 8 + * + * cdef enum cudaGraphicsMapFlags: # <<<<<<<<<<<<<< + * cudaGraphicsMapFlagsNone = 0 + * cudaGraphicsMapFlagsReadOnly = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphicsMapFlags { + __pyx_e_4cuda_7ccudart_cudaGraphicsMapFlagsNone = 0, + __pyx_e_4cuda_7ccudart_cudaGraphicsMapFlagsReadOnly = 1, + __pyx_e_4cuda_7ccudart_cudaGraphicsMapFlagsWriteDiscard = 2 +}; + +/* "cuda/ccudart.pxd":347 + * cudaGraphicsMapFlagsWriteDiscard = 2 + * + * cdef enum cudaGraphicsCubeFace: # <<<<<<<<<<<<<< + * cudaGraphicsCubeFacePositiveX = 0 + * cudaGraphicsCubeFaceNegativeX = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphicsCubeFace { + __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFacePositiveX = 0, + __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFaceNegativeX = 1, + __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFacePositiveY = 2, + __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFaceNegativeY = 3, + __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFacePositiveZ = 4, + __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFaceNegativeZ = 5 +}; + +/* "cuda/ccudart.pxd":355 + * cudaGraphicsCubeFaceNegativeZ = 5 + * + * cdef enum cudaKernelNodeAttrID: # <<<<<<<<<<<<<< + * cudaKernelNodeAttributeAccessPolicyWindow = 1 + * cudaKernelNodeAttributeCooperative = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaKernelNodeAttrID { + __pyx_e_4cuda_7ccudart_cudaKernelNodeAttributeAccessPolicyWindow = 1, + __pyx_e_4cuda_7ccudart_cudaKernelNodeAttributeCooperative = 2 +}; + +/* "cuda/ccudart.pxd":363 + * int cooperative + * + * cdef enum cudaResourceType: # <<<<<<<<<<<<<< + * cudaResourceTypeArray = 0 + * cudaResourceTypeMipmappedArray = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaResourceType { + __pyx_e_4cuda_7ccudart_cudaResourceTypeArray = 0, + __pyx_e_4cuda_7ccudart_cudaResourceTypeMipmappedArray = 1, + __pyx_e_4cuda_7ccudart_cudaResourceTypeLinear = 2, + __pyx_e_4cuda_7ccudart_cudaResourceTypePitch2D = 3 +}; + +/* "cuda/ccudart.pxd":369 + * cudaResourceTypePitch2D = 3 + * + * cdef enum cudaResourceViewFormat: # <<<<<<<<<<<<<< + * cudaResViewFormatNone = 0 + * cudaResViewFormatUnsignedChar1 = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaResourceViewFormat { + __pyx_e_4cuda_7ccudart_cudaResViewFormatNone = 0, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedChar1 = 1, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedChar2 = 2, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedChar4 = 3, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedChar1 = 4, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedChar2 = 5, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedChar4 = 6, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedShort1 = 7, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedShort2 = 8, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedShort4 = 9, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedShort1 = 10, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedShort2 = 11, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedShort4 = 12, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedInt1 = 13, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedInt2 = 14, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedInt4 = 15, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedInt1 = 16, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedInt2 = 17, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedInt4 = 18, + __pyx_e_4cuda_7ccudart_cudaResViewFormatHalf1 = 19, + __pyx_e_4cuda_7ccudart_cudaResViewFormatHalf2 = 20, + __pyx_e_4cuda_7ccudart_cudaResViewFormatHalf4 = 21, + __pyx_e_4cuda_7ccudart_cudaResViewFormatFloat1 = 22, + __pyx_e_4cuda_7ccudart_cudaResViewFormatFloat2 = 23, + __pyx_e_4cuda_7ccudart_cudaResViewFormatFloat4 = 24, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed1 = 25, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed2 = 26, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed3 = 27, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed4 = 28, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedBlockCompressed4 = 29, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed5 = 30, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedBlockCompressed5 = 31, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed6H = 32, + __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedBlockCompressed6H = 33, + __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed7 = 34 +}; + +/* "cuda/ccudart.pxd":462 + * int preferredShmemCarveout + * + * cdef enum cudaFuncAttribute: # <<<<<<<<<<<<<< + * cudaFuncAttributeMaxDynamicSharedMemorySize = 8 + * cudaFuncAttributePreferredSharedMemoryCarveout = 9 + */ +enum __pyx_t_4cuda_7ccudart_cudaFuncAttribute { + __pyx_e_4cuda_7ccudart_cudaFuncAttributeMaxDynamicSharedMemorySize = 8, + __pyx_e_4cuda_7ccudart_cudaFuncAttributePreferredSharedMemoryCarveout = 9, + __pyx_e_4cuda_7ccudart_cudaFuncAttributeMax = 10 +}; + +/* "cuda/ccudart.pxd":467 + * cudaFuncAttributeMax = 10 + * + * cdef enum cudaFuncCache: # <<<<<<<<<<<<<< + * cudaFuncCachePreferNone = 0 + * cudaFuncCachePreferShared = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaFuncCache { + __pyx_e_4cuda_7ccudart_cudaFuncCachePreferNone = 0, + __pyx_e_4cuda_7ccudart_cudaFuncCachePreferShared = 1, + __pyx_e_4cuda_7ccudart_cudaFuncCachePreferL1 = 2, + __pyx_e_4cuda_7ccudart_cudaFuncCachePreferEqual = 3 +}; + +/* "cuda/ccudart.pxd":473 + * cudaFuncCachePreferEqual = 3 + * + * cdef enum cudaSharedMemConfig: # <<<<<<<<<<<<<< + * cudaSharedMemBankSizeDefault = 0 + * cudaSharedMemBankSizeFourByte = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaSharedMemConfig { + __pyx_e_4cuda_7ccudart_cudaSharedMemBankSizeDefault = 0, + __pyx_e_4cuda_7ccudart_cudaSharedMemBankSizeFourByte = 1, + __pyx_e_4cuda_7ccudart_cudaSharedMemBankSizeEightByte = 2 +}; + +/* "cuda/ccudart.pxd":478 + * cudaSharedMemBankSizeEightByte = 2 + * + * cdef enum cudaSharedCarveout: # <<<<<<<<<<<<<< + * cudaSharedmemCarveoutDefault = -1 + * cudaSharedmemCarveoutMaxShared = 100 + */ +enum __pyx_t_4cuda_7ccudart_cudaSharedCarveout { + __pyx_e_4cuda_7ccudart_cudaSharedmemCarveoutDefault = -1L, + __pyx_e_4cuda_7ccudart_cudaSharedmemCarveoutMaxShared = 0x64, + __pyx_e_4cuda_7ccudart_cudaSharedmemCarveoutMaxL1 = 0 +}; + +/* "cuda/ccudart.pxd":483 + * cudaSharedmemCarveoutMaxL1 = 0 + * + * cdef enum cudaComputeMode: # <<<<<<<<<<<<<< + * cudaComputeModeDefault = 0 + * cudaComputeModeExclusive = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaComputeMode { + __pyx_e_4cuda_7ccudart_cudaComputeModeDefault = 0, + __pyx_e_4cuda_7ccudart_cudaComputeModeExclusive = 1, + __pyx_e_4cuda_7ccudart_cudaComputeModeProhibited = 2, + __pyx_e_4cuda_7ccudart_cudaComputeModeExclusiveProcess = 3 +}; + +/* "cuda/ccudart.pxd":489 + * cudaComputeModeExclusiveProcess = 3 + * + * cdef enum cudaLimit: # <<<<<<<<<<<<<< + * cudaLimitStackSize = 0 + * cudaLimitPrintfFifoSize = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaLimit { + __pyx_e_4cuda_7ccudart_cudaLimitStackSize = 0, + __pyx_e_4cuda_7ccudart_cudaLimitPrintfFifoSize = 1, + __pyx_e_4cuda_7ccudart_cudaLimitMallocHeapSize = 2, + __pyx_e_4cuda_7ccudart_cudaLimitDevRuntimeSyncDepth = 3, + __pyx_e_4cuda_7ccudart_cudaLimitDevRuntimePendingLaunchCount = 4, + __pyx_e_4cuda_7ccudart_cudaLimitMaxL2FetchGranularity = 5, + __pyx_e_4cuda_7ccudart_cudaLimitPersistingL2CacheSize = 6 +}; + +/* "cuda/ccudart.pxd":498 + * cudaLimitPersistingL2CacheSize = 6 + * + * cdef enum cudaMemoryAdvise: # <<<<<<<<<<<<<< + * cudaMemAdviseSetReadMostly = 1 + * cudaMemAdviseUnsetReadMostly = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemoryAdvise { + __pyx_e_4cuda_7ccudart_cudaMemAdviseSetReadMostly = 1, + __pyx_e_4cuda_7ccudart_cudaMemAdviseUnsetReadMostly = 2, + __pyx_e_4cuda_7ccudart_cudaMemAdviseSetPreferredLocation = 3, + __pyx_e_4cuda_7ccudart_cudaMemAdviseUnsetPreferredLocation = 4, + __pyx_e_4cuda_7ccudart_cudaMemAdviseSetAccessedBy = 5, + __pyx_e_4cuda_7ccudart_cudaMemAdviseUnsetAccessedBy = 6 +}; + +/* "cuda/ccudart.pxd":506 + * cudaMemAdviseUnsetAccessedBy = 6 + * + * cdef enum cudaMemRangeAttribute: # <<<<<<<<<<<<<< + * cudaMemRangeAttributeReadMostly = 1 + * cudaMemRangeAttributePreferredLocation = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemRangeAttribute { + __pyx_e_4cuda_7ccudart_cudaMemRangeAttributeReadMostly = 1, + __pyx_e_4cuda_7ccudart_cudaMemRangeAttributePreferredLocation = 2, + __pyx_e_4cuda_7ccudart_cudaMemRangeAttributeAccessedBy = 3, + __pyx_e_4cuda_7ccudart_cudaMemRangeAttributeLastPrefetchLocation = 4 +}; + +/* "cuda/ccudart.pxd":512 + * cudaMemRangeAttributeLastPrefetchLocation = 4 + * + * cdef enum cudaOutputMode: # <<<<<<<<<<<<<< + * cudaKeyValuePair = 0 + * cudaCSV = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaOutputMode { + __pyx_e_4cuda_7ccudart_cudaKeyValuePair = 0, + __pyx_e_4cuda_7ccudart_cudaCSV = 1 +}; + +/* "cuda/ccudart.pxd":516 + * cudaCSV = 1 + * + * cdef enum cudaFlushGPUDirectRDMAWritesOptions: # <<<<<<<<<<<<<< + * cudaFlushGPUDirectRDMAWritesOptionHost = 1 + * cudaFlushGPUDirectRDMAWritesOptionMemOps = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesOptions { + __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesOptionHost = 1, + __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesOptionMemOps = 2 +}; + +/* "cuda/ccudart.pxd":520 + * cudaFlushGPUDirectRDMAWritesOptionMemOps = 2 + * + * cdef enum cudaGPUDirectRDMAWritesOrdering: # <<<<<<<<<<<<<< + * cudaGPUDirectRDMAWritesOrderingNone = 0 + * cudaGPUDirectRDMAWritesOrderingOwner = 100 + */ +enum __pyx_t_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrdering { + __pyx_e_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrderingNone = 0, + __pyx_e_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrderingOwner = 0x64, + __pyx_e_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrderingAllDevices = 0xC8 +}; + +/* "cuda/ccudart.pxd":525 + * cudaGPUDirectRDMAWritesOrderingAllDevices = 200 + * + * cdef enum cudaFlushGPUDirectRDMAWritesScope: # <<<<<<<<<<<<<< + * cudaFlushGPUDirectRDMAWritesToOwner = 100 + * cudaFlushGPUDirectRDMAWritesToAllDevices = 200 + */ +enum __pyx_t_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesScope { + __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesToOwner = 0x64, + __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesToAllDevices = 0xC8 +}; + +/* "cuda/ccudart.pxd":529 + * cudaFlushGPUDirectRDMAWritesToAllDevices = 200 + * + * cdef enum cudaFlushGPUDirectRDMAWritesTarget: # <<<<<<<<<<<<<< + * cudaFlushGPUDirectRDMAWritesTargetCurrentDevice = 0 + * + */ +enum __pyx_t_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesTarget { + __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesTargetCurrentDevice = 0 +}; + +/* "cuda/ccudart.pxd":532 + * cudaFlushGPUDirectRDMAWritesTargetCurrentDevice = 0 + * + * cdef enum cudaDeviceAttr: # <<<<<<<<<<<<<< + * cudaDevAttrMaxThreadsPerBlock = 1 + * cudaDevAttrMaxBlockDimX = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaDeviceAttr { + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxThreadsPerBlock = 1, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlockDimX = 2, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlockDimY = 3, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlockDimZ = 4, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxGridDimX = 5, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxGridDimY = 6, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxGridDimZ = 7, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSharedMemoryPerBlock = 8, + __pyx_e_4cuda_7ccudart_cudaDevAttrTotalConstantMemory = 9, + __pyx_e_4cuda_7ccudart_cudaDevAttrWarpSize = 10, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxPitch = 11, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxRegistersPerBlock = 12, + __pyx_e_4cuda_7ccudart_cudaDevAttrClockRate = 13, + __pyx_e_4cuda_7ccudart_cudaDevAttrTextureAlignment = 14, + __pyx_e_4cuda_7ccudart_cudaDevAttrGpuOverlap = 15, + __pyx_e_4cuda_7ccudart_cudaDevAttrMultiProcessorCount = 16, + __pyx_e_4cuda_7ccudart_cudaDevAttrKernelExecTimeout = 17, + __pyx_e_4cuda_7ccudart_cudaDevAttrIntegrated = 18, + __pyx_e_4cuda_7ccudart_cudaDevAttrCanMapHostMemory = 19, + __pyx_e_4cuda_7ccudart_cudaDevAttrComputeMode = 20, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DWidth = 21, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DWidth = 22, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DHeight = 23, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DWidth = 24, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DHeight = 25, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DDepth = 26, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLayeredWidth = 27, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLayeredHeight = 28, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLayeredLayers = 29, + __pyx_e_4cuda_7ccudart_cudaDevAttrSurfaceAlignment = 30, + __pyx_e_4cuda_7ccudart_cudaDevAttrConcurrentKernels = 31, + __pyx_e_4cuda_7ccudart_cudaDevAttrEccEnabled = 32, + __pyx_e_4cuda_7ccudart_cudaDevAttrPciBusId = 33, + __pyx_e_4cuda_7ccudart_cudaDevAttrPciDeviceId = 34, + __pyx_e_4cuda_7ccudart_cudaDevAttrTccDriver = 35, + __pyx_e_4cuda_7ccudart_cudaDevAttrMemoryClockRate = 36, + __pyx_e_4cuda_7ccudart_cudaDevAttrGlobalMemoryBusWidth = 37, + __pyx_e_4cuda_7ccudart_cudaDevAttrL2CacheSize = 38, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxThreadsPerMultiProcessor = 39, + __pyx_e_4cuda_7ccudart_cudaDevAttrAsyncEngineCount = 40, + __pyx_e_4cuda_7ccudart_cudaDevAttrUnifiedAddressing = 41, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DLayeredWidth = 42, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DLayeredLayers = 43, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DGatherWidth = 45, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DGatherHeight = 46, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DWidthAlt = 47, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DHeightAlt = 48, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DDepthAlt = 49, + __pyx_e_4cuda_7ccudart_cudaDevAttrPciDomainId = 50, + __pyx_e_4cuda_7ccudart_cudaDevAttrTexturePitchAlignment = 51, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTextureCubemapWidth = 52, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTextureCubemapLayeredWidth = 53, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTextureCubemapLayeredLayers = 54, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface1DWidth = 55, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DWidth = 56, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DHeight = 57, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface3DWidth = 58, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface3DHeight = 59, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface3DDepth = 60, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface1DLayeredWidth = 61, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface1DLayeredLayers = 62, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DLayeredWidth = 63, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DLayeredHeight = 64, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DLayeredLayers = 65, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurfaceCubemapWidth = 66, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DLinearWidth = 69, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLinearWidth = 70, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLinearHeight = 71, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLinearPitch = 72, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DMipmappedWidth = 73, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DMipmappedHeight = 74, + __pyx_e_4cuda_7ccudart_cudaDevAttrComputeCapabilityMajor = 75, + __pyx_e_4cuda_7ccudart_cudaDevAttrComputeCapabilityMinor = 76, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DMipmappedWidth = 77, + __pyx_e_4cuda_7ccudart_cudaDevAttrStreamPrioritiesSupported = 78, + __pyx_e_4cuda_7ccudart_cudaDevAttrGlobalL1CacheSupported = 79, + __pyx_e_4cuda_7ccudart_cudaDevAttrLocalL1CacheSupported = 80, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxRegistersPerMultiprocessor = 82, + __pyx_e_4cuda_7ccudart_cudaDevAttrManagedMemory = 83, + __pyx_e_4cuda_7ccudart_cudaDevAttrIsMultiGpuBoard = 84, + __pyx_e_4cuda_7ccudart_cudaDevAttrMultiGpuBoardGroupID = 85, + __pyx_e_4cuda_7ccudart_cudaDevAttrHostNativeAtomicSupported = 86, + __pyx_e_4cuda_7ccudart_cudaDevAttrSingleToDoublePrecisionPerfRatio = 87, + __pyx_e_4cuda_7ccudart_cudaDevAttrPageableMemoryAccess = 88, + __pyx_e_4cuda_7ccudart_cudaDevAttrConcurrentManagedAccess = 89, + __pyx_e_4cuda_7ccudart_cudaDevAttrComputePreemptionSupported = 90, + __pyx_e_4cuda_7ccudart_cudaDevAttrCanUseHostPointerForRegisteredMem = 91, + __pyx_e_4cuda_7ccudart_cudaDevAttrReserved92 = 92, + __pyx_e_4cuda_7ccudart_cudaDevAttrReserved93 = 93, + __pyx_e_4cuda_7ccudart_cudaDevAttrReserved94 = 94, + __pyx_e_4cuda_7ccudart_cudaDevAttrCooperativeLaunch = 95, + __pyx_e_4cuda_7ccudart_cudaDevAttrCooperativeMultiDeviceLaunch = 96, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSharedMemoryPerBlockOptin = 97, + __pyx_e_4cuda_7ccudart_cudaDevAttrCanFlushRemoteWrites = 98, + __pyx_e_4cuda_7ccudart_cudaDevAttrHostRegisterSupported = 99, + __pyx_e_4cuda_7ccudart_cudaDevAttrPageableMemoryAccessUsesHostPageTables = 0x64, + __pyx_e_4cuda_7ccudart_cudaDevAttrDirectManagedMemAccessFromHost = 0x65, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlocksPerMultiprocessor = 0x6A, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxPersistingL2CacheSize = 0x6C, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxAccessPolicyWindowSize = 0x6D, + __pyx_e_4cuda_7ccudart_cudaDevAttrReservedSharedMemoryPerBlock = 0x6F, + __pyx_e_4cuda_7ccudart_cudaDevAttrSparseCudaArraySupported = 0x70, + __pyx_e_4cuda_7ccudart_cudaDevAttrHostRegisterReadOnlySupported = 0x71, + __pyx_e_4cuda_7ccudart_cudaDevAttrTimelineSemaphoreInteropSupported = 0x72, + __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTimelineSemaphoreInteropSupported = 0x72, + __pyx_e_4cuda_7ccudart_cudaDevAttrMemoryPoolsSupported = 0x73, + __pyx_e_4cuda_7ccudart_cudaDevAttrGPUDirectRDMASupported = 0x74, + __pyx_e_4cuda_7ccudart_cudaDevAttrGPUDirectRDMAFlushWritesOptions = 0x75, + __pyx_e_4cuda_7ccudart_cudaDevAttrGPUDirectRDMAWritesOrdering = 0x76, + __pyx_e_4cuda_7ccudart_cudaDevAttrMemoryPoolSupportedHandleTypes = 0x77, + __pyx_e_4cuda_7ccudart_cudaDevAttrDeferredMappingCudaArraySupported = 0x79, + __pyx_e_4cuda_7ccudart_cudaDevAttrMax = 0x7A +}; + +/* "cuda/ccudart.pxd":649 + * cudaDevAttrMax = 122 + * + * cdef enum cudaMemPoolAttr: # <<<<<<<<<<<<<< + * cudaMemPoolReuseFollowEventDependencies = 1 + * cudaMemPoolReuseAllowOpportunistic = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemPoolAttr { + __pyx_e_4cuda_7ccudart_cudaMemPoolReuseFollowEventDependencies = 1, + __pyx_e_4cuda_7ccudart_cudaMemPoolReuseAllowOpportunistic = 2, + __pyx_e_4cuda_7ccudart_cudaMemPoolReuseAllowInternalDependencies = 3, + __pyx_e_4cuda_7ccudart_cudaMemPoolAttrReleaseThreshold = 4, + __pyx_e_4cuda_7ccudart_cudaMemPoolAttrReservedMemCurrent = 5, + __pyx_e_4cuda_7ccudart_cudaMemPoolAttrReservedMemHigh = 6, + __pyx_e_4cuda_7ccudart_cudaMemPoolAttrUsedMemCurrent = 7, + __pyx_e_4cuda_7ccudart_cudaMemPoolAttrUsedMemHigh = 8 +}; + +/* "cuda/ccudart.pxd":659 + * cudaMemPoolAttrUsedMemHigh = 8 + * + * cdef enum cudaMemLocationType: # <<<<<<<<<<<<<< + * cudaMemLocationTypeInvalid = 0 + * cudaMemLocationTypeDevice = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemLocationType { + __pyx_e_4cuda_7ccudart_cudaMemLocationTypeInvalid = 0, + __pyx_e_4cuda_7ccudart_cudaMemLocationTypeDevice = 1 +}; + +/* "cuda/ccudart.pxd":667 + * int id + * + * cdef enum cudaMemAccessFlags: # <<<<<<<<<<<<<< + * cudaMemAccessFlagsProtNone = 0 + * cudaMemAccessFlagsProtRead = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemAccessFlags { + __pyx_e_4cuda_7ccudart_cudaMemAccessFlagsProtNone = 0, + __pyx_e_4cuda_7ccudart_cudaMemAccessFlagsProtRead = 1, + __pyx_e_4cuda_7ccudart_cudaMemAccessFlagsProtReadWrite = 3 +}; + +/* "cuda/ccudart.pxd":676 + * cudaMemAccessFlags flags + * + * cdef enum cudaMemAllocationType: # <<<<<<<<<<<<<< + * cudaMemAllocationTypeInvalid = 0 + * cudaMemAllocationTypePinned = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemAllocationType { + __pyx_e_4cuda_7ccudart_cudaMemAllocationTypeInvalid = 0, + __pyx_e_4cuda_7ccudart_cudaMemAllocationTypePinned = 1, + __pyx_e_4cuda_7ccudart_cudaMemAllocationTypeMax = 0x7FFFFFFF +}; + +/* "cuda/ccudart.pxd":681 + * cudaMemAllocationTypeMax = 2147483647 + * + * cdef enum cudaMemAllocationHandleType: # <<<<<<<<<<<<<< + * cudaMemHandleTypeNone = 0 + * cudaMemHandleTypePosixFileDescriptor = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaMemAllocationHandleType { + __pyx_e_4cuda_7ccudart_cudaMemHandleTypeNone = 0, + __pyx_e_4cuda_7ccudart_cudaMemHandleTypePosixFileDescriptor = 1, + __pyx_e_4cuda_7ccudart_cudaMemHandleTypeWin32 = 2, + __pyx_e_4cuda_7ccudart_cudaMemHandleTypeWin32Kmt = 4 +}; + +/* "cuda/ccudart.pxd":704 + * void* dptr + * + * cdef enum cudaGraphMemAttributeType: # <<<<<<<<<<<<<< + * cudaGraphMemAttrUsedMemCurrent = 0 + * cudaGraphMemAttrUsedMemHigh = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphMemAttributeType { + __pyx_e_4cuda_7ccudart_cudaGraphMemAttrUsedMemCurrent = 0, + __pyx_e_4cuda_7ccudart_cudaGraphMemAttrUsedMemHigh = 1, + __pyx_e_4cuda_7ccudart_cudaGraphMemAttrReservedMemCurrent = 2, + __pyx_e_4cuda_7ccudart_cudaGraphMemAttrReservedMemHigh = 3 +}; + +/* "cuda/ccudart.pxd":710 + * cudaGraphMemAttrReservedMemHigh = 3 + * + * cdef enum cudaDeviceP2PAttr: # <<<<<<<<<<<<<< + * cudaDevP2PAttrPerformanceRank = 1 + * cudaDevP2PAttrAccessSupported = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaDeviceP2PAttr { + __pyx_e_4cuda_7ccudart_cudaDevP2PAttrPerformanceRank = 1, + __pyx_e_4cuda_7ccudart_cudaDevP2PAttrAccessSupported = 2, + __pyx_e_4cuda_7ccudart_cudaDevP2PAttrNativeAtomicSupported = 3, + __pyx_e_4cuda_7ccudart_cudaDevP2PAttrCudaArrayAccessSupported = 4 +}; + +/* "cuda/ccudart.pxd":815 + * ctypedef cudaIpcMemHandle_st cudaIpcMemHandle_t + * + * cdef enum cudaExternalMemoryHandleType: # <<<<<<<<<<<<<< + * cudaExternalMemoryHandleTypeOpaqueFd = 1 + * cudaExternalMemoryHandleTypeOpaqueWin32 = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleType { + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeOpaqueFd = 1, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeOpaqueWin32 = 2, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeOpaqueWin32Kmt = 3, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D12Heap = 4, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D12Resource = 5, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D11Resource = 6, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D11ResourceKmt = 7, + __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeNvSciBuf = 8 +}; + +/* "cuda/ccudart.pxd":852 + * unsigned int numLevels + * + * cdef enum cudaExternalSemaphoreHandleType: # <<<<<<<<<<<<<< + * cudaExternalSemaphoreHandleTypeOpaqueFd = 1 + * cudaExternalSemaphoreHandleTypeOpaqueWin32 = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleType { + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeOpaqueFd = 1, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeOpaqueWin32 = 2, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt = 3, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeD3D12Fence = 4, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeD3D11Fence = 5, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeNvSciSync = 6, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeKeyedMutex = 7, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeKeyedMutexKmt = 8, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd = 9, + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10 +}; + +/* "cuda/ccudart.pxd":975 + * ctypedef CUmemPoolHandle_st* cudaMemPool_t + * + * cdef enum cudaCGScope: # <<<<<<<<<<<<<< + * cudaCGScopeInvalid = 0 + * cudaCGScopeGrid = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaCGScope { + __pyx_e_4cuda_7ccudart_cudaCGScopeInvalid = 0, + __pyx_e_4cuda_7ccudart_cudaCGScopeGrid = 1, + __pyx_e_4cuda_7ccudart_cudaCGScopeMultiGrid = 2 +}; + +/* "cuda/ccudart.pxd":998 + * unsigned int numExtSems + * + * cdef enum cudaGraphNodeType: # <<<<<<<<<<<<<< + * cudaGraphNodeTypeKernel = 0 + * cudaGraphNodeTypeMemcpy = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphNodeType { + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeKernel = 0, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemcpy = 1, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemset = 2, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeHost = 3, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeGraph = 4, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeEmpty = 5, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeWaitEvent = 6, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeEventRecord = 7, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeExtSemaphoreSignal = 8, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeExtSemaphoreWait = 9, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemAlloc = 10, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemFree = 11, + __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeCount = 12 +}; + +/* "cuda/ccudart.pxd":1018 + * ctypedef CUgraphExec_st* cudaGraphExec_t + * + * cdef enum cudaGraphExecUpdateResult: # <<<<<<<<<<<<<< + * cudaGraphExecUpdateSuccess = 0 + * cudaGraphExecUpdateError = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphExecUpdateResult { + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateSuccess = 0, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateError = 1, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorTopologyChanged = 2, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorNodeTypeChanged = 3, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorFunctionChanged = 4, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorParametersChanged = 5, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorNotSupported = 6, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorUnsupportedFunctionChange = 7, + __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorAttributesChanged = 8 +}; + +/* "cuda/ccudart.pxd":1029 + * cudaGraphExecUpdateErrorAttributesChanged = 8 + * + * cdef enum cudaGetDriverEntryPointFlags: # <<<<<<<<<<<<<< + * cudaEnableDefault = 0 + * cudaEnableLegacyStream = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGetDriverEntryPointFlags { + __pyx_e_4cuda_7ccudart_cudaEnableDefault = 0, + __pyx_e_4cuda_7ccudart_cudaEnableLegacyStream = 1, + __pyx_e_4cuda_7ccudart_cudaEnablePerThreadDefaultStream = 2 +}; + +/* "cuda/ccudart.pxd":1034 + * cudaEnablePerThreadDefaultStream = 2 + * + * cdef enum cudaGraphDebugDotFlags: # <<<<<<<<<<<<<< + * cudaGraphDebugDotFlagsVerbose = 1 + * cudaGraphDebugDotFlagsKernelNodeParams = 4 + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphDebugDotFlags { + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsVerbose = 1, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsKernelNodeParams = 4, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsMemcpyNodeParams = 8, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsMemsetNodeParams = 16, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsHostNodeParams = 32, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsEventNodeParams = 64, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsExtSemasSignalNodeParams = 0x80, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsExtSemasWaitNodeParams = 0x100, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsKernelNodeAttributes = 0x200, + __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsHandles = 0x400 +}; + +/* "cuda/ccudart.pxd":1046 + * cudaGraphDebugDotFlagsHandles = 1024 + * + * cdef enum cudaGraphInstantiateFlags: # <<<<<<<<<<<<<< + * cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 + * + */ +enum __pyx_t_4cuda_7ccudart_cudaGraphInstantiateFlags { + __pyx_e_4cuda_7ccudart_cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 +}; + +/* "cuda/ccudart.pxd":1049 + * cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 + * + * cdef enum cudaSurfaceBoundaryMode: # <<<<<<<<<<<<<< + * cudaBoundaryModeZero = 0 + * cudaBoundaryModeClamp = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaSurfaceBoundaryMode { + __pyx_e_4cuda_7ccudart_cudaBoundaryModeZero = 0, + __pyx_e_4cuda_7ccudart_cudaBoundaryModeClamp = 1, + __pyx_e_4cuda_7ccudart_cudaBoundaryModeTrap = 2 +}; + +/* "cuda/ccudart.pxd":1054 + * cudaBoundaryModeTrap = 2 + * + * cdef enum cudaSurfaceFormatMode: # <<<<<<<<<<<<<< + * cudaFormatModeForced = 0 + * cudaFormatModeAuto = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaSurfaceFormatMode { + __pyx_e_4cuda_7ccudart_cudaFormatModeForced = 0, + __pyx_e_4cuda_7ccudart_cudaFormatModeAuto = 1 +}; + +/* "cuda/ccudart.pxd":1060 + * ctypedef unsigned long long cudaSurfaceObject_t + * + * cdef enum cudaTextureAddressMode: # <<<<<<<<<<<<<< + * cudaAddressModeWrap = 0 + * cudaAddressModeClamp = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaTextureAddressMode { + __pyx_e_4cuda_7ccudart_cudaAddressModeWrap = 0, + __pyx_e_4cuda_7ccudart_cudaAddressModeClamp = 1, + __pyx_e_4cuda_7ccudart_cudaAddressModeMirror = 2, + __pyx_e_4cuda_7ccudart_cudaAddressModeBorder = 3 +}; + +/* "cuda/ccudart.pxd":1066 + * cudaAddressModeBorder = 3 + * + * cdef enum cudaTextureFilterMode: # <<<<<<<<<<<<<< + * cudaFilterModePoint = 0 + * cudaFilterModeLinear = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaTextureFilterMode { + __pyx_e_4cuda_7ccudart_cudaFilterModePoint = 0, + __pyx_e_4cuda_7ccudart_cudaFilterModeLinear = 1 +}; + +/* "cuda/ccudart.pxd":1070 + * cudaFilterModeLinear = 1 + * + * cdef enum cudaTextureReadMode: # <<<<<<<<<<<<<< + * cudaReadModeElementType = 0 + * cudaReadModeNormalizedFloat = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaTextureReadMode { + __pyx_e_4cuda_7ccudart_cudaReadModeElementType = 0, + __pyx_e_4cuda_7ccudart_cudaReadModeNormalizedFloat = 1 +}; + +/* "cuda/ccudart.pxd":1091 + * ctypedef unsigned long long cudaTextureObject_t + * + * cdef enum cudaDataType_t: # <<<<<<<<<<<<<< + * CUDA_R_16F = 2 + * CUDA_C_16F = 6 + */ +enum __pyx_t_4cuda_7ccudart_cudaDataType_t { + __pyx_e_4cuda_7ccudart_CUDA_R_16F = 2, + __pyx_e_4cuda_7ccudart_CUDA_C_16F = 6, + __pyx_e_4cuda_7ccudart_CUDA_R_16BF = 14, + __pyx_e_4cuda_7ccudart_CUDA_C_16BF = 15, + __pyx_e_4cuda_7ccudart_CUDA_R_32F = 0, + __pyx_e_4cuda_7ccudart_CUDA_C_32F = 4, + __pyx_e_4cuda_7ccudart_CUDA_R_64F = 1, + __pyx_e_4cuda_7ccudart_CUDA_C_64F = 5, + __pyx_e_4cuda_7ccudart_CUDA_R_4I = 16, + __pyx_e_4cuda_7ccudart_CUDA_C_4I = 17, + __pyx_e_4cuda_7ccudart_CUDA_R_4U = 18, + __pyx_e_4cuda_7ccudart_CUDA_C_4U = 19, + __pyx_e_4cuda_7ccudart_CUDA_R_8I = 3, + __pyx_e_4cuda_7ccudart_CUDA_C_8I = 7, + __pyx_e_4cuda_7ccudart_CUDA_R_8U = 8, + __pyx_e_4cuda_7ccudart_CUDA_C_8U = 9, + __pyx_e_4cuda_7ccudart_CUDA_R_16I = 20, + __pyx_e_4cuda_7ccudart_CUDA_C_16I = 21, + __pyx_e_4cuda_7ccudart_CUDA_R_16U = 22, + __pyx_e_4cuda_7ccudart_CUDA_C_16U = 23, + __pyx_e_4cuda_7ccudart_CUDA_R_32I = 10, + __pyx_e_4cuda_7ccudart_CUDA_C_32I = 11, + __pyx_e_4cuda_7ccudart_CUDA_R_32U = 12, + __pyx_e_4cuda_7ccudart_CUDA_C_32U = 13, + __pyx_e_4cuda_7ccudart_CUDA_R_64I = 24, + __pyx_e_4cuda_7ccudart_CUDA_C_64I = 25, + __pyx_e_4cuda_7ccudart_CUDA_R_64U = 26, + __pyx_e_4cuda_7ccudart_CUDA_C_64U = 27 +}; + +/* "cuda/ccudart.pxd":1123 + * ctypedef cudaDataType_t cudaDataType + * + * cdef enum libraryPropertyType_t: # <<<<<<<<<<<<<< + * MAJOR_VERSION = 0 + * MINOR_VERSION = 1 + */ +enum __pyx_t_4cuda_7ccudart_libraryPropertyType_t { + __pyx_e_4cuda_7ccudart_MAJOR_VERSION = 0, + __pyx_e_4cuda_7ccudart_MINOR_VERSION = 1, + __pyx_e_4cuda_7ccudart_PATCH_LEVEL = 2 +}; + +/* "cuda/ccudart.pxd":1701 + * cdef cudaError_t cudaGraphicsVDPAURegisterOutputSurface(cudaGraphicsResource** resource, VdpOutputSurface vdpSurface, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver + * + * cdef enum cudaGLDeviceList: # <<<<<<<<<<<<<< + * cudaGLDeviceListAll = 1 + * cudaGLDeviceListCurrentFrame = 2 + */ +enum __pyx_t_4cuda_7ccudart_cudaGLDeviceList { + __pyx_e_4cuda_7ccudart_cudaGLDeviceListAll = 1, + __pyx_e_4cuda_7ccudart_cudaGLDeviceListCurrentFrame = 2, + __pyx_e_4cuda_7ccudart_cudaGLDeviceListNextFrame = 3 +}; + +/* "cuda/ccudart.pxd":1712 + * cdef cudaError_t cudaGraphicsGLRegisterBuffer(cudaGraphicsResource** resource, GLuint buffer, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver + * + * cdef enum cudaGLMapFlags: # <<<<<<<<<<<<<< + * cudaGLMapFlagsNone = 0 + * cudaGLMapFlagsReadOnly = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaGLMapFlags { + __pyx_e_4cuda_7ccudart_cudaGLMapFlagsNone = 0, + __pyx_e_4cuda_7ccudart_cudaGLMapFlagsReadOnly = 1, + __pyx_e_4cuda_7ccudart_cudaGLMapFlagsWriteDiscard = 2 +}; + +/* "cuda/ccudart.pxd":1717 + * cudaGLMapFlagsWriteDiscard = 2 + * + * cdef enum cudaEglFrameType_enum: # <<<<<<<<<<<<<< + * cudaEglFrameTypeArray = 0 + * cudaEglFrameTypePitch = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaEglFrameType_enum { + __pyx_e_4cuda_7ccudart_cudaEglFrameTypeArray = 0, + __pyx_e_4cuda_7ccudart_cudaEglFrameTypePitch = 1 +}; + +/* "cuda/ccudart.pxd":1723 + * ctypedef cudaEglFrameType_enum cudaEglFrameType + * + * cdef enum cudaEglResourceLocationFlags_enum: # <<<<<<<<<<<<<< + * cudaEglResourceLocationSysmem = 0 + * cudaEglResourceLocationVidmem = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaEglResourceLocationFlags_enum { + __pyx_e_4cuda_7ccudart_cudaEglResourceLocationSysmem = 0, + __pyx_e_4cuda_7ccudart_cudaEglResourceLocationVidmem = 1 +}; + +/* "cuda/ccudart.pxd":1729 + * ctypedef cudaEglResourceLocationFlags_enum cudaEglResourceLocationFlags + * + * cdef enum cudaEglColorFormat_enum: # <<<<<<<<<<<<<< + * cudaEglColorFormatYUV420Planar = 0 + * cudaEglColorFormatYUV420SemiPlanar = 1 + */ +enum __pyx_t_4cuda_7ccudart_cudaEglColorFormat_enum { + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar = 0, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar = 1, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422Planar = 2, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422SemiPlanar = 3, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatARGB = 6, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatRGBA = 7, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatL = 8, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatR = 9, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444Planar = 10, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444SemiPlanar = 11, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUYV422 = 12, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatUYVY422 = 13, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatABGR = 14, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBGRA = 15, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatA = 16, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatRG = 17, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatAYUV = 18, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444SemiPlanar = 19, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422SemiPlanar = 20, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar = 21, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_444SemiPlanar = 22, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar = 23, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_444SemiPlanar = 24, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_420SemiPlanar = 25, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatVYUY_ER = 26, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatUYVY_ER = 27, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUYV_ER = 28, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVYU_ER = 29, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUVA_ER = 31, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatAYUV_ER = 32, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444Planar_ER = 33, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422Planar_ER = 34, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar_ER = 35, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444SemiPlanar_ER = 36, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422SemiPlanar_ER = 37, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar_ER = 38, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444Planar_ER = 39, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422Planar_ER = 40, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar_ER = 41, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444SemiPlanar_ER = 42, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422SemiPlanar_ER = 43, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar_ER = 44, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerRGGB = 45, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerBGGR = 46, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerGRBG = 47, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerGBRG = 48, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10RGGB = 49, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10BGGR = 50, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10GRBG = 51, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10GBRG = 52, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12RGGB = 53, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12BGGR = 54, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12GRBG = 55, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12GBRG = 56, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14RGGB = 57, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14BGGR = 58, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14GRBG = 59, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14GBRG = 60, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20RGGB = 61, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20BGGR = 62, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20GRBG = 63, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20GBRG = 64, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444Planar = 65, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422Planar = 66, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar = 67, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspRGGB = 68, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspBGGR = 69, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspGRBG = 70, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspGBRG = 71, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerBCCR = 72, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerRCCB = 73, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerCRBC = 74, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerCBRC = 75, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10CCCC = 76, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12BCCR = 77, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12RCCB = 78, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12CRBC = 79, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12CBRC = 80, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12CCCC = 81, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY = 82, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar_2020 = 83, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar_2020 = 84, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar_2020 = 85, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar_2020 = 86, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar_709 = 87, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar_709 = 88, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar_709 = 89, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar_709 = 90, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_709 = 91, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_2020 = 92, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_422SemiPlanar_2020 = 93, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_422SemiPlanar = 94, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_422SemiPlanar_709 = 95, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY_ER = 96, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY_709_ER = 97, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10_ER = 98, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10_709_ER = 99, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12_ER = 0x64, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12_709_ER = 0x65, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUVA = 0x66, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVYU = 0x68, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatVYUY = 0x69, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_ER = 0x6A, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_709_ER = 0x6B, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_444SemiPlanar_ER = 0x6C, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_444SemiPlanar_709_ER = 0x6D, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_420SemiPlanar_ER = 0x6E, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_420SemiPlanar_709_ER = 0x6F, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_444SemiPlanar_ER = 0x70, + __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 0x71 +}; + +/* "cuda/ccudart.pxd":1896 + * cdef cudaError_t cudaEventCreateFromEGLSync(cudaEvent_t* phEvent, EGLSyncKHR eglSync, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver + * + * cdef enum: cudaHostAllocDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostAllocPortable = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostAllocDefault = 0 +}; + +/* "cuda/ccudart.pxd":1898 + * cdef enum: cudaHostAllocDefault = 0 + * + * cdef enum: cudaHostAllocPortable = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostAllocMapped = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostAllocPortable = 1 +}; + +/* "cuda/ccudart.pxd":1900 + * cdef enum: cudaHostAllocPortable = 1 + * + * cdef enum: cudaHostAllocMapped = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostAllocWriteCombined = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostAllocMapped = 2 +}; + +/* "cuda/ccudart.pxd":1902 + * cdef enum: cudaHostAllocMapped = 2 + * + * cdef enum: cudaHostAllocWriteCombined = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostRegisterDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostAllocWriteCombined = 4 +}; + +/* "cuda/ccudart.pxd":1904 + * cdef enum: cudaHostAllocWriteCombined = 4 + * + * cdef enum: cudaHostRegisterDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostRegisterPortable = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostRegisterDefault = 0 +}; + +/* "cuda/ccudart.pxd":1906 + * cdef enum: cudaHostRegisterDefault = 0 + * + * cdef enum: cudaHostRegisterPortable = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostRegisterMapped = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostRegisterPortable = 1 +}; + +/* "cuda/ccudart.pxd":1908 + * cdef enum: cudaHostRegisterPortable = 1 + * + * cdef enum: cudaHostRegisterMapped = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostRegisterIoMemory = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostRegisterMapped = 2 +}; + +/* "cuda/ccudart.pxd":1910 + * cdef enum: cudaHostRegisterMapped = 2 + * + * cdef enum: cudaHostRegisterIoMemory = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaHostRegisterReadOnly = 8 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostRegisterIoMemory = 4 +}; + +/* "cuda/ccudart.pxd":1912 + * cdef enum: cudaHostRegisterIoMemory = 4 + * + * cdef enum: cudaHostRegisterReadOnly = 8 # <<<<<<<<<<<<<< + * + * cdef enum: cudaPeerAccessDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaHostRegisterReadOnly = 8 +}; + +/* "cuda/ccudart.pxd":1914 + * cdef enum: cudaHostRegisterReadOnly = 8 + * + * cdef enum: cudaPeerAccessDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaStreamDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaPeerAccessDefault = 0 +}; + +/* "cuda/ccudart.pxd":1916 + * cdef enum: cudaPeerAccessDefault = 0 + * + * cdef enum: cudaStreamDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaStreamNonBlocking = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaStreamDefault = 0 +}; + +/* "cuda/ccudart.pxd":1918 + * cdef enum: cudaStreamDefault = 0 + * + * cdef enum: cudaStreamNonBlocking = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaStreamLegacy = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaStreamNonBlocking = 1 +}; + +/* "cuda/ccudart.pxd":1920 + * cdef enum: cudaStreamNonBlocking = 1 + * + * cdef enum: cudaStreamLegacy = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaStreamPerThread = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaStreamLegacy = 1 +}; + +/* "cuda/ccudart.pxd":1922 + * cdef enum: cudaStreamLegacy = 1 + * + * cdef enum: cudaStreamPerThread = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaStreamPerThread = 2 +}; + +/* "cuda/ccudart.pxd":1924 + * cdef enum: cudaStreamPerThread = 2 + * + * cdef enum: cudaEventDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventBlockingSync = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventDefault = 0 +}; + +/* "cuda/ccudart.pxd":1926 + * cdef enum: cudaEventDefault = 0 + * + * cdef enum: cudaEventBlockingSync = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventDisableTiming = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventBlockingSync = 1 +}; + +/* "cuda/ccudart.pxd":1928 + * cdef enum: cudaEventBlockingSync = 1 + * + * cdef enum: cudaEventDisableTiming = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventInterprocess = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventDisableTiming = 2 +}; + +/* "cuda/ccudart.pxd":1930 + * cdef enum: cudaEventDisableTiming = 2 + * + * cdef enum: cudaEventInterprocess = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventRecordDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventInterprocess = 4 +}; + +/* "cuda/ccudart.pxd":1932 + * cdef enum: cudaEventInterprocess = 4 + * + * cdef enum: cudaEventRecordDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventRecordExternal = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventRecordDefault = 0 +}; + +/* "cuda/ccudart.pxd":1934 + * cdef enum: cudaEventRecordDefault = 0 + * + * cdef enum: cudaEventRecordExternal = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventWaitDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventRecordExternal = 1 +}; + +/* "cuda/ccudart.pxd":1936 + * cdef enum: cudaEventRecordExternal = 1 + * + * cdef enum: cudaEventWaitDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaEventWaitExternal = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventWaitDefault = 0 +}; + +/* "cuda/ccudart.pxd":1938 + * cdef enum: cudaEventWaitDefault = 0 + * + * cdef enum: cudaEventWaitExternal = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceScheduleAuto = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaEventWaitExternal = 1 +}; + +/* "cuda/ccudart.pxd":1940 + * cdef enum: cudaEventWaitExternal = 1 + * + * cdef enum: cudaDeviceScheduleAuto = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceScheduleSpin = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceScheduleAuto = 0 +}; + +/* "cuda/ccudart.pxd":1942 + * cdef enum: cudaDeviceScheduleAuto = 0 + * + * cdef enum: cudaDeviceScheduleSpin = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceScheduleYield = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceScheduleSpin = 1 +}; + +/* "cuda/ccudart.pxd":1944 + * cdef enum: cudaDeviceScheduleSpin = 1 + * + * cdef enum: cudaDeviceScheduleYield = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceScheduleBlockingSync = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceScheduleYield = 2 +}; + +/* "cuda/ccudart.pxd":1946 + * cdef enum: cudaDeviceScheduleYield = 2 + * + * cdef enum: cudaDeviceScheduleBlockingSync = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceBlockingSync = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceScheduleBlockingSync = 4 +}; + +/* "cuda/ccudart.pxd":1948 + * cdef enum: cudaDeviceScheduleBlockingSync = 4 + * + * cdef enum: cudaDeviceBlockingSync = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceScheduleMask = 7 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceBlockingSync = 4 +}; + +/* "cuda/ccudart.pxd":1950 + * cdef enum: cudaDeviceBlockingSync = 4 + * + * cdef enum: cudaDeviceScheduleMask = 7 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceMapHost = 8 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceScheduleMask = 7 +}; + +/* "cuda/ccudart.pxd":1952 + * cdef enum: cudaDeviceScheduleMask = 7 + * + * cdef enum: cudaDeviceMapHost = 8 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceLmemResizeToMax = 16 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceMapHost = 8 +}; + +/* "cuda/ccudart.pxd":1954 + * cdef enum: cudaDeviceMapHost = 8 + * + * cdef enum: cudaDeviceLmemResizeToMax = 16 # <<<<<<<<<<<<<< + * + * cdef enum: cudaDeviceMask = 31 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceLmemResizeToMax = 16 +}; + +/* "cuda/ccudart.pxd":1956 + * cdef enum: cudaDeviceLmemResizeToMax = 16 + * + * cdef enum: cudaDeviceMask = 31 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArrayDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaDeviceMask = 31 +}; + +/* "cuda/ccudart.pxd":1958 + * cdef enum: cudaDeviceMask = 31 + * + * cdef enum: cudaArrayDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArrayLayered = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArrayDefault = 0 +}; + +/* "cuda/ccudart.pxd":1960 + * cdef enum: cudaArrayDefault = 0 + * + * cdef enum: cudaArrayLayered = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArraySurfaceLoadStore = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArrayLayered = 1 +}; + +/* "cuda/ccudart.pxd":1962 + * cdef enum: cudaArrayLayered = 1 + * + * cdef enum: cudaArraySurfaceLoadStore = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArrayCubemap = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArraySurfaceLoadStore = 2 +}; + +/* "cuda/ccudart.pxd":1964 + * cdef enum: cudaArraySurfaceLoadStore = 2 + * + * cdef enum: cudaArrayCubemap = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArrayTextureGather = 8 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArrayCubemap = 4 +}; + +/* "cuda/ccudart.pxd":1966 + * cdef enum: cudaArrayCubemap = 4 + * + * cdef enum: cudaArrayTextureGather = 8 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArrayColorAttachment = 32 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArrayTextureGather = 8 +}; + +/* "cuda/ccudart.pxd":1968 + * cdef enum: cudaArrayTextureGather = 8 + * + * cdef enum: cudaArrayColorAttachment = 32 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArraySparse = 64 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArrayColorAttachment = 32 +}; + +/* "cuda/ccudart.pxd":1970 + * cdef enum: cudaArrayColorAttachment = 32 + * + * cdef enum: cudaArraySparse = 64 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArrayDeferredMapping = 128 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArraySparse = 64 +}; + +/* "cuda/ccudart.pxd":1972 + * cdef enum: cudaArraySparse = 64 + * + * cdef enum: cudaArrayDeferredMapping = 128 # <<<<<<<<<<<<<< + * + * cdef enum: cudaIpcMemLazyEnablePeerAccess = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArrayDeferredMapping = 0x80 +}; + +/* "cuda/ccudart.pxd":1974 + * cdef enum: cudaArrayDeferredMapping = 128 + * + * cdef enum: cudaIpcMemLazyEnablePeerAccess = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaMemAttachGlobal = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaIpcMemLazyEnablePeerAccess = 1 +}; + +/* "cuda/ccudart.pxd":1976 + * cdef enum: cudaIpcMemLazyEnablePeerAccess = 1 + * + * cdef enum: cudaMemAttachGlobal = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaMemAttachHost = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaMemAttachGlobal = 1 +}; + +/* "cuda/ccudart.pxd":1978 + * cdef enum: cudaMemAttachGlobal = 1 + * + * cdef enum: cudaMemAttachHost = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaMemAttachSingle = 4 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaMemAttachHost = 2 +}; + +/* "cuda/ccudart.pxd":1980 + * cdef enum: cudaMemAttachHost = 2 + * + * cdef enum: cudaMemAttachSingle = 4 # <<<<<<<<<<<<<< + * + * cdef enum: cudaOccupancyDefault = 0 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaMemAttachSingle = 4 +}; + +/* "cuda/ccudart.pxd":1982 + * cdef enum: cudaMemAttachSingle = 4 + * + * cdef enum: cudaOccupancyDefault = 0 # <<<<<<<<<<<<<< + * + * cdef enum: cudaOccupancyDisableCachingOverride = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaOccupancyDefault = 0 +}; + +/* "cuda/ccudart.pxd":1984 + * cdef enum: cudaOccupancyDefault = 0 + * + * cdef enum: cudaOccupancyDisableCachingOverride = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaCpuDeviceId = -1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaOccupancyDisableCachingOverride = 1 +}; + +/* "cuda/ccudart.pxd":1986 + * cdef enum: cudaOccupancyDisableCachingOverride = 1 + * + * cdef enum: cudaCpuDeviceId = -1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaInvalidDeviceId = -2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaCpuDeviceId = -1L +}; + +/* "cuda/ccudart.pxd":1988 + * cdef enum: cudaCpuDeviceId = -1 + * + * cdef enum: cudaInvalidDeviceId = -2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaCooperativeLaunchMultiDeviceNoPreSync = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaInvalidDeviceId = -2L +}; + +/* "cuda/ccudart.pxd":1990 + * cdef enum: cudaInvalidDeviceId = -2 + * + * cdef enum: cudaCooperativeLaunchMultiDeviceNoPreSync = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaCooperativeLaunchMultiDeviceNoPostSync = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaCooperativeLaunchMultiDeviceNoPreSync = 1 +}; + +/* "cuda/ccudart.pxd":1992 + * cdef enum: cudaCooperativeLaunchMultiDeviceNoPreSync = 1 + * + * cdef enum: cudaCooperativeLaunchMultiDeviceNoPostSync = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaArraySparsePropertiesSingleMipTail = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaCooperativeLaunchMultiDeviceNoPostSync = 2 +}; + +/* "cuda/ccudart.pxd":1994 + * cdef enum: cudaCooperativeLaunchMultiDeviceNoPostSync = 2 + * + * cdef enum: cudaArraySparsePropertiesSingleMipTail = 1 # <<<<<<<<<<<<<< + * + * cdef enum: CUDA_IPC_HANDLE_SIZE = 64 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaArraySparsePropertiesSingleMipTail = 1 +}; + +/* "cuda/ccudart.pxd":1996 + * cdef enum: cudaArraySparsePropertiesSingleMipTail = 1 + * + * cdef enum: CUDA_IPC_HANDLE_SIZE = 64 # <<<<<<<<<<<<<< + * + * cdef enum: cudaExternalMemoryDedicated = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_CUDA_IPC_HANDLE_SIZE = 64 +}; + +/* "cuda/ccudart.pxd":1998 + * cdef enum: CUDA_IPC_HANDLE_SIZE = 64 + * + * cdef enum: cudaExternalMemoryDedicated = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaExternalMemoryDedicated = 1 +}; + +/* "cuda/ccudart.pxd":2000 + * cdef enum: cudaExternalMemoryDedicated = 1 + * + * cdef enum: cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 +}; + +/* "cuda/ccudart.pxd":2002 + * cdef enum: cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 + * + * cdef enum: cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaNvSciSyncAttrSignal = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 +}; + +/* "cuda/ccudart.pxd":2004 + * cdef enum: cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 + * + * cdef enum: cudaNvSciSyncAttrSignal = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaNvSciSyncAttrWait = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaNvSciSyncAttrSignal = 1 +}; + +/* "cuda/ccudart.pxd":2006 + * cdef enum: cudaNvSciSyncAttrSignal = 1 + * + * cdef enum: cudaNvSciSyncAttrWait = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceType1D = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaNvSciSyncAttrWait = 2 +}; + +/* "cuda/ccudart.pxd":2008 + * cdef enum: cudaNvSciSyncAttrWait = 2 + * + * cdef enum: cudaSurfaceType1D = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceType2D = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceType1D = 1 +}; + +/* "cuda/ccudart.pxd":2010 + * cdef enum: cudaSurfaceType1D = 1 + * + * cdef enum: cudaSurfaceType2D = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceType3D = 3 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceType2D = 2 +}; + +/* "cuda/ccudart.pxd":2012 + * cdef enum: cudaSurfaceType2D = 2 + * + * cdef enum: cudaSurfaceType3D = 3 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceTypeCubemap = 12 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceType3D = 3 +}; + +/* "cuda/ccudart.pxd":2014 + * cdef enum: cudaSurfaceType3D = 3 + * + * cdef enum: cudaSurfaceTypeCubemap = 12 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceType1DLayered = 241 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceTypeCubemap = 12 +}; + +/* "cuda/ccudart.pxd":2016 + * cdef enum: cudaSurfaceTypeCubemap = 12 + * + * cdef enum: cudaSurfaceType1DLayered = 241 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceType2DLayered = 242 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceType1DLayered = 0xF1 +}; + +/* "cuda/ccudart.pxd":2018 + * cdef enum: cudaSurfaceType1DLayered = 241 + * + * cdef enum: cudaSurfaceType2DLayered = 242 # <<<<<<<<<<<<<< + * + * cdef enum: cudaSurfaceTypeCubemapLayered = 252 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceType2DLayered = 0xF2 +}; + +/* "cuda/ccudart.pxd":2020 + * cdef enum: cudaSurfaceType2DLayered = 242 + * + * cdef enum: cudaSurfaceTypeCubemapLayered = 252 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureType1D = 1 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaSurfaceTypeCubemapLayered = 0xFC +}; + +/* "cuda/ccudart.pxd":2022 + * cdef enum: cudaSurfaceTypeCubemapLayered = 252 + * + * cdef enum: cudaTextureType1D = 1 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureType2D = 2 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureType1D = 1 +}; + +/* "cuda/ccudart.pxd":2024 + * cdef enum: cudaTextureType1D = 1 + * + * cdef enum: cudaTextureType2D = 2 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureType3D = 3 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureType2D = 2 +}; + +/* "cuda/ccudart.pxd":2026 + * cdef enum: cudaTextureType2D = 2 + * + * cdef enum: cudaTextureType3D = 3 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureTypeCubemap = 12 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureType3D = 3 +}; + +/* "cuda/ccudart.pxd":2028 + * cdef enum: cudaTextureType3D = 3 + * + * cdef enum: cudaTextureTypeCubemap = 12 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureType1DLayered = 241 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureTypeCubemap = 12 +}; + +/* "cuda/ccudart.pxd":2030 + * cdef enum: cudaTextureTypeCubemap = 12 + * + * cdef enum: cudaTextureType1DLayered = 241 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureType2DLayered = 242 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureType1DLayered = 0xF1 +}; + +/* "cuda/ccudart.pxd":2032 + * cdef enum: cudaTextureType1DLayered = 241 + * + * cdef enum: cudaTextureType2DLayered = 242 # <<<<<<<<<<<<<< + * + * cdef enum: cudaTextureTypeCubemapLayered = 252 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureType2DLayered = 0xF2 +}; + +/* "cuda/ccudart.pxd":2034 + * cdef enum: cudaTextureType2DLayered = 242 + * + * cdef enum: cudaTextureTypeCubemapLayered = 252 # <<<<<<<<<<<<<< + * + * cdef enum: CUDART_VERSION = 11060 + */ +enum { + __pyx_e_4cuda_7ccudart_cudaTextureTypeCubemapLayered = 0xFC +}; + +/* "cuda/ccudart.pxd":2036 + * cdef enum: cudaTextureTypeCubemapLayered = 252 + * + * cdef enum: CUDART_VERSION = 11060 # <<<<<<<<<<<<<< + * + * cdef enum: __CUDART_API_VERSION = 11060 + */ +enum { + __pyx_e_4cuda_7ccudart_CUDART_VERSION = 0x2B34 +}; + +/* "cuda/ccudart.pxd":2038 + * cdef enum: CUDART_VERSION = 11060 + * + * cdef enum: __CUDART_API_VERSION = 11060 # <<<<<<<<<<<<<< + * + * cdef enum: CUDA_EGL_MAX_PLANES = 3 + */ +enum { + __pyx_e_4cuda_7ccudart___CUDART_API_VERSION = 0x2B34 +}; + +/* "cuda/ccudart.pxd":2040 + * cdef enum: __CUDART_API_VERSION = 11060 + * + * cdef enum: CUDA_EGL_MAX_PLANES = 3 # <<<<<<<<<<<<<< + */ +enum { + __pyx_e_4cuda_7ccudart_CUDA_EGL_MAX_PLANES = 3 +}; + +/* "cuda/ccudart.pxd":15 + * cudaRoundMinInf = 3 + * + * cdef struct dim3: # <<<<<<<<<<<<<< + * unsigned int x + * unsigned int y + */ +struct __pyx_t_4cuda_7ccudart_dim3 { + unsigned int x; + unsigned int y; + unsigned int z; +}; + +/* "cuda/ccudart.pxd":178 + * cudaChannelFormatKindUnsignedBlockCompressed7SRGB = 30 + * + * cdef struct cudaChannelFormatDesc: # <<<<<<<<<<<<<< + * int x + * int y + */ +struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc { + int x; + int y; + int z; + int w; + enum __pyx_t_4cuda_7ccudart_cudaChannelFormatKind f; +}; + +/* "cuda/ccudart.pxd":188 + * cdef struct cudaArray: + * pass + * ctypedef cudaArray* cudaArray_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct cudaArray *__pyx_t_4cuda_7ccudart_cudaArray_t; + +/* "cuda/ccudart.pxd":193 + * cdef struct cudaArray: + * pass + * ctypedef cudaArray* cudaArray_const_t # <<<<<<<<<<<<<< + * + * + */ +typedef struct cudaArray *__pyx_t_4cuda_7ccudart_cudaArray_const_t; + +/* "cuda/ccudart.pxd":199 + * cdef struct cudaMipmappedArray: + * pass + * ctypedef cudaMipmappedArray* cudaMipmappedArray_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct cudaMipmappedArray *__pyx_t_4cuda_7ccudart_cudaMipmappedArray_t; + +/* "cuda/ccudart.pxd":204 + * cdef struct cudaMipmappedArray: + * pass + * ctypedef cudaMipmappedArray* cudaMipmappedArray_const_t # <<<<<<<<<<<<<< + * + * + */ +typedef struct cudaMipmappedArray *__pyx_t_4cuda_7ccudart_cudaMipmappedArray_const_t; + +/* "cuda/ccudart.pxd":207 + * + * + * cdef struct _cudaArraySparseProperties_tileExtent_s: # <<<<<<<<<<<<<< + * unsigned int width + * unsigned int height + */ +struct __pyx_t_4cuda_7ccudart__cudaArraySparseProperties_tileExtent_s { + unsigned int width; + unsigned int height; + unsigned int depth; +}; + +/* "cuda/ccudart.pxd":212 + * unsigned int depth + * + * cdef struct cudaArraySparseProperties: # <<<<<<<<<<<<<< + * _cudaArraySparseProperties_tileExtent_s tileExtent + * unsigned int miptailFirstLevel + */ +struct __pyx_t_4cuda_7ccudart_cudaArraySparseProperties { + struct __pyx_t_4cuda_7ccudart__cudaArraySparseProperties_tileExtent_s tileExtent; + unsigned int miptailFirstLevel; + unsigned PY_LONG_LONG miptailSize; + unsigned int flags; + unsigned int reserved[4]; +}; + +/* "cuda/ccudart.pxd":219 + * unsigned int reserved[4] + * + * cdef struct cudaArrayMemoryRequirements: # <<<<<<<<<<<<<< + * size_t size + * size_t alignment + */ +struct __pyx_t_4cuda_7ccudart_cudaArrayMemoryRequirements { + size_t size; + size_t alignment; + unsigned int reserved[4]; +}; + +/* "cuda/ccudart.pxd":237 + * cudaMemcpyDefault = 4 + * + * cdef struct cudaPitchedPtr: # <<<<<<<<<<<<<< + * void* ptr + * size_t pitch + */ +struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr { + void *ptr; + size_t pitch; + size_t xsize; + size_t ysize; +}; + +/* "cuda/ccudart.pxd":243 + * size_t ysize + * + * cdef struct cudaExtent: # <<<<<<<<<<<<<< + * size_t width + * size_t height + */ +struct __pyx_t_4cuda_7ccudart_cudaExtent { + size_t width; + size_t height; + size_t depth; +}; + +/* "cuda/ccudart.pxd":248 + * size_t depth + * + * cdef struct cudaPos: # <<<<<<<<<<<<<< + * size_t x + * size_t y + */ +struct __pyx_t_4cuda_7ccudart_cudaPos { + size_t x; + size_t y; + size_t z; +}; + +/* "cuda/ccudart.pxd":253 + * size_t z + * + * cdef struct cudaMemcpy3DParms: # <<<<<<<<<<<<<< + * cudaArray_t srcArray + * cudaPos srcPos + */ +struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DParms { + __pyx_t_4cuda_7ccudart_cudaArray_t srcArray; + struct __pyx_t_4cuda_7ccudart_cudaPos srcPos; + struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr srcPtr; + __pyx_t_4cuda_7ccudart_cudaArray_t dstArray; + struct __pyx_t_4cuda_7ccudart_cudaPos dstPos; + struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr dstPtr; + struct __pyx_t_4cuda_7ccudart_cudaExtent extent; + enum __pyx_t_4cuda_7ccudart_cudaMemcpyKind kind; +}; + +/* "cuda/ccudart.pxd":263 + * cudaMemcpyKind kind + * + * cdef struct cudaMemcpy3DPeerParms: # <<<<<<<<<<<<<< + * cudaArray_t srcArray + * cudaPos srcPos + */ +struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DPeerParms { + __pyx_t_4cuda_7ccudart_cudaArray_t srcArray; + struct __pyx_t_4cuda_7ccudart_cudaPos srcPos; + struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr srcPtr; + int srcDevice; + __pyx_t_4cuda_7ccudart_cudaArray_t dstArray; + struct __pyx_t_4cuda_7ccudart_cudaPos dstPos; + struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr dstPtr; + int dstDevice; + struct __pyx_t_4cuda_7ccudart_cudaExtent extent; +}; + +/* "cuda/ccudart.pxd":274 + * cudaExtent extent + * + * cdef struct cudaMemsetParams: # <<<<<<<<<<<<<< + * void* dst + * size_t pitch + */ +struct __pyx_t_4cuda_7ccudart_cudaMemsetParams { + void *dst; + size_t pitch; + unsigned int value; + unsigned int elementSize; + size_t width; + size_t height; +}; + +/* "cuda/ccudart.pxd":287 + * cudaAccessPropertyPersisting = 2 + * + * cdef struct cudaAccessPolicyWindow: # <<<<<<<<<<<<<< + * void* base_ptr + * size_t num_bytes + */ +struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow { + void *base_ptr; + size_t num_bytes; + float hitRatio; + enum __pyx_t_4cuda_7ccudart_cudaAccessProperty hitProp; + enum __pyx_t_4cuda_7ccudart_cudaAccessProperty missProp; +}; + +/* "cuda/ccudart.pxd":294 + * cudaAccessProperty missProp + * + * ctypedef void (*cudaHostFn_t)(void* userData) # <<<<<<<<<<<<<< + * + * cdef struct cudaHostNodeParams: + */ +typedef void (*__pyx_t_4cuda_7ccudart_cudaHostFn_t)(void *); + +/* "cuda/ccudart.pxd":296 + * ctypedef void (*cudaHostFn_t)(void* userData) + * + * cdef struct cudaHostNodeParams: # <<<<<<<<<<<<<< + * cudaHostFn_t fn + * void* userData + */ +struct __pyx_t_4cuda_7ccudart_cudaHostNodeParams { + __pyx_t_4cuda_7ccudart_cudaHostFn_t fn; + void *userData; +}; + +/* "cuda/ccudart.pxd":320 + * cudaStreamAttributeSynchronizationPolicy = 3 + * + * cdef union cudaStreamAttrValue: # <<<<<<<<<<<<<< + * cudaAccessPolicyWindow accessPolicyWindow + * cudaSynchronizationPolicy syncPolicy + */ +union __pyx_t_4cuda_7ccudart_cudaStreamAttrValue { + struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow accessPolicyWindow; + enum __pyx_t_4cuda_7ccudart_cudaSynchronizationPolicy syncPolicy; +}; + +/* "cuda/ccudart.pxd":359 + * cudaKernelNodeAttributeCooperative = 2 + * + * cdef union cudaKernelNodeAttrValue: # <<<<<<<<<<<<<< + * cudaAccessPolicyWindow accessPolicyWindow + * int cooperative + */ +union __pyx_t_4cuda_7ccudart_cudaKernelNodeAttrValue { + struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow accessPolicyWindow; + int cooperative; +}; + +/* "cuda/ccudart.pxd":406 + * cudaResViewFormatUnsignedBlockCompressed7 = 34 + * + * cdef struct _cudaResourceDesc_res_res_array_s: # <<<<<<<<<<<<<< + * cudaArray_t array + * + */ +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_array_s { + __pyx_t_4cuda_7ccudart_cudaArray_t array; +}; + +/* "cuda/ccudart.pxd":409 + * cudaArray_t array + * + * cdef struct _cudaResourceDesc_res_res_mipmap_s: # <<<<<<<<<<<<<< + * cudaMipmappedArray_t mipmap + * + */ +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_mipmap_s { + __pyx_t_4cuda_7ccudart_cudaMipmappedArray_t mipmap; +}; + +/* "cuda/ccudart.pxd":412 + * cudaMipmappedArray_t mipmap + * + * cdef struct _cudaResourceDesc_res_res_linear_s: # <<<<<<<<<<<<<< + * void* devPtr + * cudaChannelFormatDesc desc + */ +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_linear_s { + void *devPtr; + struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc desc; + size_t sizeInBytes; +}; + +/* "cuda/ccudart.pxd":417 + * size_t sizeInBytes + * + * cdef struct _cudaResourceDesc_res_res_pitch2D_s: # <<<<<<<<<<<<<< + * void* devPtr + * cudaChannelFormatDesc desc + */ +struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_pitch2D_s { + void *devPtr; + struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc desc; + size_t width; + size_t height; + size_t pitchInBytes; +}; + +/* "cuda/ccudart.pxd":424 + * size_t pitchInBytes + * + * cdef union _cudaResourceDesc_res_u: # <<<<<<<<<<<<<< + * _cudaResourceDesc_res_res_array_s array + * _cudaResourceDesc_res_res_mipmap_s mipmap + */ +union __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_u { + struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_array_s array; + struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_mipmap_s mipmap; + struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_linear_s linear; + struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_pitch2D_s pitch2D; +}; + +/* "cuda/ccudart.pxd":430 + * _cudaResourceDesc_res_res_pitch2D_s pitch2D + * + * cdef struct cudaResourceDesc: # <<<<<<<<<<<<<< + * cudaResourceType resType + * _cudaResourceDesc_res_u res + */ +struct __pyx_t_4cuda_7ccudart_cudaResourceDesc { + enum __pyx_t_4cuda_7ccudart_cudaResourceType resType; + union __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_u res; +}; + +/* "cuda/ccudart.pxd":434 + * _cudaResourceDesc_res_u res + * + * cdef struct cudaResourceViewDesc: # <<<<<<<<<<<<<< + * cudaResourceViewFormat format + * size_t width + */ +struct __pyx_t_4cuda_7ccudart_cudaResourceViewDesc { + enum __pyx_t_4cuda_7ccudart_cudaResourceViewFormat format; + size_t width; + size_t height; + size_t depth; + unsigned int firstMipmapLevel; + unsigned int lastMipmapLevel; + unsigned int firstLayer; + unsigned int lastLayer; +}; + +/* "cuda/ccudart.pxd":444 + * unsigned int lastLayer + * + * cdef struct cudaPointerAttributes: # <<<<<<<<<<<<<< + * cudaMemoryType type + * int device + */ +struct __pyx_t_4cuda_7ccudart_cudaPointerAttributes { + enum __pyx_t_4cuda_7ccudart_cudaMemoryType type; + int device; + void *devicePointer; + void *hostPointer; +}; + +/* "cuda/ccudart.pxd":450 + * void* hostPointer + * + * cdef struct cudaFuncAttributes: # <<<<<<<<<<<<<< + * size_t sharedSizeBytes + * size_t constSizeBytes + */ +struct __pyx_t_4cuda_7ccudart_cudaFuncAttributes { + size_t sharedSizeBytes; + size_t constSizeBytes; + size_t localSizeBytes; + int maxThreadsPerBlock; + int numRegs; + int ptxVersion; + int binaryVersion; + int cacheModeCA; + int maxDynamicSharedSizeBytes; + int preferredShmemCarveout; +}; + +/* "cuda/ccudart.pxd":663 + * cudaMemLocationTypeDevice = 1 + * + * cdef struct cudaMemLocation: # <<<<<<<<<<<<<< + * cudaMemLocationType type + * int id + */ +struct __pyx_t_4cuda_7ccudart_cudaMemLocation { + enum __pyx_t_4cuda_7ccudart_cudaMemLocationType type; + int id; +}; + +/* "cuda/ccudart.pxd":672 + * cudaMemAccessFlagsProtReadWrite = 3 + * + * cdef struct cudaMemAccessDesc: # <<<<<<<<<<<<<< + * cudaMemLocation location + * cudaMemAccessFlags flags + */ +struct __pyx_t_4cuda_7ccudart_cudaMemAccessDesc { + struct __pyx_t_4cuda_7ccudart_cudaMemLocation location; + enum __pyx_t_4cuda_7ccudart_cudaMemAccessFlags flags; +}; + +/* "cuda/ccudart.pxd":687 + * cudaMemHandleTypeWin32Kmt = 4 + * + * cdef struct cudaMemPoolProps: # <<<<<<<<<<<<<< + * cudaMemAllocationType allocType + * cudaMemAllocationHandleType handleTypes + */ +struct __pyx_t_4cuda_7ccudart_cudaMemPoolProps { + enum __pyx_t_4cuda_7ccudart_cudaMemAllocationType allocType; + enum __pyx_t_4cuda_7ccudart_cudaMemAllocationHandleType handleTypes; + struct __pyx_t_4cuda_7ccudart_cudaMemLocation location; + void *win32SecurityAttributes; + unsigned char reserved[64]; +}; + +/* "cuda/ccudart.pxd":694 + * unsigned char reserved[64] + * + * cdef struct cudaMemPoolPtrExportData: # <<<<<<<<<<<<<< + * unsigned char reserved[64] + * + */ +struct __pyx_t_4cuda_7ccudart_cudaMemPoolPtrExportData { + unsigned char reserved[64]; +}; + +/* "cuda/ccudart.pxd":697 + * unsigned char reserved[64] + * + * cdef struct cudaMemAllocNodeParams: # <<<<<<<<<<<<<< + * cudaMemPoolProps poolProps + * const cudaMemAccessDesc* accessDescs + */ +struct __pyx_t_4cuda_7ccudart_cudaMemAllocNodeParams { + struct __pyx_t_4cuda_7ccudart_cudaMemPoolProps poolProps; + struct __pyx_t_4cuda_7ccudart_cudaMemAccessDesc const *accessDescs; + size_t accessDescCount; + size_t bytesize; + void *dptr; +}; + +/* "cuda/ccudart.pxd":716 + * cudaDevP2PAttrCudaArrayAccessSupported = 4 + * + * cdef struct CUuuid_st: # <<<<<<<<<<<<<< + * char bytes[16] + * + */ +struct __pyx_t_4cuda_7ccudart_CUuuid_st { + char bytes[16]; +}; + +/* "cuda/ccudart.pxd":719 + * char bytes[16] + * + * ctypedef CUuuid_st CUuuid # <<<<<<<<<<<<<< + * + * ctypedef CUuuid_st cudaUUID_t + */ +typedef struct __pyx_t_4cuda_7ccudart_CUuuid_st __pyx_t_4cuda_7ccudart_CUuuid; + +/* "cuda/ccudart.pxd":721 + * ctypedef CUuuid_st CUuuid + * + * ctypedef CUuuid_st cudaUUID_t # <<<<<<<<<<<<<< + * + * cdef struct cudaDeviceProp: + */ +typedef struct __pyx_t_4cuda_7ccudart_CUuuid_st __pyx_t_4cuda_7ccudart_cudaUUID_t; + +/* "cuda/ccudart.pxd":723 + * ctypedef CUuuid_st cudaUUID_t + * + * cdef struct cudaDeviceProp: # <<<<<<<<<<<<<< + * char name[256] + * cudaUUID_t uuid + */ +struct __pyx_t_4cuda_7ccudart_cudaDeviceProp { + char name[0x100]; + __pyx_t_4cuda_7ccudart_cudaUUID_t uuid; + char luid[8]; + unsigned int luidDeviceNodeMask; + size_t totalGlobalMem; + size_t sharedMemPerBlock; + int regsPerBlock; + int warpSize; + size_t memPitch; + int maxThreadsPerBlock; + int maxThreadsDim[3]; + int maxGridSize[3]; + int clockRate; + size_t totalConstMem; + int major; + int minor; + size_t textureAlignment; + size_t texturePitchAlignment; + int deviceOverlap; + int multiProcessorCount; + int kernelExecTimeoutEnabled; + int integrated; + int canMapHostMemory; + int computeMode; + int maxTexture1D; + int maxTexture1DMipmap; + int maxTexture1DLinear; + int maxTexture2D[2]; + int maxTexture2DMipmap[2]; + int maxTexture2DLinear[3]; + int maxTexture2DGather[2]; + int maxTexture3D[3]; + int maxTexture3DAlt[3]; + int maxTextureCubemap; + int maxTexture1DLayered[2]; + int maxTexture2DLayered[3]; + int maxTextureCubemapLayered[2]; + int maxSurface1D; + int maxSurface2D[2]; + int maxSurface3D[3]; + int maxSurface1DLayered[2]; + int maxSurface2DLayered[3]; + int maxSurfaceCubemap; + int maxSurfaceCubemapLayered[2]; + size_t surfaceAlignment; + int concurrentKernels; + int ECCEnabled; + int pciBusID; + int pciDeviceID; + int pciDomainID; + int tccDriver; + int asyncEngineCount; + int unifiedAddressing; + int memoryClockRate; + int memoryBusWidth; + int l2CacheSize; + int persistingL2CacheMaxSize; + int maxThreadsPerMultiProcessor; + int streamPrioritiesSupported; + int globalL1CacheSupported; + int localL1CacheSupported; + size_t sharedMemPerMultiprocessor; + int regsPerMultiprocessor; + int managedMemory; + int isMultiGpuBoard; + int multiGpuBoardGroupID; + int hostNativeAtomicSupported; + int singleToDoublePrecisionPerfRatio; + int pageableMemoryAccess; + int concurrentManagedAccess; + int computePreemptionSupported; + int canUseHostPointerForRegisteredMem; + int cooperativeLaunch; + int cooperativeMultiDeviceLaunch; + size_t sharedMemPerBlockOptin; + int pageableMemoryAccessUsesHostPageTables; + int directManagedMemAccessFromHost; + int maxBlocksPerMultiProcessor; + int accessPolicyMaxWindowSize; + size_t reservedSharedMemPerBlock; +}; + +/* "cuda/ccudart.pxd":805 + * size_t reservedSharedMemPerBlock + * + * cdef struct cudaIpcEventHandle_st: # <<<<<<<<<<<<<< + * char reserved[64] + * + */ +struct __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_st { + char reserved[64]; +}; + +/* "cuda/ccudart.pxd":808 + * char reserved[64] + * + * ctypedef cudaIpcEventHandle_st cudaIpcEventHandle_t # <<<<<<<<<<<<<< + * + * cdef struct cudaIpcMemHandle_st: + */ +typedef struct __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_st __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_t; + +/* "cuda/ccudart.pxd":810 + * ctypedef cudaIpcEventHandle_st cudaIpcEventHandle_t + * + * cdef struct cudaIpcMemHandle_st: # <<<<<<<<<<<<<< + * char reserved[64] + * + */ +struct __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_st { + char reserved[64]; +}; + +/* "cuda/ccudart.pxd":813 + * char reserved[64] + * + * ctypedef cudaIpcMemHandle_st cudaIpcMemHandle_t # <<<<<<<<<<<<<< + * + * cdef enum cudaExternalMemoryHandleType: + */ +typedef struct __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_st __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_t; + +/* "cuda/ccudart.pxd":825 + * cudaExternalMemoryHandleTypeNvSciBuf = 8 + * + * cdef struct _cudaExternalMemoryHandleDesc_handle_handle_win32_s: # <<<<<<<<<<<<<< + * void* handle + * void* name + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_handle_win32_s { + void *handle; + void *name; +}; + +/* "cuda/ccudart.pxd":829 + * void* name + * + * cdef union _cudaExternalMemoryHandleDesc_handle_u: # <<<<<<<<<<<<<< + * int fd + * _cudaExternalMemoryHandleDesc_handle_handle_win32_s win32 + */ +union __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_u { + int fd; + struct __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_handle_win32_s win32; + void *nvSciBufObject; +}; + +/* "cuda/ccudart.pxd":834 + * void* nvSciBufObject + * + * cdef struct cudaExternalMemoryHandleDesc: # <<<<<<<<<<<<<< + * cudaExternalMemoryHandleType type + * _cudaExternalMemoryHandleDesc_handle_u handle + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleDesc { + enum __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleType type; + union __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_u handle; + unsigned PY_LONG_LONG size; + unsigned int flags; +}; + +/* "cuda/ccudart.pxd":840 + * unsigned int flags + * + * cdef struct cudaExternalMemoryBufferDesc: # <<<<<<<<<<<<<< + * unsigned long long offset + * unsigned long long size + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryBufferDesc { + unsigned PY_LONG_LONG offset; + unsigned PY_LONG_LONG size; + unsigned int flags; +}; + +/* "cuda/ccudart.pxd":845 + * unsigned int flags + * + * cdef struct cudaExternalMemoryMipmappedArrayDesc: # <<<<<<<<<<<<<< + * unsigned long long offset + * cudaChannelFormatDesc formatDesc + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryMipmappedArrayDesc { + unsigned PY_LONG_LONG offset; + struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc formatDesc; + struct __pyx_t_4cuda_7ccudart_cudaExtent extent; + unsigned int flags; + unsigned int numLevels; +}; + +/* "cuda/ccudart.pxd":864 + * cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10 + * + * cdef struct _cudaExternalSemaphoreHandleDesc_handle_handle_win32_s: # <<<<<<<<<<<<<< + * void* handle + * void* name + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_handle_win32_s { + void *handle; + void *name; +}; + +/* "cuda/ccudart.pxd":868 + * void* name + * + * cdef union _cudaExternalSemaphoreHandleDesc_handle_u: # <<<<<<<<<<<<<< + * int fd + * _cudaExternalSemaphoreHandleDesc_handle_handle_win32_s win32 + */ +union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_u { + int fd; + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_handle_win32_s win32; + void *nvSciSyncObj; +}; + +/* "cuda/ccudart.pxd":873 + * void* nvSciSyncObj + * + * cdef struct cudaExternalSemaphoreHandleDesc: # <<<<<<<<<<<<<< + * cudaExternalSemaphoreHandleType type + * _cudaExternalSemaphoreHandleDesc_handle_u handle + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleDesc { + enum __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleType type; + union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_u handle; + unsigned int flags; +}; + +/* "cuda/ccudart.pxd":878 + * unsigned int flags + * + * cdef struct _cudaExternalSemaphoreSignalParams_params_params_fence_s: # <<<<<<<<<<<<<< + * unsigned long long value + * + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_fence_s { + unsigned PY_LONG_LONG value; +}; + +/* "cuda/ccudart.pxd":881 + * unsigned long long value + * + * cdef union _cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u: # <<<<<<<<<<<<<< + * void* fence + * unsigned long long reserved + */ +union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u { + void *fence; + unsigned PY_LONG_LONG reserved; +}; + +/* "cuda/ccudart.pxd":885 + * unsigned long long reserved + * + * cdef struct _cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s: # <<<<<<<<<<<<<< + * unsigned long long key + * + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s { + unsigned PY_LONG_LONG key; +}; + +/* "cuda/ccudart.pxd":888 + * unsigned long long key + * + * cdef struct _cudaExternalSemaphoreSignalParams_params_s: # <<<<<<<<<<<<<< + * _cudaExternalSemaphoreSignalParams_params_params_fence_s fence + * _cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u nvSciSync + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_s { + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_fence_s fence; + union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u nvSciSync; + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s keyedMutex; + unsigned int reserved[12]; +}; + +/* "cuda/ccudart.pxd":894 + * unsigned int reserved[12] + * + * cdef struct cudaExternalSemaphoreSignalParams: # <<<<<<<<<<<<<< + * _cudaExternalSemaphoreSignalParams_params_s params + * unsigned int flags + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalParams { + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_s params; + unsigned int flags; + unsigned int reserved[16]; +}; + +/* "cuda/ccudart.pxd":899 + * unsigned int reserved[16] + * + * cdef struct _cudaExternalSemaphoreWaitParams_params_params_fence_s: # <<<<<<<<<<<<<< + * unsigned long long value + * + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_fence_s { + unsigned PY_LONG_LONG value; +}; + +/* "cuda/ccudart.pxd":902 + * unsigned long long value + * + * cdef union _cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u: # <<<<<<<<<<<<<< + * void* fence + * unsigned long long reserved + */ +union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u { + void *fence; + unsigned PY_LONG_LONG reserved; +}; + +/* "cuda/ccudart.pxd":906 + * unsigned long long reserved + * + * cdef struct _cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s: # <<<<<<<<<<<<<< + * unsigned long long key + * unsigned int timeoutMs + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s { + unsigned PY_LONG_LONG key; + unsigned int timeoutMs; +}; + +/* "cuda/ccudart.pxd":910 + * unsigned int timeoutMs + * + * cdef struct _cudaExternalSemaphoreWaitParams_params_s: # <<<<<<<<<<<<<< + * _cudaExternalSemaphoreWaitParams_params_params_fence_s fence + * _cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u nvSciSync + */ +struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_s { + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_fence_s fence; + union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u nvSciSync; + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s keyedMutex; + unsigned int reserved[10]; +}; + +/* "cuda/ccudart.pxd":916 + * unsigned int reserved[10] + * + * cdef struct cudaExternalSemaphoreWaitParams: # <<<<<<<<<<<<<< + * _cudaExternalSemaphoreWaitParams_params_s params + * unsigned int flags + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitParams { + struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_s params; + unsigned int flags; + unsigned int reserved[16]; +}; + +/* "cuda/ccudart.pxd":921 + * unsigned int reserved[16] + * + * ctypedef cudaError cudaError_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef enum __pyx_t_4cuda_7ccudart_cudaError __pyx_t_4cuda_7ccudart_cudaError_t; + +/* "cuda/ccudart.pxd":926 + * cdef struct CUstream_st: + * pass + * ctypedef CUstream_st* cudaStream_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUstream_st *__pyx_t_4cuda_7ccudart_cudaStream_t; + +/* "cuda/ccudart.pxd":931 + * cdef struct CUevent_st: + * pass + * ctypedef CUevent_st* cudaEvent_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUevent_st *__pyx_t_4cuda_7ccudart_cudaEvent_t; + +/* "cuda/ccudart.pxd":936 + * cdef struct cudaGraphicsResource: + * pass + * ctypedef cudaGraphicsResource* cudaGraphicsResource_t # <<<<<<<<<<<<<< + * + * ctypedef cudaOutputMode cudaOutputMode_t + */ +typedef struct cudaGraphicsResource *__pyx_t_4cuda_7ccudart_cudaGraphicsResource_t; + +/* "cuda/ccudart.pxd":938 + * ctypedef cudaGraphicsResource* cudaGraphicsResource_t + * + * ctypedef cudaOutputMode cudaOutputMode_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef enum __pyx_t_4cuda_7ccudart_cudaOutputMode __pyx_t_4cuda_7ccudart_cudaOutputMode_t; + +/* "cuda/ccudart.pxd":943 + * cdef struct CUexternalMemory_st: + * pass + * ctypedef CUexternalMemory_st* cudaExternalMemory_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUexternalMemory_st *__pyx_t_4cuda_7ccudart_cudaExternalMemory_t; + +/* "cuda/ccudart.pxd":948 + * cdef struct CUexternalSemaphore_st: + * pass + * ctypedef CUexternalSemaphore_st* cudaExternalSemaphore_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUexternalSemaphore_st *__pyx_t_4cuda_7ccudart_cudaExternalSemaphore_t; + +/* "cuda/ccudart.pxd":953 + * cdef struct CUgraph_st: + * pass + * ctypedef CUgraph_st* cudaGraph_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUgraph_st *__pyx_t_4cuda_7ccudart_cudaGraph_t; + +/* "cuda/ccudart.pxd":958 + * cdef struct CUgraphNode_st: + * pass + * ctypedef CUgraphNode_st* cudaGraphNode_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUgraphNode_st *__pyx_t_4cuda_7ccudart_cudaGraphNode_t; + +/* "cuda/ccudart.pxd":963 + * cdef struct CUuserObject_st: + * pass + * ctypedef CUuserObject_st* cudaUserObject_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUuserObject_st *__pyx_t_4cuda_7ccudart_cudaUserObject_t; + +/* "cuda/ccudart.pxd":968 + * cdef struct CUfunc_st: + * pass + * ctypedef CUfunc_st* cudaFunction_t # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct CUfunc_st *__pyx_t_4cuda_7ccudart_cudaFunction_t; + +/* "cuda/ccudart.pxd":973 + * cdef struct CUmemPoolHandle_st: + * pass + * ctypedef CUmemPoolHandle_st* cudaMemPool_t # <<<<<<<<<<<<<< + * + * cdef enum cudaCGScope: + */ +typedef struct CUmemPoolHandle_st *__pyx_t_4cuda_7ccudart_cudaMemPool_t; + +/* "cuda/ccudart.pxd":980 + * cudaCGScopeMultiGrid = 2 + * + * cdef struct cudaKernelNodeParams: # <<<<<<<<<<<<<< + * void* func + * dim3 gridDim + */ +struct __pyx_t_4cuda_7ccudart_cudaKernelNodeParams { + void *func; + struct __pyx_t_4cuda_7ccudart_dim3 gridDim; + struct __pyx_t_4cuda_7ccudart_dim3 blockDim; + unsigned int sharedMemBytes; + void **kernelParams; + void **extra; +}; + +/* "cuda/ccudart.pxd":988 + * void** extra + * + * cdef struct cudaExternalSemaphoreSignalNodeParams: # <<<<<<<<<<<<<< + * cudaExternalSemaphore_t* extSemArray + * const cudaExternalSemaphoreSignalParams* paramsArray + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalNodeParams { + __pyx_t_4cuda_7ccudart_cudaExternalSemaphore_t *extSemArray; + struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalParams const *paramsArray; + unsigned int numExtSems; +}; + +/* "cuda/ccudart.pxd":993 + * unsigned int numExtSems + * + * cdef struct cudaExternalSemaphoreWaitNodeParams: # <<<<<<<<<<<<<< + * cudaExternalSemaphore_t* extSemArray + * const cudaExternalSemaphoreWaitParams* paramsArray + */ +struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitNodeParams { + __pyx_t_4cuda_7ccudart_cudaExternalSemaphore_t *extSemArray; + struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitParams const *paramsArray; + unsigned int numExtSems; +}; + +/* "cuda/ccudart.pxd":1016 + * cdef struct CUgraphExec_st: + * pass + * ctypedef CUgraphExec_st* cudaGraphExec_t # <<<<<<<<<<<<<< + * + * cdef enum cudaGraphExecUpdateResult: + */ +typedef struct CUgraphExec_st *__pyx_t_4cuda_7ccudart_cudaGraphExec_t; + +/* "cuda/ccudart.pxd":1074 + * cudaReadModeNormalizedFloat = 1 + * + * cdef struct cudaTextureDesc: # <<<<<<<<<<<<<< + * cudaTextureAddressMode addressMode[3] + * cudaTextureFilterMode filterMode + */ +struct __pyx_t_4cuda_7ccudart_cudaTextureDesc { + enum __pyx_t_4cuda_7ccudart_cudaTextureAddressMode addressMode[3]; + enum __pyx_t_4cuda_7ccudart_cudaTextureFilterMode filterMode; + enum __pyx_t_4cuda_7ccudart_cudaTextureReadMode readMode; + int sRGB; + float borderColor[4]; + int normalizedCoords; + unsigned int maxAnisotropy; + enum __pyx_t_4cuda_7ccudart_cudaTextureFilterMode mipmapFilterMode; + float mipmapLevelBias; + float minMipmapLevelClamp; + float maxMipmapLevelClamp; + int disableTrilinearOptimization; + int seamlessCubemap; +}; + +/* "cuda/ccudart.pxd":1121 + * CUDA_C_64U = 27 + * + * ctypedef cudaDataType_t cudaDataType # <<<<<<<<<<<<<< + * + * cdef enum libraryPropertyType_t: + */ +typedef enum __pyx_t_4cuda_7ccudart_cudaDataType_t __pyx_t_4cuda_7ccudart_cudaDataType; + +/* "cuda/ccudart.pxd":1128 + * PATCH_LEVEL = 2 + * + * ctypedef libraryPropertyType_t libraryPropertyType # <<<<<<<<<<<<<< + * + * cdef cudaError_t cudaDeviceReset() nogil except ?cudaErrorCallRequiresNewerDriver + */ +typedef enum __pyx_t_4cuda_7ccudart_libraryPropertyType_t __pyx_t_4cuda_7ccudart_libraryPropertyType; + +/* "cuda/ccudart.pxd":1234 + * cdef cudaError_t cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver + * + * ctypedef void (*cudaStreamCallback_t)(cudaStream_t stream, cudaError_t status, void* userData) # <<<<<<<<<<<<<< + * + * cdef cudaError_t cudaStreamAddCallback(cudaStream_t stream, cudaStreamCallback_t callback, void* userData, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver + */ +typedef void (*__pyx_t_4cuda_7ccudart_cudaStreamCallback_t)(__pyx_t_4cuda_7ccudart_cudaStream_t, __pyx_t_4cuda_7ccudart_cudaError_t, void *); + +/* "cuda/ccudart.pxd":1671 + * cdef struct void: + * pass + * ctypedef void* EGLImageKHR # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef void *__pyx_t_4cuda_7ccudart_EGLImageKHR; + +/* "cuda/ccudart.pxd":1676 + * cdef struct void: + * pass + * ctypedef void* EGLStreamKHR # <<<<<<<<<<<<<< + * + * ctypedef unsigned int EGLint + */ +typedef void *__pyx_t_4cuda_7ccudart_EGLStreamKHR; + +/* "cuda/ccudart.pxd":1683 + * cdef struct void: + * pass + * ctypedef void* EGLSyncKHR # <<<<<<<<<<<<<< + * + * ctypedef uint32_t VdpDevice + */ +typedef void *__pyx_t_4cuda_7ccudart_EGLSyncKHR; + +/* "cuda/ccudart.pxd":1721 + * cudaEglFrameTypePitch = 1 + * + * ctypedef cudaEglFrameType_enum cudaEglFrameType # <<<<<<<<<<<<<< + * + * cdef enum cudaEglResourceLocationFlags_enum: + */ +typedef enum __pyx_t_4cuda_7ccudart_cudaEglFrameType_enum __pyx_t_4cuda_7ccudart_cudaEglFrameType; + +/* "cuda/ccudart.pxd":1727 + * cudaEglResourceLocationVidmem = 1 + * + * ctypedef cudaEglResourceLocationFlags_enum cudaEglResourceLocationFlags # <<<<<<<<<<<<<< + * + * cdef enum cudaEglColorFormat_enum: + */ +typedef enum __pyx_t_4cuda_7ccudart_cudaEglResourceLocationFlags_enum __pyx_t_4cuda_7ccudart_cudaEglResourceLocationFlags; + +/* "cuda/ccudart.pxd":1841 + * cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 113 + * + * ctypedef cudaEglColorFormat_enum cudaEglColorFormat # <<<<<<<<<<<<<< + * + * cdef struct cudaEglPlaneDesc_st: + */ +typedef enum __pyx_t_4cuda_7ccudart_cudaEglColorFormat_enum __pyx_t_4cuda_7ccudart_cudaEglColorFormat; + +/* "cuda/ccudart.pxd":1843 + * ctypedef cudaEglColorFormat_enum cudaEglColorFormat + * + * cdef struct cudaEglPlaneDesc_st: # <<<<<<<<<<<<<< + * unsigned int width + * unsigned int height + */ +struct __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc_st { + unsigned int width; + unsigned int height; + unsigned int depth; + unsigned int pitch; + unsigned int numChannels; + struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc channelDesc; + unsigned int reserved[4]; +}; + +/* "cuda/ccudart.pxd":1852 + * unsigned int reserved[4] + * + * ctypedef cudaEglPlaneDesc_st cudaEglPlaneDesc # <<<<<<<<<<<<<< + * + * cdef union _cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u: + */ +typedef struct __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc_st __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc; + +/* "cuda/ccudart.pxd":1854 + * ctypedef cudaEglPlaneDesc_st cudaEglPlaneDesc + * + * cdef union _cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u: # <<<<<<<<<<<<<< + * cudaArray_t pArray[3] + * cudaPitchedPtr pPitch[3] + */ +union __pyx_t_4cuda_7ccudart__cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u { + __pyx_t_4cuda_7ccudart_cudaArray_t pArray[3]; + struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr pPitch[3]; +}; + +/* "cuda/ccudart.pxd":1858 + * cudaPitchedPtr pPitch[3] + * + * cdef struct cudaEglFrame_st: # <<<<<<<<<<<<<< + * _cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u frame + * cudaEglPlaneDesc planeDesc[3] + */ +struct __pyx_t_4cuda_7ccudart_cudaEglFrame_st { + union __pyx_t_4cuda_7ccudart__cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u frame; + __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc planeDesc[3]; + unsigned int planeCount; + __pyx_t_4cuda_7ccudart_cudaEglFrameType frameType; + __pyx_t_4cuda_7ccudart_cudaEglColorFormat eglColorFormat; +}; + +/* "cuda/ccudart.pxd":1865 + * cudaEglColorFormat eglColorFormat + * + * ctypedef cudaEglFrame_st cudaEglFrame # <<<<<<<<<<<<<< + * + * cdef extern from "": + */ +typedef struct __pyx_t_4cuda_7ccudart_cudaEglFrame_st __pyx_t_4cuda_7ccudart_cudaEglFrame; + +/* "cuda/ccudart.pxd":1870 + * cdef struct CUeglStreamConnection_st: + * pass + * ctypedef CUeglStreamConnection_st* cudaEglStreamConnection # <<<<<<<<<<<<<< + * + * cdef cudaError_t cudaGraphicsEGLRegisterImage(cudaGraphicsResource_t* pCudaResource, EGLImageKHR image, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver + */ +typedef struct CUeglStreamConnection_st *__pyx_t_4cuda_7ccudart_cudaEglStreamConnection; +struct __pyx_opt_args_3rmm_5_cuda_6stream_6Stream__from_cudaStream_t; + +/* "rmm/_cuda/stream.pxd":27 + * + * @staticmethod + * cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=*) # <<<<<<<<<<<<<< + * + * cdef cuda_stream_view view(self) nogil except * + */ +struct __pyx_opt_args_3rmm_5_cuda_6stream_6Stream__from_cudaStream_t { + int __pyx_n; + PyObject *owner; +}; +struct __pyx_opt_args_3rmm_4_lib_15memory_resource_21BinningMemoryResource_add_bin; + +/* "rmm/_lib/memory_resource.pxd":56 + * + * cpdef add_bin( + * self, # <<<<<<<<<<<<<< + * size_t allocation_size, + * DeviceMemoryResource bin_resource=*) + */ +struct __pyx_opt_args_3rmm_4_lib_15memory_resource_21BinningMemoryResource_add_bin { + int __pyx_n; + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *bin_resource; +}; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_c_to_device; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_to_host; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_host; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_device; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_tobytes; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_resize; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_to_device; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_ptr_to_host; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_host_to_ptr; +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_device_to_ptr; + +/* "rmm/_lib/device_buffer.pxd":52 + * + * @staticmethod + * cdef DeviceBuffer c_to_device(const unsigned char[::1] b, # <<<<<<<<<<<<<< + * Stream stream=*) + * cpdef copy_to_host(self, ary=*, Stream stream=*) + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_c_to_device { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":54 + * cdef DeviceBuffer c_to_device(const unsigned char[::1] b, + * Stream stream=*) + * cpdef copy_to_host(self, ary=*, Stream stream=*) # <<<<<<<<<<<<<< + * cpdef copy_from_host(self, ary, Stream stream=*) + * cpdef copy_from_device(self, cuda_ary, Stream stream=*) + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_to_host { + int __pyx_n; + PyObject *ary; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":55 + * Stream stream=*) + * cpdef copy_to_host(self, ary=*, Stream stream=*) + * cpdef copy_from_host(self, ary, Stream stream=*) # <<<<<<<<<<<<<< + * cpdef copy_from_device(self, cuda_ary, Stream stream=*) + * cpdef bytes tobytes(self, Stream stream=*) + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_host { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":56 + * cpdef copy_to_host(self, ary=*, Stream stream=*) + * cpdef copy_from_host(self, ary, Stream stream=*) + * cpdef copy_from_device(self, cuda_ary, Stream stream=*) # <<<<<<<<<<<<<< + * cpdef bytes tobytes(self, Stream stream=*) + * + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_device { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":57 + * cpdef copy_from_host(self, ary, Stream stream=*) + * cpdef copy_from_device(self, cuda_ary, Stream stream=*) + * cpdef bytes tobytes(self, Stream stream=*) # <<<<<<<<<<<<<< + * + * cdef size_t c_size(self) except * + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_tobytes { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":60 + * + * cdef size_t c_size(self) except * + * cpdef void resize(self, size_t new_size, Stream stream=*) except * # <<<<<<<<<<<<<< + * cpdef size_t capacity(self) except * + * cdef void* c_data(self) except * + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_resize { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":66 + * cdef device_buffer c_release(self) except * + * + * cpdef DeviceBuffer to_device(const unsigned char[::1] b, # <<<<<<<<<<<<<< + * Stream stream=*) + * cpdef void copy_ptr_to_host(uintptr_t db, + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_to_device { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":68 + * cpdef DeviceBuffer to_device(const unsigned char[::1] b, + * Stream stream=*) + * cpdef void copy_ptr_to_host(uintptr_t db, # <<<<<<<<<<<<<< + * unsigned char[::1] hb, + * Stream stream=*) except * + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_ptr_to_host { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":72 + * Stream stream=*) except * + * + * cpdef void copy_host_to_ptr(const unsigned char[::1] hb, # <<<<<<<<<<<<<< + * uintptr_t db, + * Stream stream=*) except * + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_host_to_ptr { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_lib/device_buffer.pxd":76 + * Stream stream=*) except * + * + * cpdef void copy_device_to_ptr(uintptr_t d_src, # <<<<<<<<<<<<<< + * uintptr_t d_dst, + * size_t count, + */ +struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_device_to_ptr { + int __pyx_n; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + +/* "rmm/_cuda/stream.pxd":22 + * + * + * cdef class Stream: # <<<<<<<<<<<<<< + * cdef cudaStream_t _cuda_stream + * cdef object _owner + */ +struct __pyx_obj_3rmm_5_cuda_6stream_Stream { + PyObject_HEAD + struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream *__pyx_vtab; + __pyx_t_4cuda_7ccudart_cudaStream_t _cuda_stream; + PyObject *_owner; +}; + + +/* "rmm/_lib/memory_resource.pxd":27 + * void deallocate(void* ptr, size_t bytes) except + + * + * cdef class DeviceMemoryResource: # <<<<<<<<<<<<<< + * cdef shared_ptr[device_memory_resource] c_obj + * cdef device_memory_resource* get_mr(self) + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource { + PyObject_HEAD + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource *__pyx_vtab; + std::shared_ptr c_obj; +}; + + +/* "rmm/_lib/memory_resource.pxd":31 + * cdef device_memory_resource* get_mr(self) + * + * cdef class UpstreamResourceAdaptor(DeviceMemoryResource): # <<<<<<<<<<<<<< + * cdef readonly DeviceMemoryResource upstream_mr + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor { + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *upstream_mr; +}; + + +/* "rmm/_lib/memory_resource.pxd":36 + * cpdef DeviceMemoryResource get_upstream(self) + * + * cdef class CudaMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":39 + * pass + * + * cdef class ManagedMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_ManagedMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":42 + * pass + * + * cdef class CudaAsyncMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":45 + * pass + * + * cdef class PoolMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_PoolMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":48 + * pass + * + * cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":51 + * pass + * + * cdef class BinningMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * + * cdef readonly list bin_mrs + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; + PyObject *bin_mrs; +}; + + +/* "rmm/_lib/memory_resource.pxd":60 + * DeviceMemoryResource bin_resource=*) + * + * cdef class CallbackMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * cdef object _allocate_func + * cdef object _deallocate_func + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_CallbackMemoryResource { + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; + PyObject *_allocate_func; + PyObject *_deallocate_func; +}; + + +/* "rmm/_lib/memory_resource.pxd":64 + * cdef object _deallocate_func + * + * cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * cdef object _log_file_name + * cpdef get_file_name(self) + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; + PyObject *_log_file_name; +}; + + +/* "rmm/_lib/memory_resource.pxd":69 + * cpdef flush(self) + * + * cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":72 + * pass + * + * cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; + + +/* "rmm/_lib/memory_resource.pxd":75 + * pass + * + * cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * cdef object _callback + * + */ +struct __pyx_obj_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor { + struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; + PyObject *_callback; +}; + + +/* "rmm/_lib/device_buffer.pxd":36 + * + * + * cdef class DeviceBuffer: # <<<<<<<<<<<<<< + * cdef unique_ptr[device_buffer] c_obj + * + */ +struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer { + PyObject_HEAD + struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_vtab; + std::unique_ptr c_obj; + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *mr; + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; +}; + + +/* "cudf/_lib/column.pxd":13 + * + * + * cdef class Column: # <<<<<<<<<<<<<< + * cdef public: + * cdef int _offset + */ +struct __pyx_obj_4cudf_4_lib_6column_Column { + PyObject_HEAD + struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *__pyx_vtab; + int _offset; + int _size; + PyObject *_dtype; + PyObject *_base_children; + PyObject *_base_data; + PyObject *_base_mask; + PyObject *_children; + PyObject *_data; + PyObject *_mask; + PyObject *_null_count; +}; + + +/* "View.MemoryView":105 + * + * @cname("__pyx_array") + * cdef class array: # <<<<<<<<<<<<<< + * + * cdef: + */ +struct __pyx_array_obj { + PyObject_HEAD + struct __pyx_vtabstruct_array *__pyx_vtab; + char *data; + Py_ssize_t len; + char *format; + int ndim; + Py_ssize_t *_shape; + Py_ssize_t *_strides; + Py_ssize_t itemsize; + PyObject *mode; + PyObject *_format; + void (*callback_free_data)(void *); + int free_data; + int dtype_is_object; +}; + + +/* "View.MemoryView":279 + * + * @cname('__pyx_MemviewEnum') + * cdef class Enum(object): # <<<<<<<<<<<<<< + * cdef object name + * def __init__(self, name): + */ +struct __pyx_MemviewEnum_obj { + PyObject_HEAD + PyObject *name; +}; + + +/* "View.MemoryView":330 + * + * @cname('__pyx_memoryview') + * cdef class memoryview(object): # <<<<<<<<<<<<<< + * + * cdef object obj + */ +struct __pyx_memoryview_obj { + PyObject_HEAD + struct __pyx_vtabstruct_memoryview *__pyx_vtab; + PyObject *obj; + PyObject *_size; + PyObject *_array_interface; + PyThread_type_lock lock; + __pyx_atomic_int acquisition_count[2]; + __pyx_atomic_int *acquisition_count_aligned_p; + Py_buffer view; + int flags; + int dtype_is_object; + __Pyx_TypeInfo *typeinfo; +}; + + +/* "View.MemoryView":965 + * + * @cname('__pyx_memoryviewslice') + * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< + * "Internal class for passing memoryview slices to Python" + * + */ +struct __pyx_memoryviewslice_obj { + struct __pyx_memoryview_obj __pyx_base; + __Pyx_memviewslice from_slice; + PyObject *from_object; + PyObject *(*to_object_func)(char *); + int (*to_dtype_func)(char *, PyObject *); +}; + + + +/* "rmm/_cuda/stream.pxd":22 + * + * + * cdef class Stream: # <<<<<<<<<<<<<< + * cdef cudaStream_t _cuda_stream + * cdef object _owner + */ + +struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream { + struct __pyx_obj_3rmm_5_cuda_6stream_Stream *(*_from_cudaStream_t)(__pyx_t_4cuda_7ccudart_cudaStream_t, struct __pyx_opt_args_3rmm_5_cuda_6stream_6Stream__from_cudaStream_t *__pyx_optional_args); + rmm::cuda_stream_view (*view)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); + void (*c_synchronize)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); + bool (*c_is_default)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); + void (*_init_with_new_cuda_stream)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); + void (*_init_from_stream)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *, struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); +}; +static struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream *__pyx_vtabptr_3rmm_5_cuda_6stream_Stream; + + +/* "rmm/_lib/memory_resource.pxd":27 + * void deallocate(void* ptr, size_t bytes) except + + * + * cdef class DeviceMemoryResource: # <<<<<<<<<<<<<< + * cdef shared_ptr[device_memory_resource] c_obj + * cdef device_memory_resource* get_mr(self) + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource { + rmm::mr::device_memory_resource *(*get_mr)(struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *); +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_DeviceMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":31 + * cdef device_memory_resource* get_mr(self) + * + * cdef class UpstreamResourceAdaptor(DeviceMemoryResource): # <<<<<<<<<<<<<< + * cdef readonly DeviceMemoryResource upstream_mr + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; + struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *(*get_upstream)(struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor; + + +/* "rmm/_lib/memory_resource.pxd":36 + * cpdef DeviceMemoryResource get_upstream(self) + * + * cdef class CudaMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":39 + * pass + * + * cdef class ManagedMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_ManagedMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_ManagedMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_ManagedMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":42 + * pass + * + * cdef class CudaAsyncMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":45 + * pass + * + * cdef class PoolMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_PoolMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_PoolMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_PoolMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":48 + * pass + * + * cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":51 + * pass + * + * cdef class BinningMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * + * cdef readonly list bin_mrs + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_BinningMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; + PyObject *(*add_bin)(struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_15memory_resource_21BinningMemoryResource_add_bin *__pyx_optional_args); +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_BinningMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_BinningMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":60 + * DeviceMemoryResource bin_resource=*) + * + * cdef class CallbackMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< + * cdef object _allocate_func + * cdef object _deallocate_func + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CallbackMemoryResource { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CallbackMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_CallbackMemoryResource; + + +/* "rmm/_lib/memory_resource.pxd":64 + * cdef object _deallocate_func + * + * cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * cdef object _log_file_name + * cpdef get_file_name(self) + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; + PyObject *(*get_file_name)(struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor *, int __pyx_skip_dispatch); + PyObject *(*flush)(struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor *, int __pyx_skip_dispatch); +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor; + + +/* "rmm/_lib/memory_resource.pxd":69 + * cpdef flush(self) + * + * cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor; + + +/* "rmm/_lib/memory_resource.pxd":72 + * pass + * + * cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * pass + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor; + + +/* "rmm/_lib/memory_resource.pxd":75 + * pass + * + * cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< + * cdef object _callback + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor { + struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; +}; +static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor; + + +/* "rmm/_lib/device_buffer.pxd":36 + * + * + * cdef class DeviceBuffer: # <<<<<<<<<<<<<< + * cdef unique_ptr[device_buffer] c_obj + * + */ + +struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer { + struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *(*c_from_unique_ptr)(std::unique_ptr ); + struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *(*c_to_device)(__Pyx_memviewslice, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_c_to_device *__pyx_optional_args); + PyObject *(*copy_to_host)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_to_host *__pyx_optional_args); + PyObject *(*copy_from_host)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_host *__pyx_optional_args); + PyObject *(*copy_from_device)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_device *__pyx_optional_args); + PyObject *(*tobytes)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_tobytes *__pyx_optional_args); + size_t (*c_size)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *); + void (*resize)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_resize *__pyx_optional_args); + size_t (*capacity)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, int __pyx_skip_dispatch); + void *(*c_data)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *); + rmm::device_buffer (*c_release)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *); +}; +static struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer; + + +/* "cudf/_lib/column.pxd":13 + * + * + * cdef class Column: # <<<<<<<<<<<<<< + * cdef public: + * cdef int _offset + */ + +struct __pyx_vtabstruct_4cudf_4_lib_6column_Column { + cudf::column_view (*_view)(struct __pyx_obj_4cudf_4_lib_6column_Column *, cudf::size_type); + cudf::column_view (*view)(struct __pyx_obj_4cudf_4_lib_6column_Column *); + cudf::mutable_column_view (*mutable_view)(struct __pyx_obj_4cudf_4_lib_6column_Column *); + struct __pyx_obj_4cudf_4_lib_6column_Column *(*from_unique_ptr)(std::unique_ptr ); + struct __pyx_obj_4cudf_4_lib_6column_Column *(*from_column_view)(cudf::column_view, PyObject *); + cudf::size_type (*compute_null_count)(struct __pyx_obj_4cudf_4_lib_6column_Column *); +}; +static struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *__pyx_vtabptr_4cudf_4_lib_6column_Column; + + +/* "View.MemoryView":105 + * + * @cname("__pyx_array") + * cdef class array: # <<<<<<<<<<<<<< + * + * cdef: + */ + +struct __pyx_vtabstruct_array { + PyObject *(*get_memview)(struct __pyx_array_obj *); +}; +static struct __pyx_vtabstruct_array *__pyx_vtabptr_array; + + +/* "View.MemoryView":330 + * + * @cname('__pyx_memoryview') + * cdef class memoryview(object): # <<<<<<<<<<<<<< + * + * cdef object obj + */ + +struct __pyx_vtabstruct_memoryview { + char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *); + PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *); + PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *); + PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *); + PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *); + PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *); + PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *); +}; +static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview; + + +/* "View.MemoryView":965 + * + * @cname('__pyx_memoryviewslice') + * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< + * "Internal class for passing memoryview slices to Python" + * + */ + +struct __pyx_vtabstruct__memoryviewslice { + struct __pyx_vtabstruct_memoryview __pyx_base; +}; +static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice; + +/* --- Runtime support code (head) --- */ +/* Refnanny.proto */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + if (acquire_gil) {\ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + PyGILState_Release(__pyx_gilstate_save);\ + } else {\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil)\ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext()\ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_XDECREF(tmp);\ + } while (0) +#define __Pyx_DECREF_SET(r, v) do {\ + PyObject *tmp = (PyObject *) r;\ + r = v; __Pyx_DECREF(tmp);\ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +/* RaiseArgTupleInvalid.proto */ +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +/* RaiseDoubleKeywords.proto */ +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +/* ParseKeywords.proto */ +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ + const char* function_name); + +/* PyObjectGetAttrStr.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#define __Pyx_BUILD_ASSERT_EXPR(cond)\ + (sizeof(char [1 - 2*!(cond)]) - 1) +#ifndef Py_MEMBER_SIZE +#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) +#endif +#if CYTHON_FAST_PYCALL + static size_t __pyx_pyframe_localsplus_offset = 0; + #include "frameobject.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif + #define __Pxy_PyFrame_Initialize_Offsets()\ + ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ + (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) + #define __Pyx_PyFrame_GetLocalsplus(frame)\ + (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) +#endif // CYTHON_FAST_PYCALL +#endif + +/* PyObjectCall.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +/* PyObjectCall2Args.proto */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); + +/* PyObjectCallMethO.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +/* PyObjectCallOneArg.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +/* GetItemInt.proto */ +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +/* ExtTypeTest.proto */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +/* GetBuiltinName.proto */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +/* PyDictVersioning.proto */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) +#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ + (version_var) = __PYX_GET_DICT_VERSION(dict);\ + (cache_var) = (value); +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ + (VAR) = __pyx_dict_cached_value;\ + } else {\ + (VAR) = __pyx_dict_cached_value = (LOOKUP);\ + __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ + }\ +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); +#else +#define __PYX_GET_DICT_VERSION(dict) (0) +#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) +#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); +#endif + +/* GetModuleGlobalName.proto */ +#if CYTHON_USE_DICT_VERSIONS +#define __Pyx_GetModuleGlobalName(var, name) {\ + static PY_UINT64_T __pyx_dict_version = 0;\ + static PyObject *__pyx_dict_cached_value = NULL;\ + (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ + (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ + __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ + PY_UINT64_T __pyx_dict_version;\ + PyObject *__pyx_dict_cached_value;\ + (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ +} +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); +#else +#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) +#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); +#endif + +/* ArgTypeTest.proto */ +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); + +/* PyThreadStateGet.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type +#else +#define __Pyx_PyThreadState_declare +#define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() +#endif + +/* PyErrFetchRestore.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) +#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) +#else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) +#endif + +/* RaiseException.proto */ +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +/* IncludeStringH.proto */ +#include + +/* BytesEquals.proto */ +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); + +/* UnicodeEquals.proto */ +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); + +/* StrEquals.proto */ +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals +#else +#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals +#endif + +/* DivInt[Py_ssize_t].proto */ +static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t); + +/* UnaryNegOverflows.proto */ +#define UNARY_NEG_WOULD_OVERFLOW(x)\ + (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x))) + +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/ +/* GetAttr.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); + +/* ObjectGetItem.proto */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); +#else +#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) +#endif + +/* decode_c_string_utf16.proto */ +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 0; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = -1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} + +/* decode_c_string.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + const char* cstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/* PyErrExceptionMatches.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) +static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); +#else +#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) +#endif + +/* GetAttr3.proto */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); + +/* RaiseTooManyValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +/* RaiseNeedMoreValuesToUnpack.proto */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +/* RaiseNoneIterError.proto */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +/* GetTopmostException.proto */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); +#endif + +/* SaveResetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); +#else +#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) +#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) +#endif + +/* GetException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* SwapException.proto */ +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); +#endif + +/* Import.proto */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +/* ListCompAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len)) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) +#endif + +/* PyIntBinop.proto */ +#if !CYTHON_COMPILING_IN_PYPY +static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); +#else +#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ + (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) +#endif + +/* ListExtend.proto */ +static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject* none = _PyList_Extend((PyListObject*)L, v); + if (unlikely(!none)) + return -1; + Py_DECREF(none); + return 0; +#else + return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v); +#endif +} + +/* ListAppend.proto */ +#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS +static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { + PyListObject* L = (PyListObject*) list; + Py_ssize_t len = Py_SIZE(list); + if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { + Py_INCREF(x); + PyList_SET_ITEM(list, len, x); + __Pyx_SET_SIZE(list, len + 1); + return 0; + } + return PyList_Append(list, x); +} +#else +#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) +#endif + +/* None.proto */ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); + +/* DivInt[long].proto */ +static CYTHON_INLINE long __Pyx_div_long(long, long); + +/* PySequenceContains.proto */ +static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { + int result = PySequence_Contains(seq, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + +/* HasAttr.proto */ +static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); + +/* PyObject_GenericGetAttrNoDict.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr +#endif + +/* PyObject_GenericGetAttr.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr +#endif + +/* SetVTable.proto */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +/* PyObjectGetAttrStrNoError.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); + +/* SetupReduce.proto */ +static int __Pyx_setup_reduce(PyObject* type_obj); + +/* TypeImport.proto */ +#ifndef __PYX_HAVE_RT_ImportType_proto +#define __PYX_HAVE_RT_ImportType_proto +enum __Pyx_ImportType_CheckSize { + __Pyx_ImportType_CheckSize_Error = 0, + __Pyx_ImportType_CheckSize_Warn = 1, + __Pyx_ImportType_CheckSize_Ignore = 2 +}; +static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); +#endif + +/* GetVTable.proto */ +static void* __Pyx_GetVtable(PyObject *dict); + +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + +/* CodeObjectCache.proto */ +typedef struct { + PyCodeObject* code_object; + int code_line; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +/* AddTraceback.proto */ +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +/* GCCDiagnostics.proto */ +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) +#define __Pyx_HAS_GCC_DIAGNOSTIC +#endif + +/* CppExceptionConversion.proto */ +#ifndef __Pyx_CppExn2PyErr +#include +#include +#include +#include +static void __Pyx_CppExn2PyErr() { + try { + if (PyErr_Occurred()) + ; // let the latest Python exn pass through and ignore the current one + else + throw; + } catch (const std::bad_alloc& exn) { + PyErr_SetString(PyExc_MemoryError, exn.what()); + } catch (const std::bad_cast& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::bad_typeid& exn) { + PyErr_SetString(PyExc_TypeError, exn.what()); + } catch (const std::domain_error& exn) { + PyErr_SetString(PyExc_ValueError, exn.what()); + } catch (const std::invalid_argument& exn) { + PyErr_SetString(PyExc_ValueError, exn.what()); + } catch (const std::ios_base::failure& exn) { + PyErr_SetString(PyExc_IOError, exn.what()); + } catch (const std::out_of_range& exn) { + PyErr_SetString(PyExc_IndexError, exn.what()); + } catch (const std::overflow_error& exn) { + PyErr_SetString(PyExc_OverflowError, exn.what()); + } catch (const std::range_error& exn) { + PyErr_SetString(PyExc_ArithmeticError, exn.what()); + } catch (const std::underflow_error& exn) { + PyErr_SetString(PyExc_ArithmeticError, exn.what()); + } catch (const std::exception& exn) { + PyErr_SetString(PyExc_RuntimeError, exn.what()); + } + catch (...) + { + PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); + } +} +#endif + +/* None.proto */ +#include + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +/* BufferStructDeclare.proto */ +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +/* MemviewSliceIsContig.proto */ +static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim); + +/* OverlappingSlices.proto */ +static int __pyx_slices_overlap(__Pyx_memviewslice *slice1, + __Pyx_memviewslice *slice2, + int ndim, size_t itemsize); + +/* Capsule.proto */ +static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *); + +/* MemviewSliceCopyTemplate.proto */ +static __Pyx_memviewslice +__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, + const char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + int dtype_is_object); + +/* MemviewSliceInit.proto */ +#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d +#define __Pyx_MEMVIEW_DIRECT 1 +#define __Pyx_MEMVIEW_PTR 2 +#define __Pyx_MEMVIEW_FULL 4 +#define __Pyx_MEMVIEW_CONTIG 8 +#define __Pyx_MEMVIEW_STRIDED 16 +#define __Pyx_MEMVIEW_FOLLOW 32 +#define __Pyx_IS_C_CONTIG 1 +#define __Pyx_IS_F_CONTIG 2 +static int __Pyx_init_memviewslice( + struct __pyx_memoryview_obj *memview, + int ndim, + __Pyx_memviewslice *memviewslice, + int memview_is_new_reference); +static CYTHON_INLINE int __pyx_add_acquisition_count_locked( + __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); +static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( + __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); +#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p) +#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview)) +#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__) +#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__) +static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); + +/* CIntFromPy.proto */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +/* CIntFromPy.proto */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +/* CIntToPy.proto */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +/* CIntFromPy.proto */ +static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); + +/* CheckBinaryVersion.proto */ +static int __Pyx_check_binary_version(void); + +/* InitStrings.proto */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/ +static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/ +static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/ +static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/ +static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/ +static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/ +static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/ +static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/ +static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/ +static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libcpp.string' */ + +/* Module declarations from 'libcpp.vector' */ + +/* Module declarations from 'libcpp' */ + +/* Module declarations from 'libcpp.memory' */ + +/* Module declarations from 'libcpp.utility' */ + +/* Module declarations from 'libc.stdint' */ + +/* Module declarations from 'cuda.ccudart' */ + +/* Module declarations from 'rmm._lib.cuda_stream_view' */ + +/* Module declarations from 'rmm._cuda.stream' */ +static PyTypeObject *__pyx_ptype_3rmm_5_cuda_6stream_Stream = 0; + +/* Module declarations from 'rmm._lib.memory_resource' */ +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor = 0; +static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor = 0; + +/* Module declarations from 'rmm._lib.device_buffer' */ +static PyTypeObject *__pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer = 0; + +/* Module declarations from 'cudf._lib.cpp.types' */ + +/* Module declarations from 'cudf._lib.cpp.column.column_view' */ + +/* Module declarations from 'cudf._lib.cpp.column.column' */ + +/* Module declarations from 'cudf._lib.column' */ +static PyTypeObject *__pyx_ptype_4cudf_4_lib_6column_Column = 0; + +/* Module declarations from 'strings_udf._lib.cpp.strings_udf' */ + +/* Module declarations from 'strings_udf._lib.cudf_jit_udf' */ +static PyTypeObject *__pyx_array_type = 0; +static PyTypeObject *__pyx_MemviewEnum_type = 0; +static PyTypeObject *__pyx_memoryview_type = 0; +static PyTypeObject *__pyx_memoryviewslice_type = 0; +static PyObject *generic = 0; +static PyObject *strided = 0; +static PyObject *indirect = 0; +static PyObject *contiguous = 0; +static PyObject *indirect_contiguous = 0; +static int __pyx_memoryview_thread_locks_used; +static PyThread_type_lock __pyx_memoryview_thread_locks[8]; +static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ +static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/ +static void *__pyx_align_pointer(void *, size_t); /*proto*/ +static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/ +static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/ +static PyObject *_unellipsify(PyObject *, int); /*proto*/ +static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/ +static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/ +static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/ +static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/ +static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/ +static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/ +static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ +static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ +static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/ +static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ +static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/ +static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/ +static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/ +static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/ +static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/ +static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/ +static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/ +static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/ +static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/ +static int __pyx_memoryview_err(PyObject *, char *); /*proto*/ +static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/ +static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/ +static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/ +static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ +static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ +static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/ +static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/ +static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/ +#define __Pyx_MODULE_NAME "strings_udf._lib.cudf_jit_udf" +extern int __pyx_module_is_main_strings_udf___lib__cudf_jit_udf; +int __pyx_module_is_main_strings_udf___lib__cudf_jit_udf = 0; + +/* Implementation of 'strings_udf._lib.cudf_jit_udf' */ +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_MemoryError; +static PyObject *__pyx_builtin_enumerate; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_TypeError; +static PyObject *__pyx_builtin_Ellipsis; +static PyObject *__pyx_builtin_id; +static PyObject *__pyx_builtin_IndexError; +static const char __pyx_k_I[] = "-I"; +static const char __pyx_k_O[] = "O"; +static const char __pyx_k_c[] = "c"; +static const char __pyx_k_id[] = "id"; +static const char __pyx_k_np[] = "np"; +static const char __pyx_k_os[] = "os"; +static const char __pyx_k_col[] = "col"; +static const char __pyx_k_get[] = "get"; +static const char __pyx_k_new[] = "__new__"; +static const char __pyx_k_obj[] = "obj"; +static const char __pyx_k_udf[] = "udf"; +static const char __pyx_k_base[] = "base"; +static const char __pyx_k_cols[] = "cols"; +static const char __pyx_k_data[] = "data"; +static const char __pyx_k_dict[] = "__dict__"; +static const char __pyx_k_main[] = "__main__"; +static const char __pyx_k_mode[] = "mode"; +static const char __pyx_k_name[] = "name"; +static const char __pyx_k_ndim[] = "ndim"; +static const char __pyx_k_pack[] = "pack"; +static const char __pyx_k_size[] = "size"; +static const char __pyx_k_step[] = "step"; +static const char __pyx_k_stop[] = "stop"; +static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_ASCII[] = "ASCII"; +static const char __pyx_k_UTF_8[] = "UTF-8"; +static const char __pyx_k_c_udf[] = "c_udf"; +static const char __pyx_k_class[] = "__class__"; +static const char __pyx_k_error[] = "error"; +static const char __pyx_k_flags[] = "flags"; +static const char __pyx_k_int64[] = "int64"; +static const char __pyx_k_numpy[] = "numpy"; +static const char __pyx_k_range[] = "range"; +static const char __pyx_k_shape[] = "shape"; +static const char __pyx_k_start[] = "start"; +static const char __pyx_k_Buffer[] = "Buffer"; +static const char __pyx_k_buffer[] = "buffer"; +static const char __pyx_k_c_name[] = "c_name"; +static const char __pyx_k_c_size[] = "c_size"; +static const char __pyx_k_column[] = "_column"; +static const char __pyx_k_encode[] = "encode"; +static const char __pyx_k_format[] = "format"; +static const char __pyx_k_import[] = "__import__"; +static const char __pyx_k_name_2[] = "__name__"; +static const char __pyx_k_pickle[] = "pickle"; +static const char __pyx_k_reduce[] = "__reduce__"; +static const char __pyx_k_struct[] = "struct"; +static const char __pyx_k_unpack[] = "unpack"; +static const char __pyx_k_update[] = "update"; +static const char __pyx_k_environ[] = "environ"; +static const char __pyx_k_fortran[] = "fortran"; +static const char __pyx_k_include[] = "/include"; +static const char __pyx_k_memview[] = "memview"; +static const char __pyx_k_tbl_ptr[] = "tbl_ptr"; +static const char __pyx_k_Ellipsis[] = "Ellipsis"; +static const char __pyx_k_c_buffer[] = "c_buffer"; +static const char __pyx_k_c_module[] = "c_module"; +static const char __pyx_k_c_result[] = "c_result"; +static const char __pyx_k_d_buffer[] = "d_buffer"; +static const char __pyx_k_getstate[] = "__getstate__"; +static const char __pyx_k_itemsize[] = "itemsize"; +static const char __pyx_k_pyx_type[] = "__pyx_type"; +static const char __pyx_k_setstate[] = "__setstate__"; +static const char __pyx_k_TypeError[] = "TypeError"; +static const char __pyx_k_c_columns[] = "c_columns"; +static const char __pyx_k_c_options[] = "c_options"; +static const char __pyx_k_enumerate[] = "enumerate"; +static const char __pyx_k_pyx_state[] = "__pyx_state"; +static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; +static const char __pyx_k_IndexError[] = "IndexError"; +static const char __pyx_k_ValueError[] = "ValueError"; +static const char __pyx_k_pyx_result[] = "__pyx_result"; +static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static const char __pyx_k_MemoryError[] = "MemoryError"; +static const char __pyx_k_PickleError[] = "PickleError"; +static const char __pyx_k_process_udf[] = "process_udf"; +static const char __pyx_k_strings_col[] = "strings_col"; +static const char __pyx_k_CONDA_PREFIX[] = "CONDA_PREFIX"; +static const char __pyx_k_include_path[] = "include_path"; +static const char __pyx_k_pyx_checksum[] = "__pyx_checksum"; +static const char __pyx_k_stringsource[] = "stringsource"; +static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; +static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; +static const char __pyx_k_View_MemoryView[] = "View.MemoryView"; +static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; +static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; +static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError"; +static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; +static const char __pyx_k_cudf_core_buffer[] = "cudf.core.buffer"; +static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_from_dstring_array[] = "from_dstring_array"; +static const char __pyx_k_strided_and_direct[] = ""; +static const char __pyx_k_strided_and_indirect[] = ""; +static const char __pyx_k_to_string_view_array[] = "to_string_view_array"; +static const char __pyx_k_contiguous_and_direct[] = ""; +static const char __pyx_k_MemoryView_of_r_object[] = ""; +static const char __pyx_k_MemoryView_of_r_at_0x_x[] = ""; +static const char __pyx_k_contiguous_and_indirect[] = ""; +static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'"; +static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d."; +static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; +static const char __pyx_k_get_character_flags_table_ptr[] = "get_character_flags_table_ptr"; +static const char __pyx_k_strings_udf__lib_cudf_jit_udf[] = "strings_udf._lib.cudf_jit_udf"; +static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; +static const char __pyx_k_strided_and_direct_or_indirect[] = ""; +static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; +static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory."; +static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview"; +static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview"; +static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array"; +static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))"; +static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported"; +static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s"; +static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)"; +static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object"; +static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)"; +static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; +static const char __pyx_k_strings_udf__lib_cudf_jit_udf_py[] = "strings_udf/_lib/cudf_jit_udf.pyx"; +static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides."; +static PyObject *__pyx_n_s_ASCII; +static PyObject *__pyx_n_s_Buffer; +static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri; +static PyObject *__pyx_n_u_CONDA_PREFIX; +static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is; +static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor; +static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi; +static PyObject *__pyx_kp_s_Cannot_index_with_type_s; +static PyObject *__pyx_n_s_Ellipsis; +static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr; +static PyObject *__pyx_kp_u_I; +static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0; +static PyObject *__pyx_n_s_IndexError; +static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte; +static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr; +static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d; +static PyObject *__pyx_n_s_MemoryError; +static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x; +static PyObject *__pyx_kp_s_MemoryView_of_r_object; +static PyObject *__pyx_n_b_O; +static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a; +static PyObject *__pyx_n_s_PickleError; +static PyObject *__pyx_n_s_TypeError; +static PyObject *__pyx_kp_u_UTF_8; +static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_View_MemoryView; +static PyObject *__pyx_n_s_allocate_buffer; +static PyObject *__pyx_n_s_base; +static PyObject *__pyx_n_s_buffer; +static PyObject *__pyx_n_s_c; +static PyObject *__pyx_n_u_c; +static PyObject *__pyx_n_s_c_buffer; +static PyObject *__pyx_n_s_c_columns; +static PyObject *__pyx_n_s_c_module; +static PyObject *__pyx_n_s_c_name; +static PyObject *__pyx_n_s_c_options; +static PyObject *__pyx_n_s_c_result; +static PyObject *__pyx_n_s_c_size; +static PyObject *__pyx_n_s_c_udf; +static PyObject *__pyx_n_s_class; +static PyObject *__pyx_n_s_cline_in_traceback; +static PyObject *__pyx_n_s_col; +static PyObject *__pyx_n_s_cols; +static PyObject *__pyx_n_s_column; +static PyObject *__pyx_kp_s_contiguous_and_direct; +static PyObject *__pyx_kp_s_contiguous_and_indirect; +static PyObject *__pyx_n_s_cudf_core_buffer; +static PyObject *__pyx_n_s_d_buffer; +static PyObject *__pyx_n_s_data; +static PyObject *__pyx_n_s_dict; +static PyObject *__pyx_n_s_dtype_is_object; +static PyObject *__pyx_n_s_encode; +static PyObject *__pyx_n_s_enumerate; +static PyObject *__pyx_n_s_environ; +static PyObject *__pyx_n_s_error; +static PyObject *__pyx_n_s_flags; +static PyObject *__pyx_n_s_format; +static PyObject *__pyx_n_s_fortran; +static PyObject *__pyx_n_u_fortran; +static PyObject *__pyx_n_s_from_dstring_array; +static PyObject *__pyx_n_s_get; +static PyObject *__pyx_n_s_get_character_flags_table_ptr; +static PyObject *__pyx_n_s_getstate; +static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; +static PyObject *__pyx_n_s_id; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_kp_u_include; +static PyObject *__pyx_n_s_include_path; +static PyObject *__pyx_n_s_int64; +static PyObject *__pyx_n_s_itemsize; +static PyObject *__pyx_kp_s_itemsize_0_for_cython_array; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_memview; +static PyObject *__pyx_n_s_mode; +static PyObject *__pyx_n_s_name; +static PyObject *__pyx_n_s_name_2; +static PyObject *__pyx_n_s_ndim; +static PyObject *__pyx_n_s_new; +static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; +static PyObject *__pyx_n_s_np; +static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_n_s_obj; +static PyObject *__pyx_n_s_os; +static PyObject *__pyx_n_s_pack; +static PyObject *__pyx_n_s_pickle; +static PyObject *__pyx_n_s_process_udf; +static PyObject *__pyx_n_s_pyx_PickleError; +static PyObject *__pyx_n_s_pyx_checksum; +static PyObject *__pyx_n_s_pyx_getbuffer; +static PyObject *__pyx_n_s_pyx_result; +static PyObject *__pyx_n_s_pyx_state; +static PyObject *__pyx_n_s_pyx_type; +static PyObject *__pyx_n_s_pyx_unpickle_Enum; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_reduce; +static PyObject *__pyx_n_s_reduce_cython; +static PyObject *__pyx_n_s_reduce_ex; +static PyObject *__pyx_n_s_setstate; +static PyObject *__pyx_n_s_setstate_cython; +static PyObject *__pyx_n_s_shape; +static PyObject *__pyx_n_s_size; +static PyObject *__pyx_n_s_start; +static PyObject *__pyx_n_s_step; +static PyObject *__pyx_n_s_stop; +static PyObject *__pyx_kp_s_strided_and_direct; +static PyObject *__pyx_kp_s_strided_and_direct_or_indirect; +static PyObject *__pyx_kp_s_strided_and_indirect; +static PyObject *__pyx_n_s_strings_col; +static PyObject *__pyx_n_s_strings_udf__lib_cudf_jit_udf; +static PyObject *__pyx_kp_s_strings_udf__lib_cudf_jit_udf_py; +static PyObject *__pyx_kp_s_stringsource; +static PyObject *__pyx_n_s_struct; +static PyObject *__pyx_n_s_tbl_ptr; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_to_string_view_array; +static PyObject *__pyx_n_s_udf; +static PyObject *__pyx_kp_s_unable_to_allocate_array_data; +static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str; +static PyObject *__pyx_n_s_unpack; +static PyObject *__pyx_n_s_update; +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_process_udf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_udf, PyObject *__pyx_v_name, PyObject *__pyx_v_cols); /* proto */ +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cudf_4_lib_6column_Column *__pyx_v_strings_col); /* proto */ +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_v_d_buffer); /* proto */ +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */ +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ +static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */ +static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */ +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ +static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_112105877; +static PyObject *__pyx_int_136983863; +static PyObject *__pyx_int_184977713; +static PyObject *__pyx_int_neg_1; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_slice__15; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__13; +static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__16; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__18; +static PyObject *__pyx_tuple__19; +static PyObject *__pyx_tuple__20; +static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__24; +static PyObject *__pyx_tuple__26; +static PyObject *__pyx_tuple__28; +static PyObject *__pyx_tuple__29; +static PyObject *__pyx_tuple__30; +static PyObject *__pyx_tuple__31; +static PyObject *__pyx_tuple__32; +static PyObject *__pyx_tuple__33; +static PyObject *__pyx_codeobj__21; +static PyObject *__pyx_codeobj__23; +static PyObject *__pyx_codeobj__25; +static PyObject *__pyx_codeobj__27; +static PyObject *__pyx_codeobj__34; +/* Late includes */ + +/* "strings_udf/_lib/cudf_jit_udf.pyx":35 + * import numpy as np + * + * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< + * cdef string c_udf + * cdef string c_name + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_1process_udf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_process_udf[] = "process_udf(udf, name, cols)"; +static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_1process_udf = {"process_udf", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_1process_udf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_process_udf}; +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_1process_udf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_udf = 0; + PyObject *__pyx_v_name = 0; + PyObject *__pyx_v_cols = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("process_udf (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_udf,&__pyx_n_s_name,&__pyx_n_s_cols,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_udf)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("process_udf", 1, 3, 3, 1); __PYX_ERR(0, 35, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cols)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("process_udf", 1, 3, 3, 2); __PYX_ERR(0, 35, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_udf") < 0)) __PYX_ERR(0, 35, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_udf = values[0]; + __pyx_v_name = values[1]; + __pyx_v_cols = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("process_udf", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 35, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.process_udf", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_process_udf(__pyx_self, __pyx_v_udf, __pyx_v_name, __pyx_v_cols); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_process_udf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_udf, PyObject *__pyx_v_name, PyObject *__pyx_v_cols) { + std::string __pyx_v_c_udf; + std::string __pyx_v_c_name; + cudf::size_type __pyx_v_c_size; + std::vector __pyx_v_c_columns; + std::unique_ptr __pyx_v_c_module; + std::vector __pyx_v_c_options; + std::unique_ptr __pyx_v_c_result; + struct __pyx_obj_4cudf_4_lib_6column_Column *__pyx_v_col = 0; + PyObject *__pyx_v_c = NULL; + PyObject *__pyx_v_include_path = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + std::string __pyx_t_4; + cudf::size_type __pyx_t_5; + Py_ssize_t __pyx_t_6; + PyObject *(*__pyx_t_7)(PyObject *); + cudf::column_view __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("process_udf", 0); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":46 + * cdef unique_ptr[column] c_result + * + * c_udf = udf.encode('UTF-8') # <<<<<<<<<<<<<< + * c_name = name.encode('UTF-8') + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_udf, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_UTF_8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_UTF_8); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_c_udf = __pyx_t_4; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":47 + * + * c_udf = udf.encode('UTF-8') + * c_name = name.encode('UTF-8') # <<<<<<<<<<<<<< + * + * cdef Column col = cols[0]._column + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_UTF_8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_UTF_8); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_c_name = __pyx_t_4; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":49 + * c_name = name.encode('UTF-8') + * + * cdef Column col = cols[0]._column # <<<<<<<<<<<<<< + * c_size = col.size + * for c in cols: + */ + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cols, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_column); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cudf_4_lib_6column_Column))))) __PYX_ERR(0, 49, __pyx_L1_error) + __pyx_v_col = ((struct __pyx_obj_4cudf_4_lib_6column_Column *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":50 + * + * cdef Column col = cols[0]._column + * c_size = col.size # <<<<<<<<<<<<<< + * for c in cols: + * col = c._column + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_col), __pyx_n_s_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyInt_As_int32_t(__pyx_t_2); if (unlikely((__pyx_t_5 == ((cudf::size_type)-1)) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_c_size = __pyx_t_5; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":51 + * cdef Column col = cols[0]._column + * c_size = col.size + * for c in cols: # <<<<<<<<<<<<<< + * col = c._column + * c_columns.push_back(col.view()) + */ + if (likely(PyList_CheckExact(__pyx_v_cols)) || PyTuple_CheckExact(__pyx_v_cols)) { + __pyx_t_2 = __pyx_v_cols; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; + __pyx_t_7 = NULL; + } else { + __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_cols); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_7)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 51, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } else { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 51, __pyx_L1_error) + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + #endif + } + } else { + __pyx_t_1 = __pyx_t_7(__pyx_t_2); + if (unlikely(!__pyx_t_1)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(0, 51, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_1); + __pyx_t_1 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":52 + * c_size = col.size + * for c in cols: + * col = c._column # <<<<<<<<<<<<<< + * c_columns.push_back(col.view()) + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_column); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cudf_4_lib_6column_Column))))) __PYX_ERR(0, 52, __pyx_L1_error) + __Pyx_DECREF_SET(__pyx_v_col, ((struct __pyx_obj_4cudf_4_lib_6column_Column *)__pyx_t_1)); + __pyx_t_1 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":53 + * for c in cols: + * col = c._column + * c_columns.push_back(col.view()) # <<<<<<<<<<<<<< + * + * include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" + */ + __pyx_t_8 = ((struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *)__pyx_v_col->__pyx_vtab)->view(__pyx_v_col); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error) + try { + __pyx_v_c_columns.push_back(__pyx_t_8); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 53, __pyx_L1_error) + } + + /* "strings_udf/_lib/cudf_jit_udf.pyx":51 + * cdef Column col = cols[0]._column + * c_size = col.size + * for c in cols: # <<<<<<<<<<<<<< + * col = c._column + * c_columns.push_back(col.view()) + */ + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":55 + * c_columns.push_back(col.view()) + * + * include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" # <<<<<<<<<<<<<< + * c_options.push_back(str(include_path).encode('UTF-8')) + * + */ + __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_environ); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_n_u_CONDA_PREFIX) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_n_u_CONDA_PREFIX); + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(__pyx_kp_u_I, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_kp_u_include); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_include_path = __pyx_t_2; + __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":56 + * + * include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" + * c_options.push_back(str(include_path).encode('UTF-8')) # <<<<<<<<<<<<<< + * + * #with nogil: + */ + __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_include_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyUnicode_AsUTF8String(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + try { + __pyx_v_c_options.push_back(__pyx_t_4); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 56, __pyx_L1_error) + } + + /* "strings_udf/_lib/cudf_jit_udf.pyx":59 + * + * #with nogil: + * c_module = move(cpp_create_udf_module(c_udf, c_options)) # <<<<<<<<<<<<<< + * # c_module will be nullptr if there is a compile error + * + */ + __pyx_v_c_module = cython_std::move >(create_udf_module(__pyx_v_c_udf, __pyx_v_c_options)); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":63 + * + * #with nogil: + * c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) # <<<<<<<<<<<<<< + * + * return Column.from_unique_ptr(move(c_result)) + */ + __pyx_v_c_result = cython_std::move >(call_udf((__pyx_v_c_module.get()[0]), __pyx_v_c_name, __pyx_v_c_size, __pyx_v_c_columns)); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":65 + * c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) + * + * return Column.from_unique_ptr(move(c_result)) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cudf_4_lib_6column_Column->from_unique_ptr(cython_std::move >(__pyx_v_c_result))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":35 + * import numpy as np + * + * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< + * cdef string c_udf + * cdef string c_name + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.process_udf", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_col); + __Pyx_XDECREF(__pyx_v_c); + __Pyx_XDECREF(__pyx_v_include_path); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "strings_udf/_lib/cudf_jit_udf.pyx":68 + * + * + * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< + * cdef unique_ptr[device_buffer] c_buffer + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array(PyObject *__pyx_self, PyObject *__pyx_v_strings_col); /*proto*/ +static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array[] = "to_string_view_array(Column strings_col)"; +static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array = {"to_string_view_array", (PyCFunction)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array, METH_O, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array}; +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array(PyObject *__pyx_self, PyObject *__pyx_v_strings_col) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("to_string_view_array (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strings_col), __pyx_ptype_4cudf_4_lib_6column_Column, 1, "strings_col", 0))) __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array(__pyx_self, ((struct __pyx_obj_4cudf_4_lib_6column_Column *)__pyx_v_strings_col)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cudf_4_lib_6column_Column *__pyx_v_strings_col) { + std::unique_ptr __pyx_v_c_buffer; + PyObject *__pyx_v_buffer = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + cudf::column_view __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("to_string_view_array", 0); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":72 + * + * #with nogil: + * c_buffer = move(cpp_to_string_view_array(strings_col.view())) # <<<<<<<<<<<<<< + * + * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *)__pyx_v_strings_col->__pyx_vtab)->view(__pyx_v_strings_col); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 72, __pyx_L1_error) + __pyx_v_c_buffer = cython_std::move >(to_string_view_array(__pyx_t_1)); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":74 + * c_buffer = move(cpp_to_string_view_array(strings_col.view())) + * + * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) # <<<<<<<<<<<<<< + * buffer = Buffer(buffer) + * return buffer + */ + __pyx_t_2 = ((PyObject *)__pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer->c_from_unique_ptr(cython_std::move >(__pyx_v_c_buffer))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_buffer = __pyx_t_2; + __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":75 + * + * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) + * buffer = Buffer(buffer) # <<<<<<<<<<<<<< + * return buffer + * + */ + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_buffer) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_buffer); + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF_SET(__pyx_v_buffer, __pyx_t_2); + __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":76 + * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) + * buffer = Buffer(buffer) + * return buffer # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_buffer); + __pyx_r = __pyx_v_buffer; + goto __pyx_L0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":68 + * + * + * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< + * cdef unique_ptr[device_buffer] c_buffer + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.to_string_view_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_buffer); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "strings_udf/_lib/cudf_jit_udf.pyx":79 + * + * + * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< + * cdef size_t size = d_buffer.c_size() + * cdef void* data = d_buffer.c_data() + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array(PyObject *__pyx_self, PyObject *__pyx_v_d_buffer); /*proto*/ +static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array[] = "from_dstring_array(DeviceBuffer d_buffer)"; +static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array = {"from_dstring_array", (PyCFunction)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array, METH_O, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array}; +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array(PyObject *__pyx_self, PyObject *__pyx_v_d_buffer) { + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("from_dstring_array (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_d_buffer), __pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer, 1, "d_buffer", 0))) __PYX_ERR(0, 79, __pyx_L1_error) + __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array(__pyx_self, ((struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *)__pyx_v_d_buffer)); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_v_d_buffer) { + size_t __pyx_v_size; + void *__pyx_v_data; + std::unique_ptr __pyx_v_c_result; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + size_t __pyx_t_1; + void *__pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("from_dstring_array", 0); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":80 + * + * def from_dstring_array(DeviceBuffer d_buffer): + * cdef size_t size = d_buffer.c_size() # <<<<<<<<<<<<<< + * cdef void* data = d_buffer.c_data() + * cdef unique_ptr[column] c_result + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *)__pyx_v_d_buffer->__pyx_vtab)->c_size(__pyx_v_d_buffer); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_v_size = __pyx_t_1; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":81 + * def from_dstring_array(DeviceBuffer d_buffer): + * cdef size_t size = d_buffer.c_size() + * cdef void* data = d_buffer.c_data() # <<<<<<<<<<<<<< + * cdef unique_ptr[column] c_result + * # data = + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *)__pyx_v_d_buffer->__pyx_vtab)->c_data(__pyx_v_d_buffer); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_v_data = __pyx_t_2; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":86 + * + * #with nogil: + * c_result = move(cpp_from_dstring_array(data, size)) # <<<<<<<<<<<<<< + * + * return Column.from_unique_ptr(move(c_result)) + */ + __pyx_v_c_result = cython_std::move >(from_dstring_array(__pyx_v_data, __pyx_v_size)); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":88 + * c_result = move(cpp_from_dstring_array(data, size)) + * + * return Column.from_unique_ptr(move(c_result)) # <<<<<<<<<<<<<< + * + * def get_character_flags_table_ptr(): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((PyObject *)__pyx_vtabptr_4cudf_4_lib_6column_Column->from_unique_ptr(cython_std::move >(__pyx_v_c_result))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":79 + * + * + * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< + * cdef size_t size = d_buffer.c_size() + * cdef void* data = d_buffer.c_data() + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.from_dstring_array", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "strings_udf/_lib/cudf_jit_udf.pyx":90 + * return Column.from_unique_ptr(move(c_result)) + * + * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< + * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + * return np.int64(tbl_ptr) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr[] = "get_character_flags_table_ptr()"; +static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr = {"get_character_flags_table_ptr", (PyCFunction)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr, METH_NOARGS, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr}; +static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_character_flags_table_ptr (wrapper)", 0); + __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr(__pyx_self); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr(CYTHON_UNUSED PyObject *__pyx_self) { + uint8_t const *__pyx_v_tbl_ptr; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + uint8_t const *__pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_character_flags_table_ptr", 0); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":91 + * + * def get_character_flags_table_ptr(): + * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() # <<<<<<<<<<<<<< + * return np.int64(tbl_ptr) + */ + try { + __pyx_t_1 = cudf::strings::detail::get_character_flags_table(); + } catch(...) { + __Pyx_CppExn2PyErr(); + __PYX_ERR(0, 91, __pyx_L1_error) + } + __pyx_v_tbl_ptr = __pyx_t_1; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":92 + * def get_character_flags_table_ptr(): + * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + * return np.int64(tbl_ptr) # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_tbl_ptr)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":90 + * return Column.from_unique_ptr(move(c_result)) + * + * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< + * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + * return np.int64(tbl_ptr) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.get_character_flags_table_ptr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "string.from_py":13 + * + * @cname("__pyx_convert_string_from_py_std__in_string") + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< + * cdef Py_ssize_t length = 0 + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + */ + +static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) { + Py_ssize_t __pyx_v_length; + char const *__pyx_v_data; + std::string __pyx_r; + __Pyx_RefNannyDeclarations + char const *__pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0); + + /* "string.from_py":14 + * @cname("__pyx_convert_string_from_py_std__in_string") + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: + * cdef Py_ssize_t length = 0 # <<<<<<<<<<<<<< + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + * return string(data, length) + */ + __pyx_v_length = 0; + + /* "string.from_py":15 + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: + * cdef Py_ssize_t length = 0 + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) # <<<<<<<<<<<<<< + * return string(data, length) + * + */ + __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(1, 15, __pyx_L1_error) + __pyx_v_data = __pyx_t_1; + + /* "string.from_py":16 + * cdef Py_ssize_t length = 0 + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + * return string(data, length) # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = std::string(__pyx_v_data, __pyx_v_length); + goto __pyx_L0; + + /* "string.from_py":13 + * + * @cname("__pyx_convert_string_from_py_std__in_string") + * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< + * cdef Py_ssize_t length = 0 + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_pretend_to_initialize(&__pyx_r); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":122 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + +/* Python wrapper */ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_shape = 0; + Py_ssize_t __pyx_v_itemsize; + PyObject *__pyx_v_format = 0; + PyObject *__pyx_v_mode = 0; + int __pyx_v_allocate_buffer; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0}; + PyObject* values[5] = {0,0,0,0,0}; + values[3] = ((PyObject *)__pyx_n_s_c); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(1, 122, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(1, 122, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 3: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode); + if (value) { values[3] = value; kw_args--; } + } + CYTHON_FALLTHROUGH; + case 4: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 122, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + CYTHON_FALLTHROUGH; + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + CYTHON_FALLTHROUGH; + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_shape = ((PyObject*)values[0]); + __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 122, __pyx_L3_error) + __pyx_v_format = values[2]; + __pyx_v_mode = values[3]; + if (values[4]) { + __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 123, __pyx_L3_error) + } else { + + /* "View.MemoryView":123 + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, + * mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<< + * + * cdef int idx + */ + __pyx_v_allocate_buffer = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 122, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(1, 122, __pyx_L1_error) + if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(1, 122, __pyx_L1_error) + } + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); + + /* "View.MemoryView":122 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { + int __pyx_v_idx; + Py_ssize_t __pyx_v_i; + Py_ssize_t __pyx_v_dim; + PyObject **__pyx_v_p; + char __pyx_v_order; + int __pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + char *__pyx_t_7; + int __pyx_t_8; + Py_ssize_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + Py_ssize_t __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + __Pyx_INCREF(__pyx_v_format); + + /* "View.MemoryView":129 + * cdef PyObject **p + * + * self.ndim = len(shape) # <<<<<<<<<<<<<< + * self.itemsize = itemsize + * + */ + if (unlikely(__pyx_v_shape == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + __PYX_ERR(1, 129, __pyx_L1_error) + } + __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 129, __pyx_L1_error) + __pyx_v_self->ndim = ((int)__pyx_t_1); + + /* "View.MemoryView":130 + * + * self.ndim = len(shape) + * self.itemsize = itemsize # <<<<<<<<<<<<<< + * + * if not self.ndim: + */ + __pyx_v_self->itemsize = __pyx_v_itemsize; + + /* "View.MemoryView":132 + * self.itemsize = itemsize + * + * if not self.ndim: # <<<<<<<<<<<<<< + * raise ValueError("Empty shape tuple for cython.array") + * + */ + __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0); + if (unlikely(__pyx_t_2)) { + + /* "View.MemoryView":133 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 133, __pyx_L1_error) + + /* "View.MemoryView":132 + * self.itemsize = itemsize + * + * if not self.ndim: # <<<<<<<<<<<<<< + * raise ValueError("Empty shape tuple for cython.array") + * + */ + } + + /* "View.MemoryView":135 + * raise ValueError("Empty shape tuple for cython.array") + * + * if itemsize <= 0: # <<<<<<<<<<<<<< + * raise ValueError("itemsize <= 0 for cython.array") + * + */ + __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0); + if (unlikely(__pyx_t_2)) { + + /* "View.MemoryView":136 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 136, __pyx_L1_error) + + /* "View.MemoryView":135 + * raise ValueError("Empty shape tuple for cython.array") + * + * if itemsize <= 0: # <<<<<<<<<<<<<< + * raise ValueError("itemsize <= 0 for cython.array") + * + */ + } + + /* "View.MemoryView":138 + * raise ValueError("itemsize <= 0 for cython.array") + * + * if not isinstance(format, bytes): # <<<<<<<<<<<<<< + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + */ + __pyx_t_2 = PyBytes_Check(__pyx_v_format); + __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":139 + * + * if not isinstance(format, bytes): + * format = format.encode('ASCII') # <<<<<<<<<<<<<< + * self._format = format # keep a reference to the byte string + * self.format = self._format + */ + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ASCII) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ASCII); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 139, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":138 + * raise ValueError("itemsize <= 0 for cython.array") + * + * if not isinstance(format, bytes): # <<<<<<<<<<<<<< + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + */ + } + + /* "View.MemoryView":140 + * if not isinstance(format, bytes): + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<< + * self.format = self._format + * + */ + if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(1, 140, __pyx_L1_error) + __pyx_t_3 = __pyx_v_format; + __Pyx_INCREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->_format); + __Pyx_DECREF(__pyx_v_self->_format); + __pyx_v_self->_format = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":141 + * format = format.encode('ASCII') + * self._format = format # keep a reference to the byte string + * self.format = self._format # <<<<<<<<<<<<<< + * + * + */ + if (unlikely(__pyx_v_self->_format == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(1, 141, __pyx_L1_error) + } + __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(1, 141, __pyx_L1_error) + __pyx_v_self->format = __pyx_t_7; + + /* "View.MemoryView":144 + * + * + * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<< + * self._strides = self._shape + self.ndim + * + */ + __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2))); + + /* "View.MemoryView":145 + * + * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) + * self._strides = self._shape + self.ndim # <<<<<<<<<<<<<< + * + * if not self._shape: + */ + __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim); + + /* "View.MemoryView":147 + * self._strides = self._shape + self.ndim + * + * if not self._shape: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate shape and strides.") + * + */ + __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0); + if (unlikely(__pyx_t_4)) { + + /* "View.MemoryView":148 + * + * if not self._shape: + * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 148, __pyx_L1_error) + + /* "View.MemoryView":147 + * self._strides = self._shape + self.ndim + * + * if not self._shape: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate shape and strides.") + * + */ + } + + /* "View.MemoryView":151 + * + * + * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + */ + __pyx_t_8 = 0; + __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 151, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 151, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 151, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_dim = __pyx_t_9; + __pyx_v_idx = __pyx_t_8; + __pyx_t_8 = (__pyx_t_8 + 1); + + /* "View.MemoryView":152 + * + * for idx, dim in enumerate(shape): + * if dim <= 0: # <<<<<<<<<<<<<< + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim + */ + __pyx_t_4 = ((__pyx_v_dim <= 0) != 0); + if (unlikely(__pyx_t_4)) { + + /* "View.MemoryView":153 + * for idx, dim in enumerate(shape): + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<< + * self._shape[idx] = dim + * + */ + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); + __pyx_t_5 = 0; + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_Raise(__pyx_t_10, 0, 0, 0); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __PYX_ERR(1, 153, __pyx_L1_error) + + /* "View.MemoryView":152 + * + * for idx, dim in enumerate(shape): + * if dim <= 0: # <<<<<<<<<<<<<< + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim + */ + } + + /* "View.MemoryView":154 + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + * self._shape[idx] = dim # <<<<<<<<<<<<<< + * + * cdef char order + */ + (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim; + + /* "View.MemoryView":151 + * + * + * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< + * if dim <= 0: + * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) + */ + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":157 + * + * cdef char order + * if mode == 'fortran': # <<<<<<<<<<<<<< + * order = b'F' + * self.mode = u'fortran' + */ + __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 157, __pyx_L1_error) + if (__pyx_t_4) { + + /* "View.MemoryView":158 + * cdef char order + * if mode == 'fortran': + * order = b'F' # <<<<<<<<<<<<<< + * self.mode = u'fortran' + * elif mode == 'c': + */ + __pyx_v_order = 'F'; + + /* "View.MemoryView":159 + * if mode == 'fortran': + * order = b'F' + * self.mode = u'fortran' # <<<<<<<<<<<<<< + * elif mode == 'c': + * order = b'C' + */ + __Pyx_INCREF(__pyx_n_u_fortran); + __Pyx_GIVEREF(__pyx_n_u_fortran); + __Pyx_GOTREF(__pyx_v_self->mode); + __Pyx_DECREF(__pyx_v_self->mode); + __pyx_v_self->mode = __pyx_n_u_fortran; + + /* "View.MemoryView":157 + * + * cdef char order + * if mode == 'fortran': # <<<<<<<<<<<<<< + * order = b'F' + * self.mode = u'fortran' + */ + goto __pyx_L10; + } + + /* "View.MemoryView":160 + * order = b'F' + * self.mode = u'fortran' + * elif mode == 'c': # <<<<<<<<<<<<<< + * order = b'C' + * self.mode = u'c' + */ + __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 160, __pyx_L1_error) + if (likely(__pyx_t_4)) { + + /* "View.MemoryView":161 + * self.mode = u'fortran' + * elif mode == 'c': + * order = b'C' # <<<<<<<<<<<<<< + * self.mode = u'c' + * else: + */ + __pyx_v_order = 'C'; + + /* "View.MemoryView":162 + * elif mode == 'c': + * order = b'C' + * self.mode = u'c' # <<<<<<<<<<<<<< + * else: + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + */ + __Pyx_INCREF(__pyx_n_u_c); + __Pyx_GIVEREF(__pyx_n_u_c); + __Pyx_GOTREF(__pyx_v_self->mode); + __Pyx_DECREF(__pyx_v_self->mode); + __pyx_v_self->mode = __pyx_n_u_c; + + /* "View.MemoryView":160 + * order = b'F' + * self.mode = u'fortran' + * elif mode == 'c': # <<<<<<<<<<<<<< + * order = b'C' + * self.mode = u'c' + */ + goto __pyx_L10; + } + + /* "View.MemoryView":164 + * self.mode = u'c' + * else: + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<< + * + * self.len = fill_contig_strides_array(self._shape, self._strides, + */ + /*else*/ { + __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_10, 0, 0, 0); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __PYX_ERR(1, 164, __pyx_L1_error) + } + __pyx_L10:; + + /* "View.MemoryView":166 + * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) + * + * self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<< + * itemsize, self.ndim, order) + * + */ + __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order); + + /* "View.MemoryView":169 + * itemsize, self.ndim, order) + * + * self.free_data = allocate_buffer # <<<<<<<<<<<<<< + * self.dtype_is_object = format == b'O' + * if allocate_buffer: + */ + __pyx_v_self->free_data = __pyx_v_allocate_buffer; + + /* "View.MemoryView":170 + * + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<< + * if allocate_buffer: + * + */ + __pyx_t_10 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 170, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 170, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_v_self->dtype_is_object = __pyx_t_4; + + /* "View.MemoryView":171 + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' + * if allocate_buffer: # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_4 = (__pyx_v_allocate_buffer != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":174 + * + * + * self.data = malloc(self.len) # <<<<<<<<<<<<<< + * if not self.data: + * raise MemoryError("unable to allocate array data.") + */ + __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len)); + + /* "View.MemoryView":175 + * + * self.data = malloc(self.len) + * if not self.data: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate array data.") + * + */ + __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0); + if (unlikely(__pyx_t_4)) { + + /* "View.MemoryView":176 + * self.data = malloc(self.len) + * if not self.data: + * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< + * + * if self.dtype_is_object: + */ + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_Raise(__pyx_t_10, 0, 0, 0); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __PYX_ERR(1, 176, __pyx_L1_error) + + /* "View.MemoryView":175 + * + * self.data = malloc(self.len) + * if not self.data: # <<<<<<<<<<<<<< + * raise MemoryError("unable to allocate array data.") + * + */ + } + + /* "View.MemoryView":178 + * raise MemoryError("unable to allocate array data.") + * + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * p = self.data + * for i in range(self.len / itemsize): + */ + __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":179 + * + * if self.dtype_is_object: + * p = self.data # <<<<<<<<<<<<<< + * for i in range(self.len / itemsize): + * p[i] = Py_None + */ + __pyx_v_p = ((PyObject **)__pyx_v_self->data); + + /* "View.MemoryView":180 + * if self.dtype_is_object: + * p = self.data + * for i in range(self.len / itemsize): # <<<<<<<<<<<<<< + * p[i] = Py_None + * Py_INCREF(Py_None) + */ + if (unlikely(__pyx_v_itemsize == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(1, 180, __pyx_L1_error) + } + else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) { + PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); + __PYX_ERR(1, 180, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize); + __pyx_t_9 = __pyx_t_1; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) { + __pyx_v_i = __pyx_t_11; + + /* "View.MemoryView":181 + * p = self.data + * for i in range(self.len / itemsize): + * p[i] = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * + */ + (__pyx_v_p[__pyx_v_i]) = Py_None; + + /* "View.MemoryView":182 + * for i in range(self.len / itemsize): + * p[i] = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * @cname('getbuffer') + */ + Py_INCREF(Py_None); + } + + /* "View.MemoryView":178 + * raise MemoryError("unable to allocate array data.") + * + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * p = self.data + * for i in range(self.len / itemsize): + */ + } + + /* "View.MemoryView":171 + * self.free_data = allocate_buffer + * self.dtype_is_object = format == b'O' + * if allocate_buffer: # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":122 + * cdef bint dtype_is_object + * + * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< + * mode="c", bint allocate_buffer=True): + * + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_format); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":185 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * cdef int bufmode = -1 + * if self.mode == u"c": + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_bufmode; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + char *__pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + Py_ssize_t *__pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + if (__pyx_v_info == NULL) { + PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); + return -1; + } + __Pyx_RefNannySetupContext("__getbuffer__", 0); + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + + /* "View.MemoryView":186 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 # <<<<<<<<<<<<<< + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + */ + __pyx_v_bufmode = -1; + + /* "View.MemoryView":187 + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 + * if self.mode == u"c": # <<<<<<<<<<<<<< + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + */ + __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 187, __pyx_L1_error) + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":188 + * cdef int bufmode = -1 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + */ + __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); + + /* "View.MemoryView":187 + * def __getbuffer__(self, Py_buffer *info, int flags): + * cdef int bufmode = -1 + * if self.mode == u"c": # <<<<<<<<<<<<<< + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + */ + goto __pyx_L3; + } + + /* "View.MemoryView":189 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": # <<<<<<<<<<<<<< + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + */ + __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 189, __pyx_L1_error) + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":190 + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") + */ + __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); + + /* "View.MemoryView":189 + * if self.mode == u"c": + * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * elif self.mode == u"fortran": # <<<<<<<<<<<<<< + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + */ + } + __pyx_L3:; + + /* "View.MemoryView":191 + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): # <<<<<<<<<<<<<< + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + */ + __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0); + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":192 + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< + * info.buf = self.data + * info.len = self.len + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 192, __pyx_L1_error) + + /* "View.MemoryView":191 + * elif self.mode == u"fortran": + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): # <<<<<<<<<<<<<< + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + */ + } + + /* "View.MemoryView":193 + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data # <<<<<<<<<<<<<< + * info.len = self.len + * info.ndim = self.ndim + */ + __pyx_t_4 = __pyx_v_self->data; + __pyx_v_info->buf = __pyx_t_4; + + /* "View.MemoryView":194 + * raise ValueError("Can only create a buffer that is contiguous in memory.") + * info.buf = self.data + * info.len = self.len # <<<<<<<<<<<<<< + * info.ndim = self.ndim + * info.shape = self._shape + */ + __pyx_t_5 = __pyx_v_self->len; + __pyx_v_info->len = __pyx_t_5; + + /* "View.MemoryView":195 + * info.buf = self.data + * info.len = self.len + * info.ndim = self.ndim # <<<<<<<<<<<<<< + * info.shape = self._shape + * info.strides = self._strides + */ + __pyx_t_6 = __pyx_v_self->ndim; + __pyx_v_info->ndim = __pyx_t_6; + + /* "View.MemoryView":196 + * info.len = self.len + * info.ndim = self.ndim + * info.shape = self._shape # <<<<<<<<<<<<<< + * info.strides = self._strides + * info.suboffsets = NULL + */ + __pyx_t_7 = __pyx_v_self->_shape; + __pyx_v_info->shape = __pyx_t_7; + + /* "View.MemoryView":197 + * info.ndim = self.ndim + * info.shape = self._shape + * info.strides = self._strides # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = self.itemsize + */ + __pyx_t_7 = __pyx_v_self->_strides; + __pyx_v_info->strides = __pyx_t_7; + + /* "View.MemoryView":198 + * info.shape = self._shape + * info.strides = self._strides + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = self.itemsize + * info.readonly = 0 + */ + __pyx_v_info->suboffsets = NULL; + + /* "View.MemoryView":199 + * info.strides = self._strides + * info.suboffsets = NULL + * info.itemsize = self.itemsize # <<<<<<<<<<<<<< + * info.readonly = 0 + * + */ + __pyx_t_5 = __pyx_v_self->itemsize; + __pyx_v_info->itemsize = __pyx_t_5; + + /* "View.MemoryView":200 + * info.suboffsets = NULL + * info.itemsize = self.itemsize + * info.readonly = 0 # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + __pyx_v_info->readonly = 0; + + /* "View.MemoryView":202 + * info.readonly = 0 + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.format + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":203 + * + * if flags & PyBUF_FORMAT: + * info.format = self.format # <<<<<<<<<<<<<< + * else: + * info.format = NULL + */ + __pyx_t_4 = __pyx_v_self->format; + __pyx_v_info->format = __pyx_t_4; + + /* "View.MemoryView":202 + * info.readonly = 0 + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.format + * else: + */ + goto __pyx_L5; + } + + /* "View.MemoryView":205 + * info.format = self.format + * else: + * info.format = NULL # <<<<<<<<<<<<<< + * + * info.obj = self + */ + /*else*/ { + __pyx_v_info->format = NULL; + } + __pyx_L5:; + + /* "View.MemoryView":207 + * info.format = NULL + * + * info.obj = self # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "View.MemoryView":185 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * cdef int bufmode = -1 + * if self.mode == u"c": + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":211 + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + * + * def __dealloc__(array self): # <<<<<<<<<<<<<< + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + */ + +/* Python wrapper */ +static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_array___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":212 + * + * def __dealloc__(array self): + * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< + * self.callback_free_data(self.data) + * elif self.free_data: + */ + __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":213 + * def __dealloc__(array self): + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) # <<<<<<<<<<<<<< + * elif self.free_data: + * if self.dtype_is_object: + */ + __pyx_v_self->callback_free_data(__pyx_v_self->data); + + /* "View.MemoryView":212 + * + * def __dealloc__(array self): + * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< + * self.callback_free_data(self.data) + * elif self.free_data: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":214 + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + * elif self.free_data: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, + */ + __pyx_t_1 = (__pyx_v_self->free_data != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":215 + * self.callback_free_data(self.data) + * elif self.free_data: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + */ + __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":216 + * elif self.free_data: + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<< + * self._strides, self.ndim, False) + * free(self.data) + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0); + + /* "View.MemoryView":215 + * self.callback_free_data(self.data) + * elif self.free_data: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + */ + } + + /* "View.MemoryView":218 + * refcount_objects_in_slice(self.data, self._shape, + * self._strides, self.ndim, False) + * free(self.data) # <<<<<<<<<<<<<< + * PyObject_Free(self._shape) + * + */ + free(__pyx_v_self->data); + + /* "View.MemoryView":214 + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + * elif self.free_data: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * refcount_objects_in_slice(self.data, self._shape, + */ + } + __pyx_L3:; + + /* "View.MemoryView":219 + * self._strides, self.ndim, False) + * free(self.data) + * PyObject_Free(self._shape) # <<<<<<<<<<<<<< + * + * @property + */ + PyObject_Free(__pyx_v_self->_shape); + + /* "View.MemoryView":211 + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") + * + * def __dealloc__(array self): # <<<<<<<<<<<<<< + * if self.callback_free_data != NULL: + * self.callback_free_data(self.data) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":222 + * + * @property + * def memview(self): # <<<<<<<<<<<<<< + * return self.get_memview() + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":223 + * @property + * def memview(self): + * return self.get_memview() # <<<<<<<<<<<<<< + * + * @cname('get_memview') + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":222 + * + * @property + * def memview(self): # <<<<<<<<<<<<<< + * return self.get_memview() + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":226 + * + * @cname('get_memview') + * cdef get_memview(self): # <<<<<<<<<<<<<< + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) + */ + +static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) { + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_memview", 0); + + /* "View.MemoryView":227 + * @cname('get_memview') + * cdef get_memview(self): + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<< + * return memoryview(self, flags, self.dtype_is_object) + * + */ + __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE); + + /* "View.MemoryView":228 + * cdef get_memview(self): + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<< + * + * def __len__(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":226 + * + * @cname('get_memview') + * cdef get_memview(self): # <<<<<<<<<<<<<< + * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE + * return memoryview(self, flags, self.dtype_is_object) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":230 + * return memoryview(self, flags, self.dtype_is_object) + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self._shape[0] + * + */ + +/* Python wrapper */ +static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__", 0); + + /* "View.MemoryView":231 + * + * def __len__(self): + * return self._shape[0] # <<<<<<<<<<<<<< + * + * def __getattr__(self, attr): + */ + __pyx_r = (__pyx_v_self->_shape[0]); + goto __pyx_L0; + + /* "View.MemoryView":230 + * return memoryview(self, flags, self.dtype_is_object) + * + * def __len__(self): # <<<<<<<<<<<<<< + * return self._shape[0] + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":233 + * return self._shape[0] + * + * def __getattr__(self, attr): # <<<<<<<<<<<<<< + * return getattr(self.memview, attr) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/ +static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getattr__", 0); + + /* "View.MemoryView":234 + * + * def __getattr__(self, attr): + * return getattr(self.memview, attr) # <<<<<<<<<<<<<< + * + * def __getitem__(self, item): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 234, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":233 + * return self._shape[0] + * + * def __getattr__(self, attr): # <<<<<<<<<<<<<< + * return getattr(self.memview, attr) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":236 + * return getattr(self.memview, attr) + * + * def __getitem__(self, item): # <<<<<<<<<<<<<< + * return self.memview[item] + * + */ + +/* Python wrapper */ +static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/ +static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "View.MemoryView":237 + * + * def __getitem__(self, item): + * return self.memview[item] # <<<<<<<<<<<<<< + * + * def __setitem__(self, item, value): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 237, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":236 + * return getattr(self.memview, attr) + * + * def __getitem__(self, item): # <<<<<<<<<<<<<< + * return self.memview[item] + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":239 + * return self.memview[item] + * + * def __setitem__(self, item, value): # <<<<<<<<<<<<<< + * self.memview[item] = value + * + */ + +/* Python wrapper */ +static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setitem__", 0); + + /* "View.MemoryView":240 + * + * def __setitem__(self, item, value): + * self.memview[item] = value # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 240, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(1, 240, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "View.MemoryView":239 + * return self.memview[item] + * + * def __setitem__(self, item, value): # <<<<<<<<<<<<<< + * self.memview[item] = value + * + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":244 + * + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result + */ + +static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { + struct __pyx_array_obj *__pyx_v_result = 0; + struct __pyx_array_obj *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("array_cwrapper", 0); + + /* "View.MemoryView":248 + * cdef array result + * + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + */ + __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":249 + * + * if buf == NULL: + * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), + */ + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_shape); + __Pyx_GIVEREF(__pyx_v_shape); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "View.MemoryView":248 + * cdef array result + * + * if buf == NULL: # <<<<<<<<<<<<<< + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":251 + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< + * allocate_buffer=False) + * result.data = buf + */ + /*else*/ { + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_shape); + __Pyx_GIVEREF(__pyx_v_shape); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_3 = 0; + + /* "View.MemoryView":252 + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), + * allocate_buffer=False) # <<<<<<<<<<<<<< + * result.data = buf + * + */ + __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(1, 252, __pyx_L1_error) + + /* "View.MemoryView":251 + * result = array(shape, itemsize, format, mode.decode('ASCII')) + * else: + * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< + * allocate_buffer=False) + * result.data = buf + */ + __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "View.MemoryView":253 + * result = array(shape, itemsize, format, mode.decode('ASCII'), + * allocate_buffer=False) + * result.data = buf # <<<<<<<<<<<<<< + * + * return result + */ + __pyx_v_result->data = __pyx_v_buf; + } + __pyx_L3:; + + /* "View.MemoryView":255 + * result.data = buf + * + * return result # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + /* "View.MemoryView":244 + * + * @cname("__pyx_array_new") + * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< + * char *mode, char *buf): + * cdef array result + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":281 + * cdef class Enum(object): + * cdef object name + * def __init__(self, name): # <<<<<<<<<<<<<< + * self.name = name + * def __repr__(self): + */ + +/* Python wrapper */ +static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_name = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 281, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + } + __pyx_v_name = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 281, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__", 0); + + /* "View.MemoryView":282 + * cdef object name + * def __init__(self, name): + * self.name = name # <<<<<<<<<<<<<< + * def __repr__(self): + * return self.name + */ + __Pyx_INCREF(__pyx_v_name); + __Pyx_GIVEREF(__pyx_v_name); + __Pyx_GOTREF(__pyx_v_self->name); + __Pyx_DECREF(__pyx_v_self->name); + __pyx_v_self->name = __pyx_v_name; + + /* "View.MemoryView":281 + * cdef class Enum(object): + * cdef object name + * def __init__(self, name): # <<<<<<<<<<<<<< + * self.name = name + * def __repr__(self): + */ + + /* function exit code */ + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":283 + * def __init__(self, name): + * self.name = name + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.name + * + */ + +/* Python wrapper */ +static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "View.MemoryView":284 + * self.name = name + * def __repr__(self): + * return self.name # <<<<<<<<<<<<<< + * + * cdef generic = Enum("") + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->name); + __pyx_r = __pyx_v_self->name; + goto __pyx_L0; + + /* "View.MemoryView":283 + * def __init__(self, name): + * self.name = name + * def __repr__(self): # <<<<<<<<<<<<<< + * return self.name + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * cdef tuple state + * cdef object _dict + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { + PyObject *__pyx_v_state = 0; + PyObject *__pyx_v__dict = 0; + int __pyx_v_use_setstate; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":5 + * cdef object _dict + * cdef bint use_setstate + * state = (self.name,) # <<<<<<<<<<<<<< + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_self->name); + __Pyx_GIVEREF(__pyx_v_self->name); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name); + __pyx_v_state = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "(tree fragment)":6 + * cdef bint use_setstate + * state = (self.name,) + * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< + * if _dict is not None: + * state += (_dict,) + */ + __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v__dict = __pyx_t_1; + __pyx_t_1 = 0; + + /* "(tree fragment)":7 + * state = (self.name,) + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: # <<<<<<<<<<<<<< + * state += (_dict,) + * use_setstate = True + */ + __pyx_t_2 = (__pyx_v__dict != Py_None); + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "(tree fragment)":8 + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: + * state += (_dict,) # <<<<<<<<<<<<<< + * use_setstate = True + * else: + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v__dict); + __Pyx_GIVEREF(__pyx_v__dict); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict); + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4)); + __pyx_t_4 = 0; + + /* "(tree fragment)":9 + * if _dict is not None: + * state += (_dict,) + * use_setstate = True # <<<<<<<<<<<<<< + * else: + * use_setstate = self.name is not None + */ + __pyx_v_use_setstate = 1; + + /* "(tree fragment)":7 + * state = (self.name,) + * _dict = getattr(self, '__dict__', None) + * if _dict is not None: # <<<<<<<<<<<<<< + * state += (_dict,) + * use_setstate = True + */ + goto __pyx_L3; + } + + /* "(tree fragment)":11 + * use_setstate = True + * else: + * use_setstate = self.name is not None # <<<<<<<<<<<<<< + * if use_setstate: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + */ + /*else*/ { + __pyx_t_3 = (__pyx_v_self->name != Py_None); + __pyx_v_use_setstate = __pyx_t_3; + } + __pyx_L3:; + + /* "(tree fragment)":12 + * else: + * use_setstate = self.name is not None + * if use_setstate: # <<<<<<<<<<<<<< + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + * else: + */ + __pyx_t_3 = (__pyx_v_use_setstate != 0); + if (__pyx_t_3) { + + /* "(tree fragment)":13 + * use_setstate = self.name is not None + * if use_setstate: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state # <<<<<<<<<<<<<< + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_INCREF(__pyx_int_184977713); + __Pyx_GIVEREF(__pyx_int_184977713); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None); + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); + __Pyx_INCREF(__pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state); + __pyx_t_4 = 0; + __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "(tree fragment)":12 + * else: + * use_setstate = self.name is not None + * if use_setstate: # <<<<<<<<<<<<<< + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + * else: + */ + } + + /* "(tree fragment)":15 + * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * __pyx_unpickle_Enum__set_state(self, __pyx_state) + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); + __Pyx_INCREF(__pyx_int_184977713); + __Pyx_GIVEREF(__pyx_int_184977713); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713); + __Pyx_INCREF(__pyx_v_state); + __Pyx_GIVEREF(__pyx_v_state); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); + __pyx_t_5 = 0; + __pyx_t_1 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + } + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * cdef tuple state + * cdef object _dict + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_state); + __Pyx_XDECREF(__pyx_v__dict); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":16 + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state(self, __pyx_state) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":17 + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + * def __setstate_cython__(self, __pyx_state): + * __pyx_unpickle_Enum__set_state(self, __pyx_state) # <<<<<<<<<<<<<< + */ + if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error) + __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "(tree fragment)":16 + * else: + * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state(self, __pyx_state) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":298 + * + * @cname('__pyx_align_pointer') + * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory + */ + +static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) { + Py_intptr_t __pyx_v_aligned_p; + size_t __pyx_v_offset; + void *__pyx_r; + int __pyx_t_1; + + /* "View.MemoryView":300 + * cdef void *align_pointer(void *memory, size_t alignment) nogil: + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory # <<<<<<<<<<<<<< + * cdef size_t offset + * + */ + __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory); + + /* "View.MemoryView":304 + * + * with cython.cdivision(True): + * offset = aligned_p % alignment # <<<<<<<<<<<<<< + * + * if offset > 0: + */ + __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment); + + /* "View.MemoryView":306 + * offset = aligned_p % alignment + * + * if offset > 0: # <<<<<<<<<<<<<< + * aligned_p += alignment - offset + * + */ + __pyx_t_1 = ((__pyx_v_offset > 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":307 + * + * if offset > 0: + * aligned_p += alignment - offset # <<<<<<<<<<<<<< + * + * return aligned_p + */ + __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset)); + + /* "View.MemoryView":306 + * offset = aligned_p % alignment + * + * if offset > 0: # <<<<<<<<<<<<<< + * aligned_p += alignment - offset + * + */ + } + + /* "View.MemoryView":309 + * aligned_p += alignment - offset + * + * return aligned_p # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = ((void *)__pyx_v_aligned_p); + goto __pyx_L0; + + /* "View.MemoryView":298 + * + * @cname('__pyx_align_pointer') + * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< + * "Align pointer memory on a given boundary" + * cdef Py_intptr_t aligned_p = memory + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":345 + * cdef __Pyx_TypeInfo *typeinfo + * + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< + * self.obj = obj + * self.flags = flags + */ + +/* Python wrapper */ +static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_obj = 0; + int __pyx_v_flags; + int __pyx_v_dtype_is_object; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(1, 345, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (kw_args > 0) { + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 345, __pyx_L3_error) + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_obj = values[0]; + __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error) + if (values[2]) { + __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error) + } else { + __pyx_v_dtype_is_object = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 345, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "View.MemoryView":346 + * + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + * self.obj = obj # <<<<<<<<<<<<<< + * self.flags = flags + * if type(self) is memoryview or obj is not None: + */ + __Pyx_INCREF(__pyx_v_obj); + __Pyx_GIVEREF(__pyx_v_obj); + __Pyx_GOTREF(__pyx_v_self->obj); + __Pyx_DECREF(__pyx_v_self->obj); + __pyx_v_self->obj = __pyx_v_obj; + + /* "View.MemoryView":347 + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): + * self.obj = obj + * self.flags = flags # <<<<<<<<<<<<<< + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + */ + __pyx_v_self->flags = __pyx_v_flags; + + /* "View.MemoryView":348 + * self.obj = obj + * self.flags = flags + * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + */ + __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type)); + __pyx_t_3 = (__pyx_t_2 != 0); + if (!__pyx_t_3) { + } else { + __pyx_t_1 = __pyx_t_3; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_3 = (__pyx_v_obj != Py_None); + __pyx_t_2 = (__pyx_t_3 != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (__pyx_t_1) { + + /* "View.MemoryView":349 + * self.flags = flags + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<< + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None + */ + __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 349, __pyx_L1_error) + + /* "View.MemoryView":350 + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) + */ + __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":351 + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * + */ + ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None; + + /* "View.MemoryView":352 + * if self.view.obj == NULL: + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * global __pyx_memoryview_thread_locks_used + */ + Py_INCREF(Py_None); + + /* "View.MemoryView":350 + * if type(self) is memoryview or obj is not None: + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &self.view).obj = Py_None + * Py_INCREF(Py_None) + */ + } + + /* "View.MemoryView":348 + * self.obj = obj + * self.flags = flags + * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< + * __Pyx_GetBuffer(obj, &self.view, flags) + * if self.view.obj == NULL: + */ + } + + /* "View.MemoryView":355 + * + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + */ + __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":356 + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: + */ + __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); + + /* "View.MemoryView":357 + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<< + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + */ + __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1); + + /* "View.MemoryView":355 + * + * global __pyx_memoryview_thread_locks_used + * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + */ + } + + /* "View.MemoryView":358 + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: # <<<<<<<<<<<<<< + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + */ + __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":359 + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<< + * if self.lock is NULL: + * raise MemoryError + */ + __pyx_v_self->lock = PyThread_allocate_lock(); + + /* "View.MemoryView":360 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * + */ + __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":361 + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + PyErr_NoMemory(); __PYX_ERR(1, 361, __pyx_L1_error) + + /* "View.MemoryView":360 + * if self.lock is NULL: + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * + */ + } + + /* "View.MemoryView":358 + * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] + * __pyx_memoryview_thread_locks_used += 1 + * if self.lock is NULL: # <<<<<<<<<<<<<< + * self.lock = PyThread_allocate_lock() + * if self.lock is NULL: + */ + } + + /* "View.MemoryView":363 + * raise MemoryError + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":364 + * + * if flags & PyBUF_FORMAT: + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<< + * else: + * self.dtype_is_object = dtype_is_object + */ + __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L11_bool_binop_done:; + __pyx_v_self->dtype_is_object = __pyx_t_1; + + /* "View.MemoryView":363 + * raise MemoryError + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + */ + goto __pyx_L10; + } + + /* "View.MemoryView":366 + * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') + * else: + * self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<< + * + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( + */ + /*else*/ { + __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object; + } + __pyx_L10:; + + /* "View.MemoryView":368 + * self.dtype_is_object = dtype_is_object + * + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<< + * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + * self.typeinfo = NULL + */ + __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int)))); + + /* "View.MemoryView":370 + * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( + * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) + * self.typeinfo = NULL # <<<<<<<<<<<<<< + * + * def __dealloc__(memoryview self): + */ + __pyx_v_self->typeinfo = NULL; + + /* "View.MemoryView":345 + * cdef __Pyx_TypeInfo *typeinfo + * + * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< + * self.obj = obj + * self.flags = flags + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":372 + * self.typeinfo = NULL + * + * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + */ + +/* Python wrapper */ +static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { + int __pyx_v_i; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + PyThread_type_lock __pyx_t_6; + PyThread_type_lock __pyx_t_7; + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":373 + * + * def __dealloc__(memoryview self): + * if self.obj is not None: # <<<<<<<<<<<<<< + * __Pyx_ReleaseBuffer(&self.view) + * elif (<__pyx_buffer *> &self.view).obj == Py_None: + */ + __pyx_t_1 = (__pyx_v_self->obj != Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":374 + * def __dealloc__(memoryview self): + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<< + * elif (<__pyx_buffer *> &self.view).obj == Py_None: + * + */ + __Pyx_ReleaseBuffer((&__pyx_v_self->view)); + + /* "View.MemoryView":373 + * + * def __dealloc__(memoryview self): + * if self.obj is not None: # <<<<<<<<<<<<<< + * __Pyx_ReleaseBuffer(&self.view) + * elif (<__pyx_buffer *> &self.view).obj == Py_None: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":375 + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + * elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<< + * + * (<__pyx_buffer *> &self.view).obj = NULL + */ + __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":377 + * elif (<__pyx_buffer *> &self.view).obj == Py_None: + * + * (<__pyx_buffer *> &self.view).obj = NULL # <<<<<<<<<<<<<< + * Py_DECREF(Py_None) + * + */ + ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL; + + /* "View.MemoryView":378 + * + * (<__pyx_buffer *> &self.view).obj = NULL + * Py_DECREF(Py_None) # <<<<<<<<<<<<<< + * + * cdef int i + */ + Py_DECREF(Py_None); + + /* "View.MemoryView":375 + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + * elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<< + * + * (<__pyx_buffer *> &self.view).obj = NULL + */ + } + __pyx_L3:; + + /* "View.MemoryView":382 + * cdef int i + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: # <<<<<<<<<<<<<< + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + */ + __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":383 + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<< + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + */ + __pyx_t_3 = __pyx_memoryview_thread_locks_used; + __pyx_t_4 = __pyx_t_3; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "View.MemoryView":384 + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + */ + __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":385 + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<< + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + */ + __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1); + + /* "View.MemoryView":386 + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + */ + __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":388 + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<< + * break + * else: + */ + __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); + __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]); + + /* "View.MemoryView":387 + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + * break + */ + (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6; + (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7; + + /* "View.MemoryView":386 + * if __pyx_memoryview_thread_locks[i] is self.lock: + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + */ + } + + /* "View.MemoryView":389 + * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( + * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) + * break # <<<<<<<<<<<<<< + * else: + * PyThread_free_lock(self.lock) + */ + goto __pyx_L6_break; + + /* "View.MemoryView":384 + * if self.lock != NULL: + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< + * __pyx_memoryview_thread_locks_used -= 1 + * if i != __pyx_memoryview_thread_locks_used: + */ + } + } + /*else*/ { + + /* "View.MemoryView":391 + * break + * else: + * PyThread_free_lock(self.lock) # <<<<<<<<<<<<<< + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: + */ + PyThread_free_lock(__pyx_v_self->lock); + } + __pyx_L6_break:; + + /* "View.MemoryView":382 + * cdef int i + * global __pyx_memoryview_thread_locks_used + * if self.lock != NULL: # <<<<<<<<<<<<<< + * for i in range(__pyx_memoryview_thread_locks_used): + * if __pyx_memoryview_thread_locks[i] is self.lock: + */ + } + + /* "View.MemoryView":372 + * self.typeinfo = NULL + * + * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< + * if self.obj is not None: + * __Pyx_ReleaseBuffer(&self.view) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":393 + * PyThread_free_lock(self.lock) + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf + */ + +static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { + Py_ssize_t __pyx_v_dim; + char *__pyx_v_itemp; + PyObject *__pyx_v_idx = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + char *__pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_item_pointer", 0); + + /* "View.MemoryView":395 + * cdef char *get_item_pointer(memoryview self, object index) except NULL: + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf # <<<<<<<<<<<<<< + * + * for dim, idx in enumerate(index): + */ + __pyx_v_itemp = ((char *)__pyx_v_self->view.buf); + + /* "View.MemoryView":397 + * cdef char *itemp = self.view.buf + * + * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + */ + __pyx_t_1 = 0; + if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) { + __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 397, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 397, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_4)) { + if (likely(PyList_CheckExact(__pyx_t_2))) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } else { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error) + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + } + } else { + __pyx_t_5 = __pyx_t_4(__pyx_t_2); + if (unlikely(!__pyx_t_5)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 397, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5); + __pyx_t_5 = 0; + __pyx_v_dim = __pyx_t_1; + __pyx_t_1 = (__pyx_t_1 + 1); + + /* "View.MemoryView":398 + * + * for dim, idx in enumerate(index): + * itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<< + * + * return itemp + */ + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 398, __pyx_L1_error) + __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(1, 398, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_7; + + /* "View.MemoryView":397 + * cdef char *itemp = self.view.buf + * + * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + */ + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":400 + * itemp = pybuffer_index(&self.view, itemp, idx, dim) + * + * return itemp # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_itemp; + goto __pyx_L0; + + /* "View.MemoryView":393 + * PyThread_free_lock(self.lock) + * + * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< + * cdef Py_ssize_t dim + * cdef char *itemp = self.view.buf + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_idx); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":403 + * + * + * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< + * if index is Ellipsis: + * return self + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ +static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { + PyObject *__pyx_v_have_slices = NULL; + PyObject *__pyx_v_indices = NULL; + char *__pyx_v_itemp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + char *__pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getitem__", 0); + + /* "View.MemoryView":404 + * + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: # <<<<<<<<<<<<<< + * return self + * + */ + __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":405 + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: + * return self # <<<<<<<<<<<<<< + * + * have_slices, indices = _unellipsify(index, self.view.ndim) + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + /* "View.MemoryView":404 + * + * def __getitem__(memoryview self, object index): + * if index is Ellipsis: # <<<<<<<<<<<<<< + * return self + * + */ + } + + /* "View.MemoryView":407 + * return self + * + * have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< + * + * cdef char *itemp + */ + __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 407, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (likely(__pyx_t_3 != Py_None)) { + PyObject* sequence = __pyx_t_3; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 407, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + #else + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 407, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 407, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 407, __pyx_L1_error) + } + __pyx_v_have_slices = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_v_indices = __pyx_t_5; + __pyx_t_5 = 0; + + /* "View.MemoryView":410 + * + * cdef char *itemp + * if have_slices: # <<<<<<<<<<<<<< + * return memview_slice(self, indices) + * else: + */ + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 410, __pyx_L1_error) + if (__pyx_t_2) { + + /* "View.MemoryView":411 + * cdef char *itemp + * if have_slices: + * return memview_slice(self, indices) # <<<<<<<<<<<<<< + * else: + * itemp = self.get_item_pointer(indices) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 411, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":410 + * + * cdef char *itemp + * if have_slices: # <<<<<<<<<<<<<< + * return memview_slice(self, indices) + * else: + */ + } + + /* "View.MemoryView":413 + * return memview_slice(self, indices) + * else: + * itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<< + * return self.convert_item_to_object(itemp) + * + */ + /*else*/ { + __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == ((char *)NULL))) __PYX_ERR(1, 413, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_6; + + /* "View.MemoryView":414 + * else: + * itemp = self.get_item_pointer(indices) + * return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<< + * + * def __setitem__(memoryview self, object index, object value): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 414, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":403 + * + * + * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< + * if index is Ellipsis: + * return self + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_have_slices); + __Pyx_XDECREF(__pyx_v_indices); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":416 + * return self.convert_item_to_object(itemp) + * + * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< + * if self.view.readonly: + * raise TypeError("Cannot assign to read-only memoryview") + */ + +/* Python wrapper */ +static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + PyObject *__pyx_v_have_slices = NULL; + PyObject *__pyx_v_obj = NULL; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setitem__", 0); + __Pyx_INCREF(__pyx_v_index); + + /* "View.MemoryView":417 + * + * def __setitem__(memoryview self, object index, object value): + * if self.view.readonly: # <<<<<<<<<<<<<< + * raise TypeError("Cannot assign to read-only memoryview") + * + */ + __pyx_t_1 = (__pyx_v_self->view.readonly != 0); + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":418 + * def __setitem__(memoryview self, object index, object value): + * if self.view.readonly: + * raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<< + * + * have_slices, index = _unellipsify(index, self.view.ndim) + */ + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 418, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 418, __pyx_L1_error) + + /* "View.MemoryView":417 + * + * def __setitem__(memoryview self, object index, object value): + * if self.view.readonly: # <<<<<<<<<<<<<< + * raise TypeError("Cannot assign to read-only memoryview") + * + */ + } + + /* "View.MemoryView":420 + * raise TypeError("Cannot assign to read-only memoryview") + * + * have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< + * + * if have_slices: + */ + __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (likely(__pyx_t_2 != Py_None)) { + PyObject* sequence = __pyx_t_2; + Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + __PYX_ERR(1, 420, __pyx_L1_error) + } + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 420, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + #endif + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 420, __pyx_L1_error) + } + __pyx_v_have_slices = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4); + __pyx_t_4 = 0; + + /* "View.MemoryView":422 + * have_slices, index = _unellipsify(index, self.view.ndim) + * + * if have_slices: # <<<<<<<<<<<<<< + * obj = self.is_slice(value) + * if obj: + */ + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 422, __pyx_L1_error) + if (__pyx_t_1) { + + /* "View.MemoryView":423 + * + * if have_slices: + * obj = self.is_slice(value) # <<<<<<<<<<<<<< + * if obj: + * self.setitem_slice_assignment(self[index], obj) + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 423, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_obj = __pyx_t_2; + __pyx_t_2 = 0; + + /* "View.MemoryView":424 + * if have_slices: + * obj = self.is_slice(value) + * if obj: # <<<<<<<<<<<<<< + * self.setitem_slice_assignment(self[index], obj) + * else: + */ + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 424, __pyx_L1_error) + if (__pyx_t_1) { + + /* "View.MemoryView":425 + * obj = self.is_slice(value) + * if obj: + * self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<< + * else: + * self.setitem_slice_assign_scalar(self[index], value) + */ + __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 425, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 425, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "View.MemoryView":424 + * if have_slices: + * obj = self.is_slice(value) + * if obj: # <<<<<<<<<<<<<< + * self.setitem_slice_assignment(self[index], obj) + * else: + */ + goto __pyx_L5; + } + + /* "View.MemoryView":427 + * self.setitem_slice_assignment(self[index], obj) + * else: + * self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<< + * else: + * self.setitem_indexed(index, value) + */ + /*else*/ { + __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(1, 427, __pyx_L1_error) + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_4), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 427, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __pyx_L5:; + + /* "View.MemoryView":422 + * have_slices, index = _unellipsify(index, self.view.ndim) + * + * if have_slices: # <<<<<<<<<<<<<< + * obj = self.is_slice(value) + * if obj: + */ + goto __pyx_L4; + } + + /* "View.MemoryView":429 + * self.setitem_slice_assign_scalar(self[index], value) + * else: + * self.setitem_indexed(index, value) # <<<<<<<<<<<<<< + * + * cdef is_slice(self, obj): + */ + /*else*/ { + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 429, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __pyx_L4:; + + /* "View.MemoryView":416 + * return self.convert_item_to_object(itemp) + * + * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< + * if self.view.readonly: + * raise TypeError("Cannot assign to read-only memoryview") + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_have_slices); + __Pyx_XDECREF(__pyx_v_obj); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":431 + * self.setitem_indexed(index, value) + * + * cdef is_slice(self, obj): # <<<<<<<<<<<<<< + * if not isinstance(obj, memoryview): + * try: + */ + +static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_slice", 0); + __Pyx_INCREF(__pyx_v_obj); + + /* "View.MemoryView":432 + * + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< + * try: + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + */ + __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":433 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_5); + /*try:*/ { + + /* "View.MemoryView":434 + * if not isinstance(obj, memoryview): + * try: + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< + * self.dtype_is_object) + * except TypeError: + */ + __pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 434, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_6); + + /* "View.MemoryView":435 + * try: + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) # <<<<<<<<<<<<<< + * except TypeError: + * return None + */ + __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 435, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_7); + + /* "View.MemoryView":434 + * if not isinstance(obj, memoryview): + * try: + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< + * self.dtype_is_object) + * except TypeError: + */ + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 434, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_obj); + __Pyx_GIVEREF(__pyx_v_obj); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); + __pyx_t_6 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 434, __pyx_L4_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7); + __pyx_t_7 = 0; + + /* "View.MemoryView":433 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + } + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L9_try_end; + __pyx_L4_error:; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "View.MemoryView":436 + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + * except TypeError: # <<<<<<<<<<<<<< + * return None + * + */ + __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); + if (__pyx_t_9) { + __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(1, 436, __pyx_L6_except_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GOTREF(__pyx_t_6); + + /* "View.MemoryView":437 + * self.dtype_is_object) + * except TypeError: + * return None # <<<<<<<<<<<<<< + * + * return obj + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + goto __pyx_L7_except_return; + } + goto __pyx_L6_except_error; + __pyx_L6_except_error:; + + /* "View.MemoryView":433 + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): + * try: # <<<<<<<<<<<<<< + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + * self.dtype_is_object) + */ + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); + goto __pyx_L1_error; + __pyx_L7_except_return:; + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_XGIVEREF(__pyx_t_5); + __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); + goto __pyx_L0; + __pyx_L9_try_end:; + } + + /* "View.MemoryView":432 + * + * cdef is_slice(self, obj): + * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< + * try: + * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, + */ + } + + /* "View.MemoryView":439 + * return None + * + * return obj # <<<<<<<<<<<<<< + * + * cdef setitem_slice_assignment(self, dst, src): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_obj); + __pyx_r = __pyx_v_obj; + goto __pyx_L0; + + /* "View.MemoryView":431 + * self.setitem_indexed(index, value) + * + * cdef is_slice(self, obj): # <<<<<<<<<<<<<< + * if not isinstance(obj, memoryview): + * try: + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_obj); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":441 + * return obj + * + * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice dst_slice + * cdef __Pyx_memviewslice src_slice + */ + +static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) { + __Pyx_memviewslice __pyx_v_dst_slice; + __Pyx_memviewslice __pyx_v_src_slice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice *__pyx_t_1; + __Pyx_memviewslice *__pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("setitem_slice_assignment", 0); + + /* "View.MemoryView":445 + * cdef __Pyx_memviewslice src_slice + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) + */ + if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(1, 445, __pyx_L1_error) + __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 445, __pyx_L1_error) + + /* "View.MemoryView":446 + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + * get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<< + * src.ndim, dst.ndim, self.dtype_is_object) + * + */ + if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(1, 446, __pyx_L1_error) + __pyx_t_2 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice)); if (unlikely(__pyx_t_2 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 446, __pyx_L1_error) + + /* "View.MemoryView":447 + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<< + * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): + */ + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":445 + * cdef __Pyx_memviewslice src_slice + * + * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< + * get_slice_from_memview(dst, &dst_slice)[0], + * src.ndim, dst.ndim, self.dtype_is_object) + */ + __pyx_t_6 = __pyx_memoryview_copy_contents((__pyx_t_1[0]), (__pyx_t_2[0]), __pyx_t_4, __pyx_t_5, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 445, __pyx_L1_error) + + /* "View.MemoryView":441 + * return obj + * + * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice dst_slice + * cdef __Pyx_memviewslice src_slice + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":449 + * src.ndim, dst.ndim, self.dtype_is_object) + * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< + * cdef int array[128] + * cdef void *tmp = NULL + */ + +static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) { + int __pyx_v_array[0x80]; + void *__pyx_v_tmp; + void *__pyx_v_item; + __Pyx_memviewslice *__pyx_v_dst_slice; + __Pyx_memviewslice __pyx_v_tmp_slice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice *__pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + char const *__pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0); + + /* "View.MemoryView":451 + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): + * cdef int array[128] + * cdef void *tmp = NULL # <<<<<<<<<<<<<< + * cdef void *item + * + */ + __pyx_v_tmp = NULL; + + /* "View.MemoryView":456 + * cdef __Pyx_memviewslice *dst_slice + * cdef __Pyx_memviewslice tmp_slice + * dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<< + * + * if self.view.itemsize > sizeof(array): + */ + __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 456, __pyx_L1_error) + __pyx_v_dst_slice = __pyx_t_1; + + /* "View.MemoryView":458 + * dst_slice = get_slice_from_memview(dst, &tmp_slice) + * + * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + */ + __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":459 + * + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<< + * if tmp == NULL: + * raise MemoryError + */ + __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize); + + /* "View.MemoryView":460 + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * item = tmp + */ + __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0); + if (unlikely(__pyx_t_2)) { + + /* "View.MemoryView":461 + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + * raise MemoryError # <<<<<<<<<<<<<< + * item = tmp + * else: + */ + PyErr_NoMemory(); __PYX_ERR(1, 461, __pyx_L1_error) + + /* "View.MemoryView":460 + * if self.view.itemsize > sizeof(array): + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: # <<<<<<<<<<<<<< + * raise MemoryError + * item = tmp + */ + } + + /* "View.MemoryView":462 + * if tmp == NULL: + * raise MemoryError + * item = tmp # <<<<<<<<<<<<<< + * else: + * item = array + */ + __pyx_v_item = __pyx_v_tmp; + + /* "View.MemoryView":458 + * dst_slice = get_slice_from_memview(dst, &tmp_slice) + * + * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< + * tmp = PyMem_Malloc(self.view.itemsize) + * if tmp == NULL: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":464 + * item = tmp + * else: + * item = array # <<<<<<<<<<<<<< + * + * try: + */ + /*else*/ { + __pyx_v_item = ((void *)__pyx_v_array); + } + __pyx_L3:; + + /* "View.MemoryView":466 + * item = array + * + * try: # <<<<<<<<<<<<<< + * if self.dtype_is_object: + * ( item)[0] = value + */ + /*try:*/ { + + /* "View.MemoryView":467 + * + * try: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * ( item)[0] = value + * else: + */ + __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":468 + * try: + * if self.dtype_is_object: + * ( item)[0] = value # <<<<<<<<<<<<<< + * else: + * self.assign_item_from_object( item, value) + */ + (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value); + + /* "View.MemoryView":467 + * + * try: + * if self.dtype_is_object: # <<<<<<<<<<<<<< + * ( item)[0] = value + * else: + */ + goto __pyx_L8; + } + + /* "View.MemoryView":470 + * ( item)[0] = value + * else: + * self.assign_item_from_object( item, value) # <<<<<<<<<<<<<< + * + * + */ + /*else*/ { + __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 470, __pyx_L6_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L8:; + + /* "View.MemoryView":474 + * + * + * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + */ + __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":475 + * + * if self.view.suboffsets != NULL: + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<< + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + * item, self.dtype_is_object) + */ + __pyx_t_3 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 475, __pyx_L6_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":474 + * + * + * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, + */ + } + + /* "View.MemoryView":476 + * if self.view.suboffsets != NULL: + * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) + * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<< + * item, self.dtype_is_object) + * finally: + */ + __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object); + } + + /* "View.MemoryView":479 + * item, self.dtype_is_object) + * finally: + * PyMem_Free(tmp) # <<<<<<<<<<<<<< + * + * cdef setitem_indexed(self, index, value): + */ + /*finally:*/ { + /*normal exit:*/{ + PyMem_Free(__pyx_v_tmp); + goto __pyx_L7; + } + __pyx_L6_error:; + /*exception exit:*/{ + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); + if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_7); + __Pyx_XGOTREF(__pyx_t_8); + __Pyx_XGOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_t_11); + __Pyx_XGOTREF(__pyx_t_12); + __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; + { + PyMem_Free(__pyx_v_tmp); + } + if (PY_MAJOR_VERSION >= 3) { + __Pyx_XGIVEREF(__pyx_t_10); + __Pyx_XGIVEREF(__pyx_t_11); + __Pyx_XGIVEREF(__pyx_t_12); + __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); + } + __Pyx_XGIVEREF(__pyx_t_7); + __Pyx_XGIVEREF(__pyx_t_8); + __Pyx_XGIVEREF(__pyx_t_9); + __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); + __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; + __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; + goto __pyx_L1_error; + } + __pyx_L7:; + } + + /* "View.MemoryView":449 + * src.ndim, dst.ndim, self.dtype_is_object) + * + * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< + * cdef int array[128] + * cdef void *tmp = NULL + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":481 + * PyMem_Free(tmp) + * + * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) + */ + +static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { + char *__pyx_v_itemp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + char *__pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("setitem_indexed", 0); + + /* "View.MemoryView":482 + * + * cdef setitem_indexed(self, index, value): + * cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<< + * self.assign_item_from_object(itemp, value) + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == ((char *)NULL))) __PYX_ERR(1, 482, __pyx_L1_error) + __pyx_v_itemp = __pyx_t_1; + + /* "View.MemoryView":483 + * cdef setitem_indexed(self, index, value): + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<< + * + * cdef convert_item_to_object(self, char *itemp): + */ + __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 483, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":481 + * PyMem_Free(tmp) + * + * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< + * cdef char *itemp = self.get_item_pointer(index) + * self.assign_item_from_object(itemp, value) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":485 + * self.assign_item_from_object(itemp, value) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + +static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) { + PyObject *__pyx_v_struct = NULL; + PyObject *__pyx_v_bytesitem = 0; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + size_t __pyx_t_10; + int __pyx_t_11; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("convert_item_to_object", 0); + + /* "View.MemoryView":488 + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + * import struct # <<<<<<<<<<<<<< + * cdef bytes bytesitem + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 488, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_struct = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":491 + * cdef bytes bytesitem + * + * bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<< + * try: + * result = struct.unpack(self.view.format, bytesitem) + */ + __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 491, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_bytesitem = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":492 + * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + */ + { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); + __Pyx_XGOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_t_4); + /*try:*/ { + + /* "View.MemoryView":493 + * bytesitem = itemp[:self.view.itemsize] + * try: + * result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<< + * except struct.error: + * raise ValueError("Unable to convert item to object") + */ + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 493, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 493, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = NULL; + __pyx_t_8 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_8 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error) + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + #endif + { + __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 493, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); + __Pyx_INCREF(__pyx_v_bytesitem); + __Pyx_GIVEREF(__pyx_v_bytesitem); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_result = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":492 + * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + */ + } + + /* "View.MemoryView":497 + * raise ValueError("Unable to convert item to object") + * else: + * if len(self.view.format) == 1: # <<<<<<<<<<<<<< + * return result[0] + * return result + */ + /*else:*/ { + __pyx_t_10 = strlen(__pyx_v_self->view.format); + __pyx_t_11 = ((__pyx_t_10 == 1) != 0); + if (__pyx_t_11) { + + /* "View.MemoryView":498 + * else: + * if len(self.view.format) == 1: + * return result[0] # <<<<<<<<<<<<<< + * return result + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L6_except_return; + + /* "View.MemoryView":497 + * raise ValueError("Unable to convert item to object") + * else: + * if len(self.view.format) == 1: # <<<<<<<<<<<<<< + * return result[0] + * return result + */ + } + + /* "View.MemoryView":499 + * if len(self.view.format) == 1: + * return result[0] + * return result # <<<<<<<<<<<<<< + * + * cdef assign_item_from_object(self, char *itemp, object value): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L6_except_return; + } + __pyx_L3_error:; + __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "View.MemoryView":494 + * try: + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: # <<<<<<<<<<<<<< + * raise ValueError("Unable to convert item to object") + * else: + */ + __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 494, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9); + __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0; + if (__pyx_t_8) { + __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(1, 494, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_1); + + /* "View.MemoryView":495 + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< + * else: + * if len(self.view.format) == 1: + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 495, __pyx_L5_except_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __PYX_ERR(1, 495, __pyx_L5_except_error) + } + goto __pyx_L5_except_error; + __pyx_L5_except_error:; + + /* "View.MemoryView":492 + * + * bytesitem = itemp[:self.view.itemsize] + * try: # <<<<<<<<<<<<<< + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + */ + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); + goto __pyx_L1_error; + __pyx_L6_except_return:; + __Pyx_XGIVEREF(__pyx_t_2); + __Pyx_XGIVEREF(__pyx_t_3); + __Pyx_XGIVEREF(__pyx_t_4); + __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); + goto __pyx_L0; + } + + /* "View.MemoryView":485 + * self.assign_item_from_object(itemp, value) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_struct); + __Pyx_XDECREF(__pyx_v_bytesitem); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":501 + * return result + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + +static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { + PyObject *__pyx_v_struct = NULL; + char __pyx_v_c; + PyObject *__pyx_v_bytesvalue = 0; + Py_ssize_t __pyx_v_i; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; + Py_ssize_t __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + char *__pyx_t_11; + char *__pyx_t_12; + char *__pyx_t_13; + char *__pyx_t_14; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("assign_item_from_object", 0); + + /* "View.MemoryView":504 + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + * import struct # <<<<<<<<<<<<<< + * cdef char c + * cdef bytes bytesvalue + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 504, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_struct = __pyx_t_1; + __pyx_t_1 = 0; + + /* "View.MemoryView":509 + * cdef Py_ssize_t i + * + * if isinstance(value, tuple): # <<<<<<<<<<<<<< + * bytesvalue = struct.pack(self.view.format, *value) + * else: + */ + __pyx_t_2 = PyTuple_Check(__pyx_v_value); + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "View.MemoryView":510 + * + * if isinstance(value, tuple): + * bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<< + * else: + * bytesvalue = struct.pack(self.view.format, value) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 510, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 510, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 510, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 510, __pyx_L1_error) + __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + /* "View.MemoryView":509 + * cdef Py_ssize_t i + * + * if isinstance(value, tuple): # <<<<<<<<<<<<<< + * bytesvalue = struct.pack(self.view.format, *value) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":512 + * bytesvalue = struct.pack(self.view.format, *value) + * else: + * bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<< + * + * for i, c in enumerate(bytesvalue): + */ + /*else*/ { + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 512, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + __pyx_t_7 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { + PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 512, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_5) { + __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); + __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 512, __pyx_L1_error) + __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + } + __pyx_L3:; + + /* "View.MemoryView":514 + * bytesvalue = struct.pack(self.view.format, value) + * + * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< + * itemp[i] = c + * + */ + __pyx_t_9 = 0; + if (unlikely(__pyx_v_bytesvalue == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); + __PYX_ERR(1, 514, __pyx_L1_error) + } + __Pyx_INCREF(__pyx_v_bytesvalue); + __pyx_t_10 = __pyx_v_bytesvalue; + __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10); + __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10)); + for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) { + __pyx_t_11 = __pyx_t_14; + __pyx_v_c = (__pyx_t_11[0]); + + /* "View.MemoryView":515 + * + * for i, c in enumerate(bytesvalue): + * itemp[i] = c # <<<<<<<<<<<<<< + * + * @cname('getbuffer') + */ + __pyx_v_i = __pyx_t_9; + + /* "View.MemoryView":514 + * bytesvalue = struct.pack(self.view.format, value) + * + * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< + * itemp[i] = c + * + */ + __pyx_t_9 = (__pyx_t_9 + 1); + + /* "View.MemoryView":515 + * + * for i, c in enumerate(bytesvalue): + * itemp[i] = c # <<<<<<<<<<<<<< + * + * @cname('getbuffer') + */ + (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "View.MemoryView":501 + * return result + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * """Only used if instantiated manually by the user, or if Cython doesn't + * know how to convert the type""" + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_struct); + __Pyx_XDECREF(__pyx_v_bytesvalue); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":518 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * if flags & PyBUF_WRITABLE and self.view.readonly: + * raise ValueError("Cannot create writable memory view from read-only memoryview") + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t *__pyx_t_4; + char *__pyx_t_5; + void *__pyx_t_6; + int __pyx_t_7; + Py_ssize_t __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + if (__pyx_v_info == NULL) { + PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); + return -1; + } + __Pyx_RefNannySetupContext("__getbuffer__", 0); + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + + /* "View.MemoryView":519 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<< + * raise ValueError("Cannot create writable memory view from read-only memoryview") + * + */ + __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_2 = (__pyx_v_self->view.readonly != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L4_bool_binop_done:; + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":520 + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_WRITABLE and self.view.readonly: + * raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<< + * + * if flags & PyBUF_ND: + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 520, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 520, __pyx_L1_error) + + /* "View.MemoryView":519 + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<< + * raise ValueError("Cannot create writable memory view from read-only memoryview") + * + */ + } + + /* "View.MemoryView":522 + * raise ValueError("Cannot create writable memory view from read-only memoryview") + * + * if flags & PyBUF_ND: # <<<<<<<<<<<<<< + * info.shape = self.view.shape + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":523 + * + * if flags & PyBUF_ND: + * info.shape = self.view.shape # <<<<<<<<<<<<<< + * else: + * info.shape = NULL + */ + __pyx_t_4 = __pyx_v_self->view.shape; + __pyx_v_info->shape = __pyx_t_4; + + /* "View.MemoryView":522 + * raise ValueError("Cannot create writable memory view from read-only memoryview") + * + * if flags & PyBUF_ND: # <<<<<<<<<<<<<< + * info.shape = self.view.shape + * else: + */ + goto __pyx_L6; + } + + /* "View.MemoryView":525 + * info.shape = self.view.shape + * else: + * info.shape = NULL # <<<<<<<<<<<<<< + * + * if flags & PyBUF_STRIDES: + */ + /*else*/ { + __pyx_v_info->shape = NULL; + } + __pyx_L6:; + + /* "View.MemoryView":527 + * info.shape = NULL + * + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.strides = self.view.strides + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":528 + * + * if flags & PyBUF_STRIDES: + * info.strides = self.view.strides # <<<<<<<<<<<<<< + * else: + * info.strides = NULL + */ + __pyx_t_4 = __pyx_v_self->view.strides; + __pyx_v_info->strides = __pyx_t_4; + + /* "View.MemoryView":527 + * info.shape = NULL + * + * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< + * info.strides = self.view.strides + * else: + */ + goto __pyx_L7; + } + + /* "View.MemoryView":530 + * info.strides = self.view.strides + * else: + * info.strides = NULL # <<<<<<<<<<<<<< + * + * if flags & PyBUF_INDIRECT: + */ + /*else*/ { + __pyx_v_info->strides = NULL; + } + __pyx_L7:; + + /* "View.MemoryView":532 + * info.strides = NULL + * + * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< + * info.suboffsets = self.view.suboffsets + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":533 + * + * if flags & PyBUF_INDIRECT: + * info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<< + * else: + * info.suboffsets = NULL + */ + __pyx_t_4 = __pyx_v_self->view.suboffsets; + __pyx_v_info->suboffsets = __pyx_t_4; + + /* "View.MemoryView":532 + * info.strides = NULL + * + * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< + * info.suboffsets = self.view.suboffsets + * else: + */ + goto __pyx_L8; + } + + /* "View.MemoryView":535 + * info.suboffsets = self.view.suboffsets + * else: + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * + * if flags & PyBUF_FORMAT: + */ + /*else*/ { + __pyx_v_info->suboffsets = NULL; + } + __pyx_L8:; + + /* "View.MemoryView":537 + * info.suboffsets = NULL + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.view.format + * else: + */ + __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":538 + * + * if flags & PyBUF_FORMAT: + * info.format = self.view.format # <<<<<<<<<<<<<< + * else: + * info.format = NULL + */ + __pyx_t_5 = __pyx_v_self->view.format; + __pyx_v_info->format = __pyx_t_5; + + /* "View.MemoryView":537 + * info.suboffsets = NULL + * + * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< + * info.format = self.view.format + * else: + */ + goto __pyx_L9; + } + + /* "View.MemoryView":540 + * info.format = self.view.format + * else: + * info.format = NULL # <<<<<<<<<<<<<< + * + * info.buf = self.view.buf + */ + /*else*/ { + __pyx_v_info->format = NULL; + } + __pyx_L9:; + + /* "View.MemoryView":542 + * info.format = NULL + * + * info.buf = self.view.buf # <<<<<<<<<<<<<< + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize + */ + __pyx_t_6 = __pyx_v_self->view.buf; + __pyx_v_info->buf = __pyx_t_6; + + /* "View.MemoryView":543 + * + * info.buf = self.view.buf + * info.ndim = self.view.ndim # <<<<<<<<<<<<<< + * info.itemsize = self.view.itemsize + * info.len = self.view.len + */ + __pyx_t_7 = __pyx_v_self->view.ndim; + __pyx_v_info->ndim = __pyx_t_7; + + /* "View.MemoryView":544 + * info.buf = self.view.buf + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize # <<<<<<<<<<<<<< + * info.len = self.view.len + * info.readonly = self.view.readonly + */ + __pyx_t_8 = __pyx_v_self->view.itemsize; + __pyx_v_info->itemsize = __pyx_t_8; + + /* "View.MemoryView":545 + * info.ndim = self.view.ndim + * info.itemsize = self.view.itemsize + * info.len = self.view.len # <<<<<<<<<<<<<< + * info.readonly = self.view.readonly + * info.obj = self + */ + __pyx_t_8 = __pyx_v_self->view.len; + __pyx_v_info->len = __pyx_t_8; + + /* "View.MemoryView":546 + * info.itemsize = self.view.itemsize + * info.len = self.view.len + * info.readonly = self.view.readonly # <<<<<<<<<<<<<< + * info.obj = self + * + */ + __pyx_t_1 = __pyx_v_self->view.readonly; + __pyx_v_info->readonly = __pyx_t_1; + + /* "View.MemoryView":547 + * info.len = self.view.len + * info.readonly = self.view.readonly + * info.obj = self # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + + /* "View.MemoryView":518 + * + * @cname('getbuffer') + * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< + * if flags & PyBUF_WRITABLE and self.view.readonly: + * raise ValueError("Cannot create writable memory view from read-only memoryview") + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; + } + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":553 + * + * @property + * def T(self): # <<<<<<<<<<<<<< + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":554 + * @property + * def T(self): + * cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<< + * transpose_memslice(&result.from_slice) + * return result + */ + __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(1, 554, __pyx_L1_error) + __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "View.MemoryView":555 + * def T(self): + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 555, __pyx_L1_error) + + /* "View.MemoryView":556 + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + * return result # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + /* "View.MemoryView":553 + * + * @property + * def T(self): # <<<<<<<<<<<<<< + * cdef _memoryviewslice result = memoryview_copy(self) + * transpose_memslice(&result.from_slice) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":559 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.obj + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":560 + * @property + * def base(self): + * return self.obj # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->obj); + __pyx_r = __pyx_v_self->obj; + goto __pyx_L0; + + /* "View.MemoryView":559 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.obj + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":563 + * + * @property + * def shape(self): # <<<<<<<<<<<<<< + * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_length; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":564 + * @property + * def shape(self): + * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 564, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); + for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { + __pyx_t_2 = __pyx_t_4; + __pyx_v_length = (__pyx_t_2[0]); + __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 564, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "View.MemoryView":563 + * + * @property + * def shape(self): # <<<<<<<<<<<<<< + * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":567 + * + * @property + * def strides(self): # <<<<<<<<<<<<<< + * if self.view.strides == NULL: + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_stride; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":568 + * @property + * def strides(self): + * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * + * raise ValueError("Buffer view does not expose strides") + */ + __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0); + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":570 + * if self.view.strides == NULL: + * + * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + */ + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 570, __pyx_L1_error) + + /* "View.MemoryView":568 + * @property + * def strides(self): + * if self.view.strides == NULL: # <<<<<<<<<<<<<< + * + * raise ValueError("Buffer view does not expose strides") + */ + } + + /* "View.MemoryView":572 + * raise ValueError("Buffer view does not expose strides") + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 572, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim); + for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { + __pyx_t_3 = __pyx_t_5; + __pyx_v_stride = (__pyx_t_3[0]); + __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 572, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_6; + __pyx_t_6 = 0; + goto __pyx_L0; + + /* "View.MemoryView":567 + * + * @property + * def strides(self): # <<<<<<<<<<<<<< + * if self.view.strides == NULL: + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":575 + * + * @property + * def suboffsets(self): # <<<<<<<<<<<<<< + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + Py_ssize_t *__pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":576 + * @property + * def suboffsets(self): + * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< + * return (-1,) * self.view.ndim + * + */ + __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":577 + * def suboffsets(self): + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__12, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":576 + * @property + * def suboffsets(self): + * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< + * return (-1,) * self.view.ndim + * + */ + } + + /* "View.MemoryView":579 + * return (-1,) * self.view.ndim + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 579, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim); + for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) { + __pyx_t_4 = __pyx_t_6; + __pyx_v_suboffset = (__pyx_t_4[0]); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(1, 579, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":575 + * + * @property + * def suboffsets(self): # <<<<<<<<<<<<<< + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":582 + * + * @property + * def ndim(self): # <<<<<<<<<<<<<< + * return self.view.ndim + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":583 + * @property + * def ndim(self): + * return self.view.ndim # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 583, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":582 + * + * @property + * def ndim(self): # <<<<<<<<<<<<<< + * return self.view.ndim + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":586 + * + * @property + * def itemsize(self): # <<<<<<<<<<<<<< + * return self.view.itemsize + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":587 + * @property + * def itemsize(self): + * return self.view.itemsize # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 587, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":586 + * + * @property + * def itemsize(self): # <<<<<<<<<<<<<< + * return self.view.itemsize + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":590 + * + * @property + * def nbytes(self): # <<<<<<<<<<<<<< + * return self.size * self.view.itemsize + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":591 + * @property + * def nbytes(self): + * return self.size * self.view.itemsize # <<<<<<<<<<<<<< + * + * @property + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 591, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 591, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 591, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":590 + * + * @property + * def nbytes(self): # <<<<<<<<<<<<<< + * return self.size * self.view.itemsize + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":594 + * + * @property + * def size(self): # <<<<<<<<<<<<<< + * if self._size is None: + * result = 1 + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_length = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + Py_ssize_t *__pyx_t_5; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":595 + * @property + * def size(self): + * if self._size is None: # <<<<<<<<<<<<<< + * result = 1 + * + */ + __pyx_t_1 = (__pyx_v_self->_size == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":596 + * def size(self): + * if self._size is None: + * result = 1 # <<<<<<<<<<<<<< + * + * for length in self.view.shape[:self.view.ndim]: + */ + __Pyx_INCREF(__pyx_int_1); + __pyx_v_result = __pyx_int_1; + + /* "View.MemoryView":598 + * result = 1 + * + * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<< + * result *= length + * + */ + __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); + for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { + __pyx_t_3 = __pyx_t_5; + __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 598, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6); + __pyx_t_6 = 0; + + /* "View.MemoryView":599 + * + * for length in self.view.shape[:self.view.ndim]: + * result *= length # <<<<<<<<<<<<<< + * + * self._size = result + */ + __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 599, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6); + __pyx_t_6 = 0; + } + + /* "View.MemoryView":601 + * result *= length + * + * self._size = result # <<<<<<<<<<<<<< + * + * return self._size + */ + __Pyx_INCREF(__pyx_v_result); + __Pyx_GIVEREF(__pyx_v_result); + __Pyx_GOTREF(__pyx_v_self->_size); + __Pyx_DECREF(__pyx_v_self->_size); + __pyx_v_self->_size = __pyx_v_result; + + /* "View.MemoryView":595 + * @property + * def size(self): + * if self._size is None: # <<<<<<<<<<<<<< + * result = 1 + * + */ + } + + /* "View.MemoryView":603 + * self._size = result + * + * return self._size # <<<<<<<<<<<<<< + * + * def __len__(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->_size); + __pyx_r = __pyx_v_self->_size; + goto __pyx_L0; + + /* "View.MemoryView":594 + * + * @property + * def size(self): # <<<<<<<<<<<<<< + * if self._size is None: + * result = 1 + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_length); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":605 + * return self._size + * + * def __len__(self): # <<<<<<<<<<<<<< + * if self.view.ndim >= 1: + * return self.view.shape[0] + */ + +/* Python wrapper */ +static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { + Py_ssize_t __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__len__", 0); + + /* "View.MemoryView":606 + * + * def __len__(self): + * if self.view.ndim >= 1: # <<<<<<<<<<<<<< + * return self.view.shape[0] + * + */ + __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":607 + * def __len__(self): + * if self.view.ndim >= 1: + * return self.view.shape[0] # <<<<<<<<<<<<<< + * + * return 0 + */ + __pyx_r = (__pyx_v_self->view.shape[0]); + goto __pyx_L0; + + /* "View.MemoryView":606 + * + * def __len__(self): + * if self.view.ndim >= 1: # <<<<<<<<<<<<<< + * return self.view.shape[0] + * + */ + } + + /* "View.MemoryView":609 + * return self.view.shape[0] + * + * return 0 # <<<<<<<<<<<<<< + * + * def __repr__(self): + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":605 + * return self._size + * + * def __len__(self): # <<<<<<<<<<<<<< + * if self.view.ndim >= 1: + * return self.view.shape[0] + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":611 + * return 0 + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__, + * id(self)) + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__repr__", 0); + + /* "View.MemoryView":612 + * + * def __repr__(self): + * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< + * id(self)) + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":613 + * def __repr__(self): + * return "" % (self.base.__class__.__name__, + * id(self)) # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 613, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + + /* "View.MemoryView":612 + * + * def __repr__(self): + * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< + * id(self)) + * + */ + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":611 + * return 0 + * + * def __repr__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__, + * id(self)) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":615 + * id(self)) + * + * def __str__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__,) + * + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "View.MemoryView":616 + * + * def __str__(self): + * return "" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":615 + * id(self)) + * + * def __str__(self): # <<<<<<<<<<<<<< + * return "" % (self.base.__class__.__name__,) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":619 + * + * + * def is_c_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice *__pyx_v_mslice; + __Pyx_memviewslice __pyx_v_tmp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice *__pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_c_contig", 0); + + /* "View.MemoryView":622 + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< + * return slice_is_contig(mslice[0], 'C', self.view.ndim) + * + */ + __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 622, __pyx_L1_error) + __pyx_v_mslice = __pyx_t_1; + + /* "View.MemoryView":623 + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) + * return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<< + * + * def is_f_contig(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 623, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":619 + * + * + * def is_c_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":625 + * return slice_is_contig(mslice[0], 'C', self.view.ndim) + * + * def is_f_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice *__pyx_v_mslice; + __Pyx_memviewslice __pyx_v_tmp; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice *__pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("is_f_contig", 0); + + /* "View.MemoryView":628 + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< + * return slice_is_contig(mslice[0], 'F', self.view.ndim) + * + */ + __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 628, __pyx_L1_error) + __pyx_v_mslice = __pyx_t_1; + + /* "View.MemoryView":629 + * cdef __Pyx_memviewslice tmp + * mslice = get_slice_from_memview(self, &tmp) + * return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<< + * + * def copy(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 629, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":625 + * return slice_is_contig(mslice[0], 'C', self.view.ndim) + * + * def is_f_contig(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice *mslice + * cdef __Pyx_memviewslice tmp + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":631 + * return slice_is_contig(mslice[0], 'F', self.view.ndim) + * + * def copy(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("copy (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice __pyx_v_mslice; + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("copy", 0); + + /* "View.MemoryView":633 + * def copy(self): + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<< + * + * slice_copy(self, &mslice) + */ + __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS)); + + /* "View.MemoryView":635 + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + * + * slice_copy(self, &mslice) # <<<<<<<<<<<<<< + * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, + * self.view.itemsize, + */ + __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice)); + + /* "View.MemoryView":636 + * + * slice_copy(self, &mslice) + * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<< + * self.view.itemsize, + * flags|PyBUF_C_CONTIGUOUS, + */ + __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 636, __pyx_L1_error) + __pyx_v_mslice = __pyx_t_1; + + /* "View.MemoryView":641 + * self.dtype_is_object) + * + * return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<< + * + * def copy_fortran(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 641, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":631 + * return slice_is_contig(mslice[0], 'F', self.view.ndim) + * + * def copy(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice mslice + * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":643 + * return memoryview_copy_from_slice(self, &mslice) + * + * def copy_fortran(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + */ + +/* Python wrapper */ +static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0); + __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { + __Pyx_memviewslice __pyx_v_src; + __Pyx_memviewslice __pyx_v_dst; + int __pyx_v_flags; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_memviewslice __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("copy_fortran", 0); + + /* "View.MemoryView":645 + * def copy_fortran(self): + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<< + * + * slice_copy(self, &src) + */ + __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS)); + + /* "View.MemoryView":647 + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + * + * slice_copy(self, &src) # <<<<<<<<<<<<<< + * dst = slice_copy_contig(&src, "fortran", self.view.ndim, + * self.view.itemsize, + */ + __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src)); + + /* "View.MemoryView":648 + * + * slice_copy(self, &src) + * dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<< + * self.view.itemsize, + * flags|PyBUF_F_CONTIGUOUS, + */ + __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 648, __pyx_L1_error) + __pyx_v_dst = __pyx_t_1; + + /* "View.MemoryView":653 + * self.dtype_is_object) + * + * return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 653, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":643 + * return memoryview_copy_from_slice(self, &mslice) + * + * def copy_fortran(self): # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice src, dst + * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":657 + * + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + */ + +static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) { + struct __pyx_memoryview_obj *__pyx_v_result = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("memoryview_cwrapper", 0); + + /* "View.MemoryView":658 + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + * cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<< + * result.typeinfo = typeinfo + * return result + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 658, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 658, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_o); + __Pyx_GIVEREF(__pyx_v_o); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":659 + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo # <<<<<<<<<<<<<< + * return result + * + */ + __pyx_v_result->typeinfo = __pyx_v_typeinfo; + + /* "View.MemoryView":660 + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + * return result # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_check') + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + /* "View.MemoryView":657 + * + * @cname('__pyx_memoryview_new') + * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< + * cdef memoryview result = memoryview(o, flags, dtype_is_object) + * result.typeinfo = typeinfo + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":663 + * + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< + * return isinstance(o, memoryview) + * + */ + +static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("memoryview_check", 0); + + /* "View.MemoryView":664 + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): + * return isinstance(o, memoryview) # <<<<<<<<<<<<<< + * + * cdef tuple _unellipsify(object index, int ndim): + */ + __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); + __pyx_r = __pyx_t_1; + goto __pyx_L0; + + /* "View.MemoryView":663 + * + * @cname('__pyx_memoryview_check') + * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< + * return isinstance(o, memoryview) + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":666 + * return isinstance(o, memoryview) + * + * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< + * """ + * Replace all ellipses with full slices and fill incomplete indices with + */ + +static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { + PyObject *__pyx_v_tup = NULL; + PyObject *__pyx_v_result = NULL; + int __pyx_v_have_slices; + int __pyx_v_seen_ellipsis; + CYTHON_UNUSED PyObject *__pyx_v_idx = NULL; + PyObject *__pyx_v_item = NULL; + Py_ssize_t __pyx_v_nslices; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); + PyObject *__pyx_t_7 = NULL; + Py_ssize_t __pyx_t_8; + int __pyx_t_9; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_unellipsify", 0); + + /* "View.MemoryView":671 + * full slices. + * """ + * if not isinstance(index, tuple): # <<<<<<<<<<<<<< + * tup = (index,) + * else: + */ + __pyx_t_1 = PyTuple_Check(__pyx_v_index); + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":672 + * """ + * if not isinstance(index, tuple): + * tup = (index,) # <<<<<<<<<<<<<< + * else: + * tup = index + */ + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 672, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_index); + __Pyx_GIVEREF(__pyx_v_index); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index); + __pyx_v_tup = __pyx_t_3; + __pyx_t_3 = 0; + + /* "View.MemoryView":671 + * full slices. + * """ + * if not isinstance(index, tuple): # <<<<<<<<<<<<<< + * tup = (index,) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":674 + * tup = (index,) + * else: + * tup = index # <<<<<<<<<<<<<< + * + * result = [] + */ + /*else*/ { + __Pyx_INCREF(__pyx_v_index); + __pyx_v_tup = __pyx_v_index; + } + __pyx_L3:; + + /* "View.MemoryView":676 + * tup = index + * + * result = [] # <<<<<<<<<<<<<< + * have_slices = False + * seen_ellipsis = False + */ + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 676, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_v_result = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":677 + * + * result = [] + * have_slices = False # <<<<<<<<<<<<<< + * seen_ellipsis = False + * for idx, item in enumerate(tup): + */ + __pyx_v_have_slices = 0; + + /* "View.MemoryView":678 + * result = [] + * have_slices = False + * seen_ellipsis = False # <<<<<<<<<<<<<< + * for idx, item in enumerate(tup): + * if item is Ellipsis: + */ + __pyx_v_seen_ellipsis = 0; + + /* "View.MemoryView":679 + * have_slices = False + * seen_ellipsis = False + * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< + * if item is Ellipsis: + * if not seen_ellipsis: + */ + __Pyx_INCREF(__pyx_int_0); + __pyx_t_3 = __pyx_int_0; + if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) { + __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 679, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_6)) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error) + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + } else { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error) + #else + __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + #endif + } + } else { + __pyx_t_7 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_7)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 679, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_7); + } + __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7); + __pyx_t_7 = 0; + __Pyx_INCREF(__pyx_t_3); + __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3); + __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); + __pyx_t_3 = __pyx_t_7; + __pyx_t_7 = 0; + + /* "View.MemoryView":680 + * seen_ellipsis = False + * for idx, item in enumerate(tup): + * if item is Ellipsis: # <<<<<<<<<<<<<< + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + */ + __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":681 + * for idx, item in enumerate(tup): + * if item is Ellipsis: + * if not seen_ellipsis: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True + */ + __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":682 + * if item is Ellipsis: + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< + * seen_ellipsis = True + * else: + */ + __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(1, 682, __pyx_L1_error) + __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { + __Pyx_INCREF(__pyx_slice__15); + __Pyx_GIVEREF(__pyx_slice__15); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__15); + } + } + __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 682, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "View.MemoryView":683 + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True # <<<<<<<<<<<<<< + * else: + * result.append(slice(None)) + */ + __pyx_v_seen_ellipsis = 1; + + /* "View.MemoryView":681 + * for idx, item in enumerate(tup): + * if item is Ellipsis: + * if not seen_ellipsis: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + * seen_ellipsis = True + */ + goto __pyx_L7; + } + + /* "View.MemoryView":685 + * seen_ellipsis = True + * else: + * result.append(slice(None)) # <<<<<<<<<<<<<< + * have_slices = True + * else: + */ + /*else*/ { + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__15); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 685, __pyx_L1_error) + } + __pyx_L7:; + + /* "View.MemoryView":686 + * else: + * result.append(slice(None)) + * have_slices = True # <<<<<<<<<<<<<< + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): + */ + __pyx_v_have_slices = 1; + + /* "View.MemoryView":680 + * seen_ellipsis = False + * for idx, item in enumerate(tup): + * if item is Ellipsis: # <<<<<<<<<<<<<< + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) + */ + goto __pyx_L6; + } + + /* "View.MemoryView":688 + * have_slices = True + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< + * raise TypeError("Cannot index with type '%s'" % type(item)) + * + */ + /*else*/ { + __pyx_t_2 = PySlice_Check(__pyx_v_item); + __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0); + if (__pyx_t_10) { + } else { + __pyx_t_1 = __pyx_t_10; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0); + __pyx_t_1 = __pyx_t_10; + __pyx_L9_bool_binop_done:; + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":689 + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): + * raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<< + * + * have_slices = have_slices or isinstance(item, slice) + */ + __pyx_t_7 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 689, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_Raise(__pyx_t_11, 0, 0, 0); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __PYX_ERR(1, 689, __pyx_L1_error) + + /* "View.MemoryView":688 + * have_slices = True + * else: + * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< + * raise TypeError("Cannot index with type '%s'" % type(item)) + * + */ + } + + /* "View.MemoryView":691 + * raise TypeError("Cannot index with type '%s'" % type(item)) + * + * have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<< + * result.append(item) + * + */ + __pyx_t_10 = (__pyx_v_have_slices != 0); + if (!__pyx_t_10) { + } else { + __pyx_t_1 = __pyx_t_10; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_10 = PySlice_Check(__pyx_v_item); + __pyx_t_2 = (__pyx_t_10 != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L11_bool_binop_done:; + __pyx_v_have_slices = __pyx_t_1; + + /* "View.MemoryView":692 + * + * have_slices = have_slices or isinstance(item, slice) + * result.append(item) # <<<<<<<<<<<<<< + * + * nslices = ndim - len(result) + */ + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 692, __pyx_L1_error) + } + __pyx_L6:; + + /* "View.MemoryView":679 + * have_slices = False + * seen_ellipsis = False + * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< + * if item is Ellipsis: + * if not seen_ellipsis: + */ + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":694 + * result.append(item) + * + * nslices = ndim - len(result) # <<<<<<<<<<<<<< + * if nslices: + * result.extend([slice(None)] * nslices) + */ + __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 694, __pyx_L1_error) + __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5); + + /* "View.MemoryView":695 + * + * nslices = ndim - len(result) + * if nslices: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * nslices) + * + */ + __pyx_t_1 = (__pyx_v_nslices != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":696 + * nslices = ndim - len(result) + * if nslices: + * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< + * + * return have_slices or nslices, tuple(result) + */ + __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 696, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { + __Pyx_INCREF(__pyx_slice__15); + __Pyx_GIVEREF(__pyx_slice__15); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__15); + } + } + __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 696, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":695 + * + * nslices = ndim - len(result) + * if nslices: # <<<<<<<<<<<<<< + * result.extend([slice(None)] * nslices) + * + */ + } + + /* "View.MemoryView":698 + * result.extend([slice(None)] * nslices) + * + * return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<< + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + */ + __Pyx_XDECREF(__pyx_r); + if (!__pyx_v_have_slices) { + } else { + __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L14_bool_binop_done; + } + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_L14_bool_binop_done:; + __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 698, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_r = ((PyObject*)__pyx_t_11); + __pyx_t_11 = 0; + goto __pyx_L0; + + /* "View.MemoryView":666 + * return isinstance(o, memoryview) + * + * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< + * """ + * Replace all ellipses with full slices and fill incomplete indices with + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_tup); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_idx); + __Pyx_XDECREF(__pyx_v_item); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":700 + * return have_slices or nslices, tuple(result) + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + */ + +static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) { + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + Py_ssize_t *__pyx_t_1; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("assert_direct_dimensions", 0); + + /* "View.MemoryView":701 + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<< + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") + */ + __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim); + for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) { + __pyx_t_1 = __pyx_t_3; + __pyx_v_suboffset = (__pyx_t_1[0]); + + /* "View.MemoryView":702 + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * raise ValueError("Indirect dimensions not supported") + * + */ + __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0); + if (unlikely(__pyx_t_4)) { + + /* "View.MemoryView":703 + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 703, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __PYX_ERR(1, 703, __pyx_L1_error) + + /* "View.MemoryView":702 + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * raise ValueError("Indirect dimensions not supported") + * + */ + } + } + + /* "View.MemoryView":700 + * return have_slices or nslices, tuple(result) + * + * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":710 + * + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< + * cdef int new_ndim = 0, suboffset_dim = -1, dim + * cdef bint negative_step + */ + +static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) { + int __pyx_v_new_ndim; + int __pyx_v_suboffset_dim; + int __pyx_v_dim; + __Pyx_memviewslice __pyx_v_src; + __Pyx_memviewslice __pyx_v_dst; + __Pyx_memviewslice *__pyx_v_p_src; + struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0; + __Pyx_memviewslice *__pyx_v_p_dst; + int *__pyx_v_p_suboffset_dim; + Py_ssize_t __pyx_v_start; + Py_ssize_t __pyx_v_stop; + Py_ssize_t __pyx_v_step; + int __pyx_v_have_start; + int __pyx_v_have_stop; + int __pyx_v_have_step; + PyObject *__pyx_v_index = NULL; + struct __pyx_memoryview_obj *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + struct __pyx_memoryview_obj *__pyx_t_4; + char *__pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + Py_ssize_t __pyx_t_10; + int __pyx_t_11; + Py_ssize_t __pyx_t_12; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("memview_slice", 0); + + /* "View.MemoryView":711 + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): + * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<< + * cdef bint negative_step + * cdef __Pyx_memviewslice src, dst + */ + __pyx_v_new_ndim = 0; + __pyx_v_suboffset_dim = -1; + + /* "View.MemoryView":718 + * + * + * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<< + * + * cdef _memoryviewslice memviewsliceobj + */ + (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst)))); + + /* "View.MemoryView":722 + * cdef _memoryviewslice memviewsliceobj + * + * assert memview.view.ndim > 0 # <<<<<<<<<<<<<< + * + * if isinstance(memview, _memoryviewslice): + */ + #ifndef CYTHON_WITHOUT_ASSERTIONS + if (unlikely(!Py_OptimizeFlag)) { + if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) { + PyErr_SetNone(PyExc_AssertionError); + __PYX_ERR(1, 722, __pyx_L1_error) + } + } + #endif + + /* "View.MemoryView":724 + * assert memview.view.ndim > 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":725 + * + * if isinstance(memview, _memoryviewslice): + * memviewsliceobj = memview # <<<<<<<<<<<<<< + * p_src = &memviewsliceobj.from_slice + * else: + */ + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 725, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_memview); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":726 + * if isinstance(memview, _memoryviewslice): + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<< + * else: + * slice_copy(memview, &src) + */ + __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice); + + /* "View.MemoryView":724 + * assert memview.view.ndim > 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * memviewsliceobj = memview + * p_src = &memviewsliceobj.from_slice + */ + goto __pyx_L3; + } + + /* "View.MemoryView":728 + * p_src = &memviewsliceobj.from_slice + * else: + * slice_copy(memview, &src) # <<<<<<<<<<<<<< + * p_src = &src + * + */ + /*else*/ { + __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src)); + + /* "View.MemoryView":729 + * else: + * slice_copy(memview, &src) + * p_src = &src # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_p_src = (&__pyx_v_src); + } + __pyx_L3:; + + /* "View.MemoryView":735 + * + * + * dst.memview = p_src.memview # <<<<<<<<<<<<<< + * dst.data = p_src.data + * + */ + __pyx_t_4 = __pyx_v_p_src->memview; + __pyx_v_dst.memview = __pyx_t_4; + + /* "View.MemoryView":736 + * + * dst.memview = p_src.memview + * dst.data = p_src.data # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __pyx_v_p_src->data; + __pyx_v_dst.data = __pyx_t_5; + + /* "View.MemoryView":741 + * + * + * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<< + * cdef int *p_suboffset_dim = &suboffset_dim + * cdef Py_ssize_t start, stop, step + */ + __pyx_v_p_dst = (&__pyx_v_dst); + + /* "View.MemoryView":742 + * + * cdef __Pyx_memviewslice *p_dst = &dst + * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<< + * cdef Py_ssize_t start, stop, step + * cdef bint have_start, have_stop, have_step + */ + __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim); + + /* "View.MemoryView":746 + * cdef bint have_start, have_stop, have_step + * + * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< + * if PyIndex_Check(index): + * slice_memviewslice( + */ + __pyx_t_6 = 0; + if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) { + __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 746, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 746, __pyx_L1_error) + } + for (;;) { + if (likely(!__pyx_t_8)) { + if (likely(PyList_CheckExact(__pyx_t_3))) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error) + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } else { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error) + #else + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + #endif + } + } else { + __pyx_t_9 = __pyx_t_8(__pyx_t_3); + if (unlikely(!__pyx_t_9)) { + PyObject* exc_type = PyErr_Occurred(); + if (exc_type) { + if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); + else __PYX_ERR(1, 746, __pyx_L1_error) + } + break; + } + __Pyx_GOTREF(__pyx_t_9); + } + __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9); + __pyx_t_9 = 0; + __pyx_v_dim = __pyx_t_6; + __pyx_t_6 = (__pyx_t_6 + 1); + + /* "View.MemoryView":747 + * + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): # <<<<<<<<<<<<<< + * slice_memviewslice( + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + */ + __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":751 + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<< + * 0, 0, 0, # have_{start,stop,step} + * False) + */ + __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 751, __pyx_L1_error) + + /* "View.MemoryView":748 + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): + * slice_memviewslice( # <<<<<<<<<<<<<< + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + */ + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 748, __pyx_L1_error) + + /* "View.MemoryView":747 + * + * for dim, index in enumerate(indices): + * if PyIndex_Check(index): # <<<<<<<<<<<<<< + * slice_memviewslice( + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + */ + goto __pyx_L6; + } + + /* "View.MemoryView":754 + * 0, 0, 0, # have_{start,stop,step} + * False) + * elif index is None: # <<<<<<<<<<<<<< + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + */ + __pyx_t_2 = (__pyx_v_index == Py_None); + __pyx_t_1 = (__pyx_t_2 != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":755 + * False) + * elif index is None: + * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<< + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 + */ + (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1; + + /* "View.MemoryView":756 + * elif index is None: + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<< + * p_dst.suboffsets[new_ndim] = -1 + * new_ndim += 1 + */ + (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0; + + /* "View.MemoryView":757 + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<< + * new_ndim += 1 + * else: + */ + (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L; + + /* "View.MemoryView":758 + * p_dst.strides[new_ndim] = 0 + * p_dst.suboffsets[new_ndim] = -1 + * new_ndim += 1 # <<<<<<<<<<<<<< + * else: + * start = index.start or 0 + */ + __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); + + /* "View.MemoryView":754 + * 0, 0, 0, # have_{start,stop,step} + * False) + * elif index is None: # <<<<<<<<<<<<<< + * p_dst.shape[new_ndim] = 1 + * p_dst.strides[new_ndim] = 0 + */ + goto __pyx_L6; + } + + /* "View.MemoryView":760 + * new_ndim += 1 + * else: + * start = index.start or 0 # <<<<<<<<<<<<<< + * stop = index.stop or 0 + * step = index.step or 0 + */ + /*else*/ { + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 760, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 760, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 760, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L7_bool_binop_done:; + __pyx_v_start = __pyx_t_10; + + /* "View.MemoryView":761 + * else: + * start = index.start or 0 + * stop = index.stop or 0 # <<<<<<<<<<<<<< + * step = index.step or 0 + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 761, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 761, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 761, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L9_bool_binop_done:; + __pyx_v_stop = __pyx_t_10; + + /* "View.MemoryView":762 + * start = index.start or 0 + * stop = index.stop or 0 + * step = index.step or 0 # <<<<<<<<<<<<<< + * + * have_start = index.start is not None + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 762, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 762, __pyx_L1_error) + if (!__pyx_t_1) { + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else { + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 762, __pyx_L1_error) + __pyx_t_10 = __pyx_t_12; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L11_bool_binop_done; + } + __pyx_t_10 = 0; + __pyx_L11_bool_binop_done:; + __pyx_v_step = __pyx_t_10; + + /* "View.MemoryView":764 + * step = index.step or 0 + * + * have_start = index.start is not None # <<<<<<<<<<<<<< + * have_stop = index.stop is not None + * have_step = index.step is not None + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 764, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_start = __pyx_t_1; + + /* "View.MemoryView":765 + * + * have_start = index.start is not None + * have_stop = index.stop is not None # <<<<<<<<<<<<<< + * have_step = index.step is not None + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 765, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_stop = __pyx_t_1; + + /* "View.MemoryView":766 + * have_start = index.start is not None + * have_stop = index.stop is not None + * have_step = index.step is not None # <<<<<<<<<<<<<< + * + * slice_memviewslice( + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 766, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_have_step = __pyx_t_1; + + /* "View.MemoryView":768 + * have_step = index.step is not None + * + * slice_memviewslice( # <<<<<<<<<<<<<< + * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], + * dim, new_ndim, p_suboffset_dim, + */ + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 768, __pyx_L1_error) + + /* "View.MemoryView":774 + * have_start, have_stop, have_step, + * True) + * new_ndim += 1 # <<<<<<<<<<<<<< + * + * if isinstance(memview, _memoryviewslice): + */ + __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); + } + __pyx_L6:; + + /* "View.MemoryView":746 + * cdef bint have_start, have_stop, have_step + * + * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< + * if PyIndex_Check(index): + * slice_memviewslice( + */ + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + + /* "View.MemoryView":776 + * new_ndim += 1 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":777 + * + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + + /* "View.MemoryView":778 + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<< + * memviewsliceobj.to_dtype_func, + * memview.dtype_is_object) + */ + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 778, __pyx_L1_error) } + + /* "View.MemoryView":779 + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * else: + */ + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 779, __pyx_L1_error) } + + /* "View.MemoryView":777 + * + * if isinstance(memview, _memoryviewslice): + * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< + * memviewsliceobj.to_object_func, + * memviewsliceobj.to_dtype_func, + */ + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 777, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 777, __pyx_L1_error) + __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + + /* "View.MemoryView":776 + * new_ndim += 1 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * return memoryview_fromslice(dst, new_ndim, + * memviewsliceobj.to_object_func, + */ + } + + /* "View.MemoryView":782 + * memview.dtype_is_object) + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * + */ + /*else*/ { + __Pyx_XDECREF(((PyObject *)__pyx_r)); + + /* "View.MemoryView":783 + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, + * memview.dtype_is_object) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 782, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + + /* "View.MemoryView":782 + * memview.dtype_is_object) + * else: + * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< + * memview.dtype_is_object) + * + */ + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 782, __pyx_L1_error) + __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":710 + * + * @cname('__pyx_memview_slice') + * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< + * cdef int new_ndim = 0, suboffset_dim = -1, dim + * cdef bint negative_step + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj); + __Pyx_XDECREF(__pyx_v_index); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":807 + * + * @cname('__pyx_memoryview_slice_memviewslice') + * cdef int slice_memviewslice( # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + */ + +static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) { + Py_ssize_t __pyx_v_new_shape; + int __pyx_v_negative_step; + int __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + + /* "View.MemoryView":827 + * cdef bint negative_step + * + * if not is_slice: # <<<<<<<<<<<<<< + * + * if start < 0: + */ + __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":829 + * if not is_slice: + * + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if not 0 <= start < shape: + */ + __pyx_t_1 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":830 + * + * if start < 0: + * start += shape # <<<<<<<<<<<<<< + * if not 0 <= start < shape: + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + */ + __pyx_v_start = (__pyx_v_start + __pyx_v_shape); + + /* "View.MemoryView":829 + * if not is_slice: + * + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if not 0 <= start < shape: + */ + } + + /* "View.MemoryView":831 + * if start < 0: + * start += shape + * if not 0 <= start < shape: # <<<<<<<<<<<<<< + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + * else: + */ + __pyx_t_1 = (0 <= __pyx_v_start); + if (__pyx_t_1) { + __pyx_t_1 = (__pyx_v_start < __pyx_v_shape); + } + __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":832 + * start += shape + * if not 0 <= start < shape: + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<< + * else: + * + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 832, __pyx_L1_error) + + /* "View.MemoryView":831 + * if start < 0: + * start += shape + * if not 0 <= start < shape: # <<<<<<<<<<<<<< + * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) + * else: + */ + } + + /* "View.MemoryView":827 + * cdef bint negative_step + * + * if not is_slice: # <<<<<<<<<<<<<< + * + * if start < 0: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":835 + * else: + * + * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<< + * + * if have_step and step == 0: + */ + /*else*/ { + __pyx_t_1 = ((__pyx_v_have_step != 0) != 0); + if (__pyx_t_1) { + } else { + __pyx_t_2 = __pyx_t_1; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_1 = ((__pyx_v_step < 0) != 0); + __pyx_t_2 = __pyx_t_1; + __pyx_L6_bool_binop_done:; + __pyx_v_negative_step = __pyx_t_2; + + /* "View.MemoryView":837 + * negative_step = have_step != 0 and step < 0 + * + * if have_step and step == 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + * + */ + __pyx_t_1 = (__pyx_v_have_step != 0); + if (__pyx_t_1) { + } else { + __pyx_t_2 = __pyx_t_1; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_1 = ((__pyx_v_step == 0) != 0); + __pyx_t_2 = __pyx_t_1; + __pyx_L9_bool_binop_done:; + if (__pyx_t_2) { + + /* "View.MemoryView":838 + * + * if have_step and step == 0: + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 838, __pyx_L1_error) + + /* "View.MemoryView":837 + * negative_step = have_step != 0 and step < 0 + * + * if have_step and step == 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) + * + */ + } + + /* "View.MemoryView":841 + * + * + * if have_start: # <<<<<<<<<<<<<< + * if start < 0: + * start += shape + */ + __pyx_t_2 = (__pyx_v_have_start != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":842 + * + * if have_start: + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if start < 0: + */ + __pyx_t_2 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":843 + * if have_start: + * if start < 0: + * start += shape # <<<<<<<<<<<<<< + * if start < 0: + * start = 0 + */ + __pyx_v_start = (__pyx_v_start + __pyx_v_shape); + + /* "View.MemoryView":844 + * if start < 0: + * start += shape + * if start < 0: # <<<<<<<<<<<<<< + * start = 0 + * elif start >= shape: + */ + __pyx_t_2 = ((__pyx_v_start < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":845 + * start += shape + * if start < 0: + * start = 0 # <<<<<<<<<<<<<< + * elif start >= shape: + * if negative_step: + */ + __pyx_v_start = 0; + + /* "View.MemoryView":844 + * if start < 0: + * start += shape + * if start < 0: # <<<<<<<<<<<<<< + * start = 0 + * elif start >= shape: + */ + } + + /* "View.MemoryView":842 + * + * if have_start: + * if start < 0: # <<<<<<<<<<<<<< + * start += shape + * if start < 0: + */ + goto __pyx_L12; + } + + /* "View.MemoryView":846 + * if start < 0: + * start = 0 + * elif start >= shape: # <<<<<<<<<<<<<< + * if negative_step: + * start = shape - 1 + */ + __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":847 + * start = 0 + * elif start >= shape: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":848 + * elif start >= shape: + * if negative_step: + * start = shape - 1 # <<<<<<<<<<<<<< + * else: + * start = shape + */ + __pyx_v_start = (__pyx_v_shape - 1); + + /* "View.MemoryView":847 + * start = 0 + * elif start >= shape: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + goto __pyx_L14; + } + + /* "View.MemoryView":850 + * start = shape - 1 + * else: + * start = shape # <<<<<<<<<<<<<< + * else: + * if negative_step: + */ + /*else*/ { + __pyx_v_start = __pyx_v_shape; + } + __pyx_L14:; + + /* "View.MemoryView":846 + * if start < 0: + * start = 0 + * elif start >= shape: # <<<<<<<<<<<<<< + * if negative_step: + * start = shape - 1 + */ + } + __pyx_L12:; + + /* "View.MemoryView":841 + * + * + * if have_start: # <<<<<<<<<<<<<< + * if start < 0: + * start += shape + */ + goto __pyx_L11; + } + + /* "View.MemoryView":852 + * start = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + /*else*/ { + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":853 + * else: + * if negative_step: + * start = shape - 1 # <<<<<<<<<<<<<< + * else: + * start = 0 + */ + __pyx_v_start = (__pyx_v_shape - 1); + + /* "View.MemoryView":852 + * start = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * start = shape - 1 + * else: + */ + goto __pyx_L15; + } + + /* "View.MemoryView":855 + * start = shape - 1 + * else: + * start = 0 # <<<<<<<<<<<<<< + * + * if have_stop: + */ + /*else*/ { + __pyx_v_start = 0; + } + __pyx_L15:; + } + __pyx_L11:; + + /* "View.MemoryView":857 + * start = 0 + * + * if have_stop: # <<<<<<<<<<<<<< + * if stop < 0: + * stop += shape + */ + __pyx_t_2 = (__pyx_v_have_stop != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":858 + * + * if have_stop: + * if stop < 0: # <<<<<<<<<<<<<< + * stop += shape + * if stop < 0: + */ + __pyx_t_2 = ((__pyx_v_stop < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":859 + * if have_stop: + * if stop < 0: + * stop += shape # <<<<<<<<<<<<<< + * if stop < 0: + * stop = 0 + */ + __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape); + + /* "View.MemoryView":860 + * if stop < 0: + * stop += shape + * if stop < 0: # <<<<<<<<<<<<<< + * stop = 0 + * elif stop > shape: + */ + __pyx_t_2 = ((__pyx_v_stop < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":861 + * stop += shape + * if stop < 0: + * stop = 0 # <<<<<<<<<<<<<< + * elif stop > shape: + * stop = shape + */ + __pyx_v_stop = 0; + + /* "View.MemoryView":860 + * if stop < 0: + * stop += shape + * if stop < 0: # <<<<<<<<<<<<<< + * stop = 0 + * elif stop > shape: + */ + } + + /* "View.MemoryView":858 + * + * if have_stop: + * if stop < 0: # <<<<<<<<<<<<<< + * stop += shape + * if stop < 0: + */ + goto __pyx_L17; + } + + /* "View.MemoryView":862 + * if stop < 0: + * stop = 0 + * elif stop > shape: # <<<<<<<<<<<<<< + * stop = shape + * else: + */ + __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":863 + * stop = 0 + * elif stop > shape: + * stop = shape # <<<<<<<<<<<<<< + * else: + * if negative_step: + */ + __pyx_v_stop = __pyx_v_shape; + + /* "View.MemoryView":862 + * if stop < 0: + * stop = 0 + * elif stop > shape: # <<<<<<<<<<<<<< + * stop = shape + * else: + */ + } + __pyx_L17:; + + /* "View.MemoryView":857 + * start = 0 + * + * if have_stop: # <<<<<<<<<<<<<< + * if stop < 0: + * stop += shape + */ + goto __pyx_L16; + } + + /* "View.MemoryView":865 + * stop = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * stop = -1 + * else: + */ + /*else*/ { + __pyx_t_2 = (__pyx_v_negative_step != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":866 + * else: + * if negative_step: + * stop = -1 # <<<<<<<<<<<<<< + * else: + * stop = shape + */ + __pyx_v_stop = -1L; + + /* "View.MemoryView":865 + * stop = shape + * else: + * if negative_step: # <<<<<<<<<<<<<< + * stop = -1 + * else: + */ + goto __pyx_L19; + } + + /* "View.MemoryView":868 + * stop = -1 + * else: + * stop = shape # <<<<<<<<<<<<<< + * + * if not have_step: + */ + /*else*/ { + __pyx_v_stop = __pyx_v_shape; + } + __pyx_L19:; + } + __pyx_L16:; + + /* "View.MemoryView":870 + * stop = shape + * + * if not have_step: # <<<<<<<<<<<<<< + * step = 1 + * + */ + __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":871 + * + * if not have_step: + * step = 1 # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_step = 1; + + /* "View.MemoryView":870 + * stop = shape + * + * if not have_step: # <<<<<<<<<<<<<< + * step = 1 + * + */ + } + + /* "View.MemoryView":875 + * + * with cython.cdivision(True): + * new_shape = (stop - start) // step # <<<<<<<<<<<<<< + * + * if (stop - start) - step * new_shape: + */ + __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step); + + /* "View.MemoryView":877 + * new_shape = (stop - start) // step + * + * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< + * new_shape += 1 + * + */ + __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":878 + * + * if (stop - start) - step * new_shape: + * new_shape += 1 # <<<<<<<<<<<<<< + * + * if new_shape < 0: + */ + __pyx_v_new_shape = (__pyx_v_new_shape + 1); + + /* "View.MemoryView":877 + * new_shape = (stop - start) // step + * + * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< + * new_shape += 1 + * + */ + } + + /* "View.MemoryView":880 + * new_shape += 1 + * + * if new_shape < 0: # <<<<<<<<<<<<<< + * new_shape = 0 + * + */ + __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":881 + * + * if new_shape < 0: + * new_shape = 0 # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_new_shape = 0; + + /* "View.MemoryView":880 + * new_shape += 1 + * + * if new_shape < 0: # <<<<<<<<<<<<<< + * new_shape = 0 + * + */ + } + + /* "View.MemoryView":884 + * + * + * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<< + * dst.shape[new_ndim] = new_shape + * dst.suboffsets[new_ndim] = suboffset + */ + (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step); + + /* "View.MemoryView":885 + * + * dst.strides[new_ndim] = stride * step + * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<< + * dst.suboffsets[new_ndim] = suboffset + * + */ + (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape; + + /* "View.MemoryView":886 + * dst.strides[new_ndim] = stride * step + * dst.shape[new_ndim] = new_shape + * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset; + } + __pyx_L3:; + + /* "View.MemoryView":889 + * + * + * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< + * dst.data += start * stride + * else: + */ + __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":890 + * + * if suboffset_dim[0] < 0: + * dst.data += start * stride # <<<<<<<<<<<<<< + * else: + * dst.suboffsets[suboffset_dim[0]] += start * stride + */ + __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride)); + + /* "View.MemoryView":889 + * + * + * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< + * dst.data += start * stride + * else: + */ + goto __pyx_L23; + } + + /* "View.MemoryView":892 + * dst.data += start * stride + * else: + * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<< + * + * if suboffset >= 0: + */ + /*else*/ { + __pyx_t_3 = (__pyx_v_suboffset_dim[0]); + (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride)); + } + __pyx_L23:; + + /* "View.MemoryView":894 + * dst.suboffsets[suboffset_dim[0]] += start * stride + * + * if suboffset >= 0: # <<<<<<<<<<<<<< + * if not is_slice: + * if new_ndim == 0: + */ + __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":895 + * + * if suboffset >= 0: + * if not is_slice: # <<<<<<<<<<<<<< + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset + */ + __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":896 + * if suboffset >= 0: + * if not is_slice: + * if new_ndim == 0: # <<<<<<<<<<<<<< + * dst.data = ( dst.data)[0] + suboffset + * else: + */ + __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":897 + * if not is_slice: + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<< + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " + */ + __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset); + + /* "View.MemoryView":896 + * if suboffset >= 0: + * if not is_slice: + * if new_ndim == 0: # <<<<<<<<<<<<<< + * dst.data = ( dst.data)[0] + suboffset + * else: + */ + goto __pyx_L26; + } + + /* "View.MemoryView":899 + * dst.data = ( dst.data)[0] + suboffset + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<< + * "must be indexed and not sliced", dim) + * else: + */ + /*else*/ { + + /* "View.MemoryView":900 + * else: + * _err_dim(IndexError, "All dimensions preceding dimension %d " + * "must be indexed and not sliced", dim) # <<<<<<<<<<<<<< + * else: + * suboffset_dim[0] = new_ndim + */ + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 899, __pyx_L1_error) + } + __pyx_L26:; + + /* "View.MemoryView":895 + * + * if suboffset >= 0: + * if not is_slice: # <<<<<<<<<<<<<< + * if new_ndim == 0: + * dst.data = ( dst.data)[0] + suboffset + */ + goto __pyx_L25; + } + + /* "View.MemoryView":902 + * "must be indexed and not sliced", dim) + * else: + * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<< + * + * return 0 + */ + /*else*/ { + (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim; + } + __pyx_L25:; + + /* "View.MemoryView":894 + * dst.suboffsets[suboffset_dim[0]] += start * stride + * + * if suboffset >= 0: # <<<<<<<<<<<<<< + * if not is_slice: + * if new_ndim == 0: + */ + } + + /* "View.MemoryView":904 + * suboffset_dim[0] = new_ndim + * + * return 0 # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":807 + * + * @cname('__pyx_memoryview_slice_memviewslice') + * cdef int slice_memviewslice( # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":910 + * + * @cname('__pyx_pybuffer_index') + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + */ + +static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) { + Py_ssize_t __pyx_v_shape; + Py_ssize_t __pyx_v_stride; + Py_ssize_t __pyx_v_suboffset; + Py_ssize_t __pyx_v_itemsize; + char *__pyx_v_resultp; + char *__pyx_r; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("pybuffer_index", 0); + + /* "View.MemoryView":912 + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<< + * cdef Py_ssize_t itemsize = view.itemsize + * cdef char *resultp + */ + __pyx_v_suboffset = -1L; + + /* "View.MemoryView":913 + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<< + * cdef char *resultp + * + */ + __pyx_t_1 = __pyx_v_view->itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":916 + * cdef char *resultp + * + * if view.ndim == 0: # <<<<<<<<<<<<<< + * shape = view.len / itemsize + * stride = itemsize + */ + __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":917 + * + * if view.ndim == 0: + * shape = view.len / itemsize # <<<<<<<<<<<<<< + * stride = itemsize + * else: + */ + if (unlikely(__pyx_v_itemsize == 0)) { + PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + __PYX_ERR(1, 917, __pyx_L1_error) + } + else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) { + PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); + __PYX_ERR(1, 917, __pyx_L1_error) + } + __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize); + + /* "View.MemoryView":918 + * if view.ndim == 0: + * shape = view.len / itemsize + * stride = itemsize # <<<<<<<<<<<<<< + * else: + * shape = view.shape[dim] + */ + __pyx_v_stride = __pyx_v_itemsize; + + /* "View.MemoryView":916 + * cdef char *resultp + * + * if view.ndim == 0: # <<<<<<<<<<<<<< + * shape = view.len / itemsize + * stride = itemsize + */ + goto __pyx_L3; + } + + /* "View.MemoryView":920 + * stride = itemsize + * else: + * shape = view.shape[dim] # <<<<<<<<<<<<<< + * stride = view.strides[dim] + * if view.suboffsets != NULL: + */ + /*else*/ { + __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]); + + /* "View.MemoryView":921 + * else: + * shape = view.shape[dim] + * stride = view.strides[dim] # <<<<<<<<<<<<<< + * if view.suboffsets != NULL: + * suboffset = view.suboffsets[dim] + */ + __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]); + + /* "View.MemoryView":922 + * shape = view.shape[dim] + * stride = view.strides[dim] + * if view.suboffsets != NULL: # <<<<<<<<<<<<<< + * suboffset = view.suboffsets[dim] + * + */ + __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":923 + * stride = view.strides[dim] + * if view.suboffsets != NULL: + * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<< + * + * if index < 0: + */ + __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]); + + /* "View.MemoryView":922 + * shape = view.shape[dim] + * stride = view.strides[dim] + * if view.suboffsets != NULL: # <<<<<<<<<<<<<< + * suboffset = view.suboffsets[dim] + * + */ + } + } + __pyx_L3:; + + /* "View.MemoryView":925 + * suboffset = view.suboffsets[dim] + * + * if index < 0: # <<<<<<<<<<<<<< + * index += view.shape[dim] + * if index < 0: + */ + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":926 + * + * if index < 0: + * index += view.shape[dim] # <<<<<<<<<<<<<< + * if index < 0: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + */ + __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim])); + + /* "View.MemoryView":927 + * if index < 0: + * index += view.shape[dim] + * if index < 0: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + __pyx_t_2 = ((__pyx_v_index < 0) != 0); + if (unlikely(__pyx_t_2)) { + + /* "View.MemoryView":928 + * index += view.shape[dim] + * if index < 0: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< + * + * if index >= shape: + */ + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 928, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 928, __pyx_L1_error) + + /* "View.MemoryView":927 + * if index < 0: + * index += view.shape[dim] + * if index < 0: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + } + + /* "View.MemoryView":925 + * suboffset = view.suboffsets[dim] + * + * if index < 0: # <<<<<<<<<<<<<< + * index += view.shape[dim] + * if index < 0: + */ + } + + /* "View.MemoryView":930 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + * if index >= shape: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0); + if (unlikely(__pyx_t_2)) { + + /* "View.MemoryView":931 + * + * if index >= shape: + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< + * + * resultp = bufp + index * stride + */ + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 931, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __PYX_ERR(1, 931, __pyx_L1_error) + + /* "View.MemoryView":930 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + * if index >= shape: # <<<<<<<<<<<<<< + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + */ + } + + /* "View.MemoryView":933 + * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) + * + * resultp = bufp + index * stride # <<<<<<<<<<<<<< + * if suboffset >= 0: + * resultp = ( resultp)[0] + suboffset + */ + __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride)); + + /* "View.MemoryView":934 + * + * resultp = bufp + index * stride + * if suboffset >= 0: # <<<<<<<<<<<<<< + * resultp = ( resultp)[0] + suboffset + * + */ + __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":935 + * resultp = bufp + index * stride + * if suboffset >= 0: + * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<< + * + * return resultp + */ + __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset); + + /* "View.MemoryView":934 + * + * resultp = bufp + index * stride + * if suboffset >= 0: # <<<<<<<<<<<<<< + * resultp = ( resultp)[0] + suboffset + * + */ + } + + /* "View.MemoryView":937 + * resultp = ( resultp)[0] + suboffset + * + * return resultp # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_resultp; + goto __pyx_L0; + + /* "View.MemoryView":910 + * + * @cname('__pyx_pybuffer_index') + * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< + * Py_ssize_t dim) except NULL: + * cdef Py_ssize_t shape, stride, suboffset = -1 + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":943 + * + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< + * cdef int ndim = memslice.memview.view.ndim + * + */ + +static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { + int __pyx_v_ndim; + Py_ssize_t *__pyx_v_shape; + Py_ssize_t *__pyx_v_strides; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_r; + int __pyx_t_1; + Py_ssize_t *__pyx_t_2; + long __pyx_t_3; + long __pyx_t_4; + Py_ssize_t __pyx_t_5; + Py_ssize_t __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + + /* "View.MemoryView":944 + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: + * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<< + * + * cdef Py_ssize_t *shape = memslice.shape + */ + __pyx_t_1 = __pyx_v_memslice->memview->view.ndim; + __pyx_v_ndim = __pyx_t_1; + + /* "View.MemoryView":946 + * cdef int ndim = memslice.memview.view.ndim + * + * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<< + * cdef Py_ssize_t *strides = memslice.strides + * + */ + __pyx_t_2 = __pyx_v_memslice->shape; + __pyx_v_shape = __pyx_t_2; + + /* "View.MemoryView":947 + * + * cdef Py_ssize_t *shape = memslice.shape + * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __pyx_v_memslice->strides; + __pyx_v_strides = __pyx_t_2; + + /* "View.MemoryView":951 + * + * cdef int i, j + * for i in range(ndim / 2): # <<<<<<<<<<<<<< + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] + */ + __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2); + __pyx_t_4 = __pyx_t_3; + for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":952 + * cdef int i, j + * for i in range(ndim / 2): + * j = ndim - 1 - i # <<<<<<<<<<<<<< + * strides[i], strides[j] = strides[j], strides[i] + * shape[i], shape[j] = shape[j], shape[i] + */ + __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i); + + /* "View.MemoryView":953 + * for i in range(ndim / 2): + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<< + * shape[i], shape[j] = shape[j], shape[i] + * + */ + __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]); + __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]); + (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5; + (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6; + + /* "View.MemoryView":954 + * j = ndim - 1 - i + * strides[i], strides[j] = strides[j], strides[i] + * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<< + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + */ + __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]); + __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]); + (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6; + (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5; + + /* "View.MemoryView":956 + * shape[i], shape[j] = shape[j], shape[i] + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + * + */ + __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0); + if (!__pyx_t_8) { + } else { + __pyx_t_7 = __pyx_t_8; + goto __pyx_L6_bool_binop_done; + } + __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0); + __pyx_t_7 = __pyx_t_8; + __pyx_L6_bool_binop_done:; + if (__pyx_t_7) { + + /* "View.MemoryView":957 + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<< + * + * return 1 + */ + __pyx_t_9 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L1_error) + + /* "View.MemoryView":956 + * shape[i], shape[j] = shape[j], shape[i] + * + * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + * + */ + } + } + + /* "View.MemoryView":959 + * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") + * + * return 1 # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = 1; + goto __pyx_L0; + + /* "View.MemoryView":943 + * + * @cname('__pyx_memslice_transpose') + * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< + * cdef int ndim = memslice.memview.view.ndim + * + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = 0; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":976 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + */ + +/* Python wrapper */ +static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__dealloc__", 0); + + /* "View.MemoryView":977 + * + * def __dealloc__(self): + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<< + * + * cdef convert_item_to_object(self, char *itemp): + */ + __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1); + + /* "View.MemoryView":976 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":979 + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) + */ + +static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("convert_item_to_object", 0); + + /* "View.MemoryView":980 + * + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: # <<<<<<<<<<<<<< + * return self.to_object_func(itemp) + * else: + */ + __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":981 + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) # <<<<<<<<<<<<<< + * else: + * return memoryview.convert_item_to_object(self, itemp) + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 981, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "View.MemoryView":980 + * + * cdef convert_item_to_object(self, char *itemp): + * if self.to_object_func != NULL: # <<<<<<<<<<<<<< + * return self.to_object_func(itemp) + * else: + */ + } + + /* "View.MemoryView":983 + * return self.to_object_func(itemp) + * else: + * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<< + * + * cdef assign_item_from_object(self, char *itemp, object value): + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 983, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + } + + /* "View.MemoryView":979 + * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) + * + * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< + * if self.to_object_func != NULL: + * return self.to_object_func(itemp) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":985 + * return memoryview.convert_item_to_object(self, itemp) + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) + */ + +static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("assign_item_from_object", 0); + + /* "View.MemoryView":986 + * + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< + * self.to_dtype_func(itemp, value) + * else: + */ + __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":987 + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<< + * else: + * memoryview.assign_item_from_object(self, itemp, value) + */ + __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 987, __pyx_L1_error) + + /* "View.MemoryView":986 + * + * cdef assign_item_from_object(self, char *itemp, object value): + * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< + * self.to_dtype_func(itemp, value) + * else: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":989 + * self.to_dtype_func(itemp, value) + * else: + * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<< + * + * @property + */ + /*else*/ { + __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 989, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __pyx_L3:; + + /* "View.MemoryView":985 + * return memoryview.convert_item_to_object(self, itemp) + * + * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< + * if self.to_dtype_func != NULL: + * self.to_dtype_func(itemp, value) + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":992 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.from_object + * + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + + /* "View.MemoryView":993 + * @property + * def base(self): + * return self.from_object # <<<<<<<<<<<<<< + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->from_object); + __pyx_r = __pyx_v_self->from_object; + goto __pyx_L0; + + /* "View.MemoryView":992 + * + * @property + * def base(self): # <<<<<<<<<<<<<< + * return self.from_object + * + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__reduce_cython__", 0); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 2, __pyx_L1_error) + + /* "(tree fragment)":1 + * def __reduce_cython__(self): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + +/* Python wrapper */ +static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ +static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); + __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__setstate_cython__", 0); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 4, __pyx_L1_error) + + /* "(tree fragment)":3 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":999 + * + * @cname('__pyx_memoryview_fromslice') + * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< + * int ndim, + * object (*to_object_func)(char *), + */ + +static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) { + struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; + Py_ssize_t __pyx_v_suboffset; + PyObject *__pyx_v_length = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + __Pyx_TypeInfo *__pyx_t_4; + Py_buffer __pyx_t_5; + Py_ssize_t *__pyx_t_6; + Py_ssize_t *__pyx_t_7; + Py_ssize_t *__pyx_t_8; + Py_ssize_t __pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("memoryview_fromslice", 0); + + /* "View.MemoryView":1007 + * cdef _memoryviewslice result + * + * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< + * return None + * + */ + __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1008 + * + * if memviewslice.memview == Py_None: + * return None # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + + /* "View.MemoryView":1007 + * cdef _memoryviewslice result + * + * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< + * return None + * + */ + } + + /* "View.MemoryView":1013 + * + * + * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<< + * + * result.from_slice = memviewslice + */ + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1013, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None); + __Pyx_INCREF(__pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":1015 + * result = _memoryviewslice(None, 0, dtype_is_object) + * + * result.from_slice = memviewslice # <<<<<<<<<<<<<< + * __PYX_INC_MEMVIEW(&memviewslice, 1) + * + */ + __pyx_v_result->from_slice = __pyx_v_memviewslice; + + /* "View.MemoryView":1016 + * + * result.from_slice = memviewslice + * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<< + * + * result.from_object = ( memviewslice.memview).base + */ + __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1); + + /* "View.MemoryView":1018 + * __PYX_INC_MEMVIEW(&memviewslice, 1) + * + * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<< + * result.typeinfo = memviewslice.memview.typeinfo + * + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1018, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_result->from_object); + __Pyx_DECREF(__pyx_v_result->from_object); + __pyx_v_result->from_object = __pyx_t_2; + __pyx_t_2 = 0; + + /* "View.MemoryView":1019 + * + * result.from_object = ( memviewslice.memview).base + * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<< + * + * result.view = memviewslice.memview.view + */ + __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo; + __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4; + + /* "View.MemoryView":1021 + * result.typeinfo = memviewslice.memview.typeinfo + * + * result.view = memviewslice.memview.view # <<<<<<<<<<<<<< + * result.view.buf = memviewslice.data + * result.view.ndim = ndim + */ + __pyx_t_5 = __pyx_v_memviewslice.memview->view; + __pyx_v_result->__pyx_base.view = __pyx_t_5; + + /* "View.MemoryView":1022 + * + * result.view = memviewslice.memview.view + * result.view.buf = memviewslice.data # <<<<<<<<<<<<<< + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None + */ + __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data); + + /* "View.MemoryView":1023 + * result.view = memviewslice.memview.view + * result.view.buf = memviewslice.data + * result.view.ndim = ndim # <<<<<<<<<<<<<< + * (<__pyx_buffer *> &result.view).obj = Py_None + * Py_INCREF(Py_None) + */ + __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim; + + /* "View.MemoryView":1024 + * result.view.buf = memviewslice.data + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<< + * Py_INCREF(Py_None) + * + */ + ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None; + + /* "View.MemoryView":1025 + * result.view.ndim = ndim + * (<__pyx_buffer *> &result.view).obj = Py_None + * Py_INCREF(Py_None) # <<<<<<<<<<<<<< + * + * if (memviewslice.memview).flags & PyBUF_WRITABLE: + */ + Py_INCREF(Py_None); + + /* "View.MemoryView":1027 + * Py_INCREF(Py_None) + * + * if (memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<< + * result.flags = PyBUF_RECORDS + * else: + */ + __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1028 + * + * if (memviewslice.memview).flags & PyBUF_WRITABLE: + * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<< + * else: + * result.flags = PyBUF_RECORDS_RO + */ + __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS; + + /* "View.MemoryView":1027 + * Py_INCREF(Py_None) + * + * if (memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<< + * result.flags = PyBUF_RECORDS + * else: + */ + goto __pyx_L4; + } + + /* "View.MemoryView":1030 + * result.flags = PyBUF_RECORDS + * else: + * result.flags = PyBUF_RECORDS_RO # <<<<<<<<<<<<<< + * + * result.view.shape = result.from_slice.shape + */ + /*else*/ { + __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO; + } + __pyx_L4:; + + /* "View.MemoryView":1032 + * result.flags = PyBUF_RECORDS_RO + * + * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<< + * result.view.strides = result.from_slice.strides + * + */ + __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape); + + /* "View.MemoryView":1033 + * + * result.view.shape = result.from_slice.shape + * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides); + + /* "View.MemoryView":1036 + * + * + * result.view.suboffsets = NULL # <<<<<<<<<<<<<< + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: + */ + __pyx_v_result->__pyx_base.view.suboffsets = NULL; + + /* "View.MemoryView":1037 + * + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<< + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets + */ + __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim); + for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { + __pyx_t_6 = __pyx_t_8; + __pyx_v_suboffset = (__pyx_t_6[0]); + + /* "View.MemoryView":1038 + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * result.view.suboffsets = result.from_slice.suboffsets + * break + */ + __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1039 + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< + * break + * + */ + __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); + + /* "View.MemoryView":1040 + * if suboffset >= 0: + * result.view.suboffsets = result.from_slice.suboffsets + * break # <<<<<<<<<<<<<< + * + * result.view.len = result.view.itemsize + */ + goto __pyx_L6_break; + + /* "View.MemoryView":1038 + * result.view.suboffsets = NULL + * for suboffset in result.from_slice.suboffsets[:ndim]: + * if suboffset >= 0: # <<<<<<<<<<<<<< + * result.view.suboffsets = result.from_slice.suboffsets + * break + */ + } + } + __pyx_L6_break:; + + /* "View.MemoryView":1042 + * break + * + * result.view.len = result.view.itemsize # <<<<<<<<<<<<<< + * for length in result.view.shape[:ndim]: + * result.view.len *= length + */ + __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize; + __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + + /* "View.MemoryView":1043 + * + * result.view.len = result.view.itemsize + * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<< + * result.view.len *= length + * + */ + __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim); + for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { + __pyx_t_6 = __pyx_t_8; + __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1043, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":1044 + * result.view.len = result.view.itemsize + * for length in result.view.shape[:ndim]: + * result.view.len *= length # <<<<<<<<<<<<<< + * + * result.to_object_func = to_object_func + */ + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1044, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1044, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1044, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + } + + /* "View.MemoryView":1046 + * result.view.len *= length + * + * result.to_object_func = to_object_func # <<<<<<<<<<<<<< + * result.to_dtype_func = to_dtype_func + * + */ + __pyx_v_result->to_object_func = __pyx_v_to_object_func; + + /* "View.MemoryView":1047 + * + * result.to_object_func = to_object_func + * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<< + * + * return result + */ + __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func; + + /* "View.MemoryView":1049 + * result.to_dtype_func = to_dtype_func + * + * return result # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + /* "View.MemoryView":999 + * + * @cname('__pyx_memoryview_fromslice') + * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< + * int ndim, + * object (*to_object_func)(char *), + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_length); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1052 + * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *mslice) except NULL: + * cdef _memoryviewslice obj + */ + +static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) { + struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0; + __Pyx_memviewslice *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_slice_from_memview", 0); + + /* "View.MemoryView":1055 + * __Pyx_memviewslice *mslice) except NULL: + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * obj = memview + * return &obj.from_slice + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1056 + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): + * obj = memview # <<<<<<<<<<<<<< + * return &obj.from_slice + * else: + */ + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 1056, __pyx_L1_error) + __pyx_t_3 = ((PyObject *)__pyx_v_memview); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":1057 + * if isinstance(memview, _memoryviewslice): + * obj = memview + * return &obj.from_slice # <<<<<<<<<<<<<< + * else: + * slice_copy(memview, mslice) + */ + __pyx_r = (&__pyx_v_obj->from_slice); + goto __pyx_L0; + + /* "View.MemoryView":1055 + * __Pyx_memviewslice *mslice) except NULL: + * cdef _memoryviewslice obj + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * obj = memview + * return &obj.from_slice + */ + } + + /* "View.MemoryView":1059 + * return &obj.from_slice + * else: + * slice_copy(memview, mslice) # <<<<<<<<<<<<<< + * return mslice + * + */ + /*else*/ { + __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice); + + /* "View.MemoryView":1060 + * else: + * slice_copy(memview, mslice) + * return mslice # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_slice_copy') + */ + __pyx_r = __pyx_v_mslice; + goto __pyx_L0; + } + + /* "View.MemoryView":1052 + * + * @cname('__pyx_memoryview_get_slice_from_memoryview') + * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *mslice) except NULL: + * cdef _memoryviewslice obj + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_obj); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1063 + * + * @cname('__pyx_memoryview_slice_copy') + * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< + * cdef int dim + * cdef (Py_ssize_t*) shape, strides, suboffsets + */ + +static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) { + int __pyx_v_dim; + Py_ssize_t *__pyx_v_shape; + Py_ssize_t *__pyx_v_strides; + Py_ssize_t *__pyx_v_suboffsets; + __Pyx_RefNannyDeclarations + Py_ssize_t *__pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + Py_ssize_t __pyx_t_5; + __Pyx_RefNannySetupContext("slice_copy", 0); + + /* "View.MemoryView":1067 + * cdef (Py_ssize_t*) shape, strides, suboffsets + * + * shape = memview.view.shape # <<<<<<<<<<<<<< + * strides = memview.view.strides + * suboffsets = memview.view.suboffsets + */ + __pyx_t_1 = __pyx_v_memview->view.shape; + __pyx_v_shape = __pyx_t_1; + + /* "View.MemoryView":1068 + * + * shape = memview.view.shape + * strides = memview.view.strides # <<<<<<<<<<<<<< + * suboffsets = memview.view.suboffsets + * + */ + __pyx_t_1 = __pyx_v_memview->view.strides; + __pyx_v_strides = __pyx_t_1; + + /* "View.MemoryView":1069 + * shape = memview.view.shape + * strides = memview.view.strides + * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<< + * + * dst.memview = <__pyx_memoryview *> memview + */ + __pyx_t_1 = __pyx_v_memview->view.suboffsets; + __pyx_v_suboffsets = __pyx_t_1; + + /* "View.MemoryView":1071 + * suboffsets = memview.view.suboffsets + * + * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<< + * dst.data = memview.view.buf + * + */ + __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview); + + /* "View.MemoryView":1072 + * + * dst.memview = <__pyx_memoryview *> memview + * dst.data = memview.view.buf # <<<<<<<<<<<<<< + * + * for dim in range(memview.view.ndim): + */ + __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf); + + /* "View.MemoryView":1074 + * dst.data = memview.view.buf + * + * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<< + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] + */ + __pyx_t_2 = __pyx_v_memview->view.ndim; + __pyx_t_3 = __pyx_t_2; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_dim = __pyx_t_4; + + /* "View.MemoryView":1075 + * + * for dim in range(memview.view.ndim): + * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<< + * dst.strides[dim] = strides[dim] + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + */ + (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]); + + /* "View.MemoryView":1076 + * for dim in range(memview.view.ndim): + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<< + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + * + */ + (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]); + + /* "View.MemoryView":1077 + * dst.shape[dim] = shape[dim] + * dst.strides[dim] = strides[dim] + * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_object') + */ + if ((__pyx_v_suboffsets != 0)) { + __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]); + } else { + __pyx_t_5 = -1L; + } + (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5; + } + + /* "View.MemoryView":1063 + * + * @cname('__pyx_memoryview_slice_copy') + * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< + * cdef int dim + * cdef (Py_ssize_t*) shape, strides, suboffsets + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":1080 + * + * @cname('__pyx_memoryview_copy_object') + * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + */ + +static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) { + __Pyx_memviewslice __pyx_v_memviewslice; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("memoryview_copy", 0); + + /* "View.MemoryView":1083 + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<< + * return memoryview_copy_from_slice(memview, &memviewslice) + * + */ + __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice)); + + /* "View.MemoryView":1084 + * cdef __Pyx_memviewslice memviewslice + * slice_copy(memview, &memviewslice) + * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_object_from_slice') + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1084, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "View.MemoryView":1080 + * + * @cname('__pyx_memoryview_copy_object') + * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< + * "Create a new memoryview object" + * cdef __Pyx_memviewslice memviewslice + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1087 + * + * @cname('__pyx_memoryview_copy_object_from_slice') + * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< + * """ + * Create a new memoryview object from a given memoryview object and slice. + */ + +static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) { + PyObject *(*__pyx_v_to_object_func)(char *); + int (*__pyx_v_to_dtype_func)(char *, PyObject *); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *(*__pyx_t_3)(char *); + int (*__pyx_t_4)(char *, PyObject *); + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0); + + /* "View.MemoryView":1094 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + */ + __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1095 + * + * if isinstance(memview, _memoryviewslice): + * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<< + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + * else: + */ + __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func; + __pyx_v_to_object_func = __pyx_t_3; + + /* "View.MemoryView":1096 + * if isinstance(memview, _memoryviewslice): + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<< + * else: + * to_object_func = NULL + */ + __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func; + __pyx_v_to_dtype_func = __pyx_t_4; + + /* "View.MemoryView":1094 + * cdef int (*to_dtype_func)(char *, object) except 0 + * + * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< + * to_object_func = (<_memoryviewslice> memview).to_object_func + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1098 + * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func + * else: + * to_object_func = NULL # <<<<<<<<<<<<<< + * to_dtype_func = NULL + * + */ + /*else*/ { + __pyx_v_to_object_func = NULL; + + /* "View.MemoryView":1099 + * else: + * to_object_func = NULL + * to_dtype_func = NULL # <<<<<<<<<<<<<< + * + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, + */ + __pyx_v_to_dtype_func = NULL; + } + __pyx_L3:; + + /* "View.MemoryView":1101 + * to_dtype_func = NULL + * + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<< + * to_object_func, to_dtype_func, + * memview.dtype_is_object) + */ + __Pyx_XDECREF(__pyx_r); + + /* "View.MemoryView":1103 + * return memoryview_fromslice(memviewslice[0], memview.view.ndim, + * to_object_func, to_dtype_func, + * memview.dtype_is_object) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1101, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "View.MemoryView":1087 + * + * @cname('__pyx_memoryview_copy_object_from_slice') + * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< + * """ + * Create a new memoryview object from a given memoryview object and slice. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "View.MemoryView":1109 + * + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< + * if arg < 0: + * return -arg + */ + +static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { + Py_ssize_t __pyx_r; + int __pyx_t_1; + + /* "View.MemoryView":1110 + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: # <<<<<<<<<<<<<< + * return -arg + * else: + */ + __pyx_t_1 = ((__pyx_v_arg < 0) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1111 + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: + * return -arg # <<<<<<<<<<<<<< + * else: + * return arg + */ + __pyx_r = (-__pyx_v_arg); + goto __pyx_L0; + + /* "View.MemoryView":1110 + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: + * if arg < 0: # <<<<<<<<<<<<<< + * return -arg + * else: + */ + } + + /* "View.MemoryView":1113 + * return -arg + * else: + * return arg # <<<<<<<<<<<<<< + * + * @cname('__pyx_get_best_slice_order') + */ + /*else*/ { + __pyx_r = __pyx_v_arg; + goto __pyx_L0; + } + + /* "View.MemoryView":1109 + * + * + * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< + * if arg < 0: + * return -arg + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1116 + * + * @cname('__pyx_get_best_slice_order') + * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< + * """ + * Figure out the best memory access order for a given slice. + */ + +static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) { + int __pyx_v_i; + Py_ssize_t __pyx_v_c_stride; + Py_ssize_t __pyx_v_f_stride; + char __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + + /* "View.MemoryView":1121 + * """ + * cdef int i + * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<< + * cdef Py_ssize_t f_stride = 0 + * + */ + __pyx_v_c_stride = 0; + + /* "View.MemoryView":1122 + * cdef int i + * cdef Py_ssize_t c_stride = 0 + * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<< + * + * for i in range(ndim - 1, -1, -1): + */ + __pyx_v_f_stride = 0; + + /* "View.MemoryView":1124 + * cdef Py_ssize_t f_stride = 0 + * + * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] + */ + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":1125 + * + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * c_stride = mslice.strides[i] + * break + */ + __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1126 + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] # <<<<<<<<<<<<<< + * break + * + */ + __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1127 + * if mslice.shape[i] > 1: + * c_stride = mslice.strides[i] + * break # <<<<<<<<<<<<<< + * + * for i in range(ndim): + */ + goto __pyx_L4_break; + + /* "View.MemoryView":1125 + * + * for i in range(ndim - 1, -1, -1): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * c_stride = mslice.strides[i] + * break + */ + } + } + __pyx_L4_break:; + + /* "View.MemoryView":1129 + * break + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] + */ + __pyx_t_1 = __pyx_v_ndim; + __pyx_t_3 = __pyx_t_1; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "View.MemoryView":1130 + * + * for i in range(ndim): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * f_stride = mslice.strides[i] + * break + */ + __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1131 + * for i in range(ndim): + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] # <<<<<<<<<<<<<< + * break + * + */ + __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1132 + * if mslice.shape[i] > 1: + * f_stride = mslice.strides[i] + * break # <<<<<<<<<<<<<< + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + */ + goto __pyx_L7_break; + + /* "View.MemoryView":1130 + * + * for i in range(ndim): + * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< + * f_stride = mslice.strides[i] + * break + */ + } + } + __pyx_L7_break:; + + /* "View.MemoryView":1134 + * break + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< + * return 'C' + * else: + */ + __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1135 + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): + * return 'C' # <<<<<<<<<<<<<< + * else: + * return 'F' + */ + __pyx_r = 'C'; + goto __pyx_L0; + + /* "View.MemoryView":1134 + * break + * + * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< + * return 'C' + * else: + */ + } + + /* "View.MemoryView":1137 + * return 'C' + * else: + * return 'F' # <<<<<<<<<<<<<< + * + * @cython.cdivision(True) + */ + /*else*/ { + __pyx_r = 'F'; + goto __pyx_L0; + } + + /* "View.MemoryView":1116 + * + * @cname('__pyx_get_best_slice_order') + * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< + * """ + * Figure out the best memory access order for a given slice. + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1140 + * + * @cython.cdivision(True) + * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< + * char *dst_data, Py_ssize_t *dst_strides, + * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + */ + +static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent; + Py_ssize_t __pyx_v_dst_extent; + Py_ssize_t __pyx_v_src_stride; + Py_ssize_t __pyx_v_dst_stride; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + Py_ssize_t __pyx_t_4; + Py_ssize_t __pyx_t_5; + Py_ssize_t __pyx_t_6; + + /* "View.MemoryView":1147 + * + * cdef Py_ssize_t i + * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] + */ + __pyx_v_src_extent = (__pyx_v_src_shape[0]); + + /* "View.MemoryView":1148 + * cdef Py_ssize_t i + * cdef Py_ssize_t src_extent = src_shape[0] + * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t src_stride = src_strides[0] + * cdef Py_ssize_t dst_stride = dst_strides[0] + */ + __pyx_v_dst_extent = (__pyx_v_dst_shape[0]); + + /* "View.MemoryView":1149 + * cdef Py_ssize_t src_extent = src_shape[0] + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + */ + __pyx_v_src_stride = (__pyx_v_src_strides[0]); + + /* "View.MemoryView":1150 + * cdef Py_ssize_t dst_extent = dst_shape[0] + * cdef Py_ssize_t src_stride = src_strides[0] + * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<< + * + * if ndim == 1: + */ + __pyx_v_dst_stride = (__pyx_v_dst_strides[0]); + + /* "View.MemoryView":1152 + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + */ + __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1153 + * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) + */ + __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } + __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L5_bool_binop_done; + } + + /* "View.MemoryView":1154 + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<< + * memcpy(dst_data, src_data, itemsize * dst_extent) + * else: + */ + __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize); + if (__pyx_t_2) { + __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride)); + } + __pyx_t_3 = (__pyx_t_2 != 0); + __pyx_t_1 = __pyx_t_3; + __pyx_L5_bool_binop_done:; + + /* "View.MemoryView":1153 + * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) + */ + if (__pyx_t_1) { + + /* "View.MemoryView":1155 + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<< + * else: + * for i in range(dst_extent): + */ + (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent))); + + /* "View.MemoryView":1153 + * + * if ndim == 1: + * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< + * src_stride == itemsize == dst_stride): + * memcpy(dst_data, src_data, itemsize * dst_extent) + */ + goto __pyx_L4; + } + + /* "View.MemoryView":1157 + * memcpy(dst_data, src_data, itemsize * dst_extent) + * else: + * for i in range(dst_extent): # <<<<<<<<<<<<<< + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride + */ + /*else*/ { + __pyx_t_4 = __pyx_v_dst_extent; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "View.MemoryView":1158 + * else: + * for i in range(dst_extent): + * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<< + * src_data += src_stride + * dst_data += dst_stride + */ + (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize)); + + /* "View.MemoryView":1159 + * for i in range(dst_extent): + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride # <<<<<<<<<<<<<< + * dst_data += dst_stride + * else: + */ + __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + + /* "View.MemoryView":1160 + * memcpy(dst_data, src_data, itemsize) + * src_data += src_stride + * dst_data += dst_stride # <<<<<<<<<<<<<< + * else: + * for i in range(dst_extent): + */ + __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); + } + } + __pyx_L4:; + + /* "View.MemoryView":1152 + * cdef Py_ssize_t dst_stride = dst_strides[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * if (src_stride > 0 and dst_stride > 0 and + * src_stride == itemsize == dst_stride): + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1162 + * dst_data += dst_stride + * else: + * for i in range(dst_extent): # <<<<<<<<<<<<<< + * _copy_strided_to_strided(src_data, src_strides + 1, + * dst_data, dst_strides + 1, + */ + /*else*/ { + __pyx_t_4 = __pyx_v_dst_extent; + __pyx_t_5 = __pyx_t_4; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "View.MemoryView":1163 + * else: + * for i in range(dst_extent): + * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<< + * dst_data, dst_strides + 1, + * src_shape + 1, dst_shape + 1, + */ + _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize); + + /* "View.MemoryView":1167 + * src_shape + 1, dst_shape + 1, + * ndim - 1, itemsize) + * src_data += src_stride # <<<<<<<<<<<<<< + * dst_data += dst_stride + * + */ + __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); + + /* "View.MemoryView":1168 + * ndim - 1, itemsize) + * src_data += src_stride + * dst_data += dst_stride # <<<<<<<<<<<<<< + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, + */ + __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); + } + } + __pyx_L3:; + + /* "View.MemoryView":1140 + * + * @cython.cdivision(True) + * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< + * char *dst_data, Py_ssize_t *dst_strides, + * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, + */ + + /* function exit code */ +} + +/* "View.MemoryView":1170 + * dst_data += dst_stride + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + */ + +static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) { + + /* "View.MemoryView":1173 + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<< + * src.shape, dst.shape, ndim, itemsize) + * + */ + _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize); + + /* "View.MemoryView":1170 + * dst_data += dst_stride + * + * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *dst, + * int ndim, size_t itemsize) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1177 + * + * @cname('__pyx_memoryview_slice_get_size') + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef Py_ssize_t shape, size = src.memview.view.itemsize + */ + +static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) { + Py_ssize_t __pyx_v_shape; + Py_ssize_t __pyx_v_size; + Py_ssize_t __pyx_r; + Py_ssize_t __pyx_t_1; + Py_ssize_t *__pyx_t_2; + Py_ssize_t *__pyx_t_3; + Py_ssize_t *__pyx_t_4; + + /* "View.MemoryView":1179 + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef Py_ssize_t shape, size = src.memview.view.itemsize # <<<<<<<<<<<<<< + * + * for shape in src.shape[:ndim]: + */ + __pyx_t_1 = __pyx_v_src->memview->view.itemsize; + __pyx_v_size = __pyx_t_1; + + /* "View.MemoryView":1181 + * cdef Py_ssize_t shape, size = src.memview.view.itemsize + * + * for shape in src.shape[:ndim]: # <<<<<<<<<<<<<< + * size *= shape + * + */ + __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim); + for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { + __pyx_t_2 = __pyx_t_4; + __pyx_v_shape = (__pyx_t_2[0]); + + /* "View.MemoryView":1182 + * + * for shape in src.shape[:ndim]: + * size *= shape # <<<<<<<<<<<<<< + * + * return size + */ + __pyx_v_size = (__pyx_v_size * __pyx_v_shape); + } + + /* "View.MemoryView":1184 + * size *= shape + * + * return size # <<<<<<<<<<<<<< + * + * @cname('__pyx_fill_contig_strides_array') + */ + __pyx_r = __pyx_v_size; + goto __pyx_L0; + + /* "View.MemoryView":1177 + * + * @cname('__pyx_memoryview_slice_get_size') + * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< + * "Return the size of the memory occupied by the slice in number of bytes" + * cdef Py_ssize_t shape, size = src.memview.view.itemsize + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1187 + * + * @cname('__pyx_fill_contig_strides_array') + * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< + * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + * int ndim, char order) nogil: + */ + +static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) { + int __pyx_v_idx; + Py_ssize_t __pyx_r; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + + /* "View.MemoryView":1196 + * cdef int idx + * + * if order == 'F': # <<<<<<<<<<<<<< + * for idx in range(ndim): + * strides[idx] = stride + */ + __pyx_t_1 = ((__pyx_v_order == 'F') != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1197 + * + * if order == 'F': + * for idx in range(ndim): # <<<<<<<<<<<<<< + * strides[idx] = stride + * stride *= shape[idx] + */ + __pyx_t_2 = __pyx_v_ndim; + __pyx_t_3 = __pyx_t_2; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_idx = __pyx_t_4; + + /* "View.MemoryView":1198 + * if order == 'F': + * for idx in range(ndim): + * strides[idx] = stride # <<<<<<<<<<<<<< + * stride *= shape[idx] + * else: + */ + (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; + + /* "View.MemoryView":1199 + * for idx in range(ndim): + * strides[idx] = stride + * stride *= shape[idx] # <<<<<<<<<<<<<< + * else: + * for idx in range(ndim - 1, -1, -1): + */ + __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); + } + + /* "View.MemoryView":1196 + * cdef int idx + * + * if order == 'F': # <<<<<<<<<<<<<< + * for idx in range(ndim): + * strides[idx] = stride + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1201 + * stride *= shape[idx] + * else: + * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * strides[idx] = stride + * stride *= shape[idx] + */ + /*else*/ { + for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) { + __pyx_v_idx = __pyx_t_2; + + /* "View.MemoryView":1202 + * else: + * for idx in range(ndim - 1, -1, -1): + * strides[idx] = stride # <<<<<<<<<<<<<< + * stride *= shape[idx] + * + */ + (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; + + /* "View.MemoryView":1203 + * for idx in range(ndim - 1, -1, -1): + * strides[idx] = stride + * stride *= shape[idx] # <<<<<<<<<<<<<< + * + * return stride + */ + __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); + } + } + __pyx_L3:; + + /* "View.MemoryView":1205 + * stride *= shape[idx] + * + * return stride # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_data_to_temp') + */ + __pyx_r = __pyx_v_stride; + goto __pyx_L0; + + /* "View.MemoryView":1187 + * + * @cname('__pyx_fill_contig_strides_array') + * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< + * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, + * int ndim, char order) nogil: + */ + + /* function exit code */ + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1208 + * + * @cname('__pyx_memoryview_copy_data_to_temp') + * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *tmpslice, + * char order, + */ + +static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) { + int __pyx_v_i; + void *__pyx_v_result; + size_t __pyx_v_itemsize; + size_t __pyx_v_size; + void *__pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + struct __pyx_memoryview_obj *__pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + + /* "View.MemoryView":1219 + * cdef void *result + * + * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< + * cdef size_t size = slice_get_size(src, ndim) + * + */ + __pyx_t_1 = __pyx_v_src->memview->view.itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":1220 + * + * cdef size_t itemsize = src.memview.view.itemsize + * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<< + * + * result = malloc(size) + */ + __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim); + + /* "View.MemoryView":1222 + * cdef size_t size = slice_get_size(src, ndim) + * + * result = malloc(size) # <<<<<<<<<<<<<< + * if not result: + * _err(MemoryError, NULL) + */ + __pyx_v_result = malloc(__pyx_v_size); + + /* "View.MemoryView":1223 + * + * result = malloc(size) + * if not result: # <<<<<<<<<<<<<< + * _err(MemoryError, NULL) + * + */ + __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1224 + * result = malloc(size) + * if not result: + * _err(MemoryError, NULL) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1224, __pyx_L1_error) + + /* "View.MemoryView":1223 + * + * result = malloc(size) + * if not result: # <<<<<<<<<<<<<< + * _err(MemoryError, NULL) + * + */ + } + + /* "View.MemoryView":1227 + * + * + * tmpslice.data = result # <<<<<<<<<<<<<< + * tmpslice.memview = src.memview + * for i in range(ndim): + */ + __pyx_v_tmpslice->data = ((char *)__pyx_v_result); + + /* "View.MemoryView":1228 + * + * tmpslice.data = result + * tmpslice.memview = src.memview # <<<<<<<<<<<<<< + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] + */ + __pyx_t_4 = __pyx_v_src->memview; + __pyx_v_tmpslice->memview = __pyx_t_4; + + /* "View.MemoryView":1229 + * tmpslice.data = result + * tmpslice.memview = src.memview + * for i in range(ndim): # <<<<<<<<<<<<<< + * tmpslice.shape[i] = src.shape[i] + * tmpslice.suboffsets[i] = -1 + */ + __pyx_t_3 = __pyx_v_ndim; + __pyx_t_5 = __pyx_t_3; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "View.MemoryView":1230 + * tmpslice.memview = src.memview + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<< + * tmpslice.suboffsets[i] = -1 + * + */ + (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]); + + /* "View.MemoryView":1231 + * for i in range(ndim): + * tmpslice.shape[i] = src.shape[i] + * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * + * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, + */ + (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L; + } + + /* "View.MemoryView":1233 + * tmpslice.suboffsets[i] = -1 + * + * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<< + * ndim, order) + * + */ + (void)(__pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order)); + + /* "View.MemoryView":1237 + * + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if tmpslice.shape[i] == 1: + * tmpslice.strides[i] = 0 + */ + __pyx_t_3 = __pyx_v_ndim; + __pyx_t_5 = __pyx_t_3; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_i = __pyx_t_6; + + /* "View.MemoryView":1238 + * + * for i in range(ndim): + * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< + * tmpslice.strides[i] = 0 + * + */ + __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1239 + * for i in range(ndim): + * if tmpslice.shape[i] == 1: + * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<< + * + * if slice_is_contig(src[0], order, ndim): + */ + (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0; + + /* "View.MemoryView":1238 + * + * for i in range(ndim): + * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< + * tmpslice.strides[i] = 0 + * + */ + } + } + + /* "View.MemoryView":1241 + * tmpslice.strides[i] = 0 + * + * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< + * memcpy(result, src.data, size) + * else: + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1242 + * + * if slice_is_contig(src[0], order, ndim): + * memcpy(result, src.data, size) # <<<<<<<<<<<<<< + * else: + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) + */ + (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size)); + + /* "View.MemoryView":1241 + * tmpslice.strides[i] = 0 + * + * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< + * memcpy(result, src.data, size) + * else: + */ + goto __pyx_L9; + } + + /* "View.MemoryView":1244 + * memcpy(result, src.data, size) + * else: + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<< + * + * return result + */ + /*else*/ { + copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize); + } + __pyx_L9:; + + /* "View.MemoryView":1246 + * copy_strided_to_strided(src, tmpslice, ndim, itemsize) + * + * return result # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + /* "View.MemoryView":1208 + * + * @cname('__pyx_memoryview_copy_data_to_temp') + * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice *tmpslice, + * char order, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = NULL; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1251 + * + * @cname('__pyx_memoryview_err_extents') + * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + */ + +static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err_extents", 0); + + /* "View.MemoryView":1254 + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + * (i, extent1, extent2)) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_err_dim') + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1254, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1254, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1254, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1254, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + + /* "View.MemoryView":1253 + * cdef int _err_extents(int i, Py_ssize_t extent1, + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<< + * (i, extent1, extent2)) + * + */ + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1253, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1253, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 1253, __pyx_L1_error) + + /* "View.MemoryView":1251 + * + * @cname('__pyx_memoryview_err_extents') + * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< + * Py_ssize_t extent2) except -1 with gil: + * raise ValueError("got differing extents in dimension %d (got %d and %d)" % + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "View.MemoryView":1257 + * + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii') % dim) + * + */ + +static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err_dim", 0); + __Pyx_INCREF(__pyx_v_error); + + /* "View.MemoryView":1258 + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: + * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_err') + */ + __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_v_error); + __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); + __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1258, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __PYX_ERR(1, 1258, __pyx_L1_error) + + /* "View.MemoryView":1257 + * + * @cname('__pyx_memoryview_err_dim') + * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii') % dim) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_XDECREF(__pyx_v_error); + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "View.MemoryView":1261 + * + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< + * if msg != NULL: + * raise error(msg.decode('ascii')) + */ + +static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("_err", 0); + __Pyx_INCREF(__pyx_v_error); + + /* "View.MemoryView":1262 + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii')) + * else: + */ + __pyx_t_1 = ((__pyx_v_msg != NULL) != 0); + if (unlikely(__pyx_t_1)) { + + /* "View.MemoryView":1263 + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: + * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<< + * else: + * raise error + */ + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_error); + __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1263, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __PYX_ERR(1, 1263, __pyx_L1_error) + + /* "View.MemoryView":1262 + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: + * if msg != NULL: # <<<<<<<<<<<<<< + * raise error(msg.decode('ascii')) + * else: + */ + } + + /* "View.MemoryView":1265 + * raise error(msg.decode('ascii')) + * else: + * raise error # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_copy_contents') + */ + /*else*/ { + __Pyx_Raise(__pyx_v_error, 0, 0, 0); + __PYX_ERR(1, 1265, __pyx_L1_error) + } + + /* "View.MemoryView":1261 + * + * @cname('__pyx_memoryview_err') + * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< + * if msg != NULL: + * raise error(msg.decode('ascii')) + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __Pyx_XDECREF(__pyx_v_error); + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + return __pyx_r; +} + +/* "View.MemoryView":1268 + * + * @cname('__pyx_memoryview_copy_contents') + * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice dst, + * int src_ndim, int dst_ndim, + */ + +static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) { + void *__pyx_v_tmpdata; + size_t __pyx_v_itemsize; + int __pyx_v_i; + char __pyx_v_order; + int __pyx_v_broadcasting; + int __pyx_v_direct_copy; + __Pyx_memviewslice __pyx_v_tmp; + int __pyx_v_ndim; + int __pyx_r; + Py_ssize_t __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + void *__pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + + /* "View.MemoryView":1276 + * Check for overlapping memory and verify the shapes. + * """ + * cdef void *tmpdata = NULL # <<<<<<<<<<<<<< + * cdef size_t itemsize = src.memview.view.itemsize + * cdef int i + */ + __pyx_v_tmpdata = NULL; + + /* "View.MemoryView":1277 + * """ + * cdef void *tmpdata = NULL + * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) + */ + __pyx_t_1 = __pyx_v_src.memview->view.itemsize; + __pyx_v_itemsize = __pyx_t_1; + + /* "View.MemoryView":1279 + * cdef size_t itemsize = src.memview.view.itemsize + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<< + * cdef bint broadcasting = False + * cdef bint direct_copy = False + */ + __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim); + + /* "View.MemoryView":1280 + * cdef int i + * cdef char order = get_best_order(&src, src_ndim) + * cdef bint broadcasting = False # <<<<<<<<<<<<<< + * cdef bint direct_copy = False + * cdef __Pyx_memviewslice tmp + */ + __pyx_v_broadcasting = 0; + + /* "View.MemoryView":1281 + * cdef char order = get_best_order(&src, src_ndim) + * cdef bint broadcasting = False + * cdef bint direct_copy = False # <<<<<<<<<<<<<< + * cdef __Pyx_memviewslice tmp + * + */ + __pyx_v_direct_copy = 0; + + /* "View.MemoryView":1284 + * cdef __Pyx_memviewslice tmp + * + * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + */ + __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1285 + * + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<< + * elif dst_ndim < src_ndim: + * broadcast_leading(&dst, dst_ndim, src_ndim) + */ + __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim); + + /* "View.MemoryView":1284 + * cdef __Pyx_memviewslice tmp + * + * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1286 + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&dst, dst_ndim, src_ndim) + * + */ + __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1287 + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: + * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<< + * + * cdef int ndim = max(src_ndim, dst_ndim) + */ + __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim); + + /* "View.MemoryView":1286 + * if src_ndim < dst_ndim: + * broadcast_leading(&src, src_ndim, dst_ndim) + * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< + * broadcast_leading(&dst, dst_ndim, src_ndim) + * + */ + } + __pyx_L3:; + + /* "View.MemoryView":1289 + * broadcast_leading(&dst, dst_ndim, src_ndim) + * + * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<< + * + * for i in range(ndim): + */ + __pyx_t_3 = __pyx_v_dst_ndim; + __pyx_t_4 = __pyx_v_src_ndim; + if (((__pyx_t_3 > __pyx_t_4) != 0)) { + __pyx_t_5 = __pyx_t_3; + } else { + __pyx_t_5 = __pyx_t_4; + } + __pyx_v_ndim = __pyx_t_5; + + /* "View.MemoryView":1291 + * cdef int ndim = max(src_ndim, dst_ndim) + * + * for i in range(ndim): # <<<<<<<<<<<<<< + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: + */ + __pyx_t_5 = __pyx_v_ndim; + __pyx_t_3 = __pyx_t_5; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "View.MemoryView":1292 + * + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< + * if src.shape[i] == 1: + * broadcasting = True + */ + __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1293 + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: # <<<<<<<<<<<<<< + * broadcasting = True + * src.strides[i] = 0 + */ + __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1294 + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: + * broadcasting = True # <<<<<<<<<<<<<< + * src.strides[i] = 0 + * else: + */ + __pyx_v_broadcasting = 1; + + /* "View.MemoryView":1295 + * if src.shape[i] == 1: + * broadcasting = True + * src.strides[i] = 0 # <<<<<<<<<<<<<< + * else: + * _err_extents(i, dst.shape[i], src.shape[i]) + */ + (__pyx_v_src.strides[__pyx_v_i]) = 0; + + /* "View.MemoryView":1293 + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: + * if src.shape[i] == 1: # <<<<<<<<<<<<<< + * broadcasting = True + * src.strides[i] = 0 + */ + goto __pyx_L7; + } + + /* "View.MemoryView":1297 + * src.strides[i] = 0 + * else: + * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<< + * + * if src.suboffsets[i] >= 0: + */ + /*else*/ { + __pyx_t_6 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1297, __pyx_L1_error) + } + __pyx_L7:; + + /* "View.MemoryView":1292 + * + * for i in range(ndim): + * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< + * if src.shape[i] == 1: + * broadcasting = True + */ + } + + /* "View.MemoryView":1299 + * _err_extents(i, dst.shape[i], src.shape[i]) + * + * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + */ + __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1300 + * + * if src.suboffsets[i] >= 0: + * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<< + * + * if slices_overlap(&src, &dst, ndim, itemsize): + */ + __pyx_t_6 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1300, __pyx_L1_error) + + /* "View.MemoryView":1299 + * _err_extents(i, dst.shape[i], src.shape[i]) + * + * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + */ + } + } + + /* "View.MemoryView":1302 + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< + * + * if not slice_is_contig(src, order, ndim): + */ + __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1304 + * if slices_overlap(&src, &dst, ndim, itemsize): + * + * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< + * order = get_best_order(&dst, ndim) + * + */ + __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1305 + * + * if not slice_is_contig(src, order, ndim): + * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<< + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + */ + __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim); + + /* "View.MemoryView":1304 + * if slices_overlap(&src, &dst, ndim, itemsize): + * + * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< + * order = get_best_order(&dst, ndim) + * + */ + } + + /* "View.MemoryView":1307 + * order = get_best_order(&dst, ndim) + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<< + * src = tmp + * + */ + __pyx_t_7 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(1, 1307, __pyx_L1_error) + __pyx_v_tmpdata = __pyx_t_7; + + /* "View.MemoryView":1308 + * + * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) + * src = tmp # <<<<<<<<<<<<<< + * + * if not broadcasting: + */ + __pyx_v_src = __pyx_v_tmp; + + /* "View.MemoryView":1302 + * _err_dim(ValueError, "Dimension %d is not direct", i) + * + * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< + * + * if not slice_is_contig(src, order, ndim): + */ + } + + /* "View.MemoryView":1310 + * src = tmp + * + * if not broadcasting: # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1313 + * + * + * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1314 + * + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<< + * elif slice_is_contig(src, 'F', ndim): + * direct_copy = slice_is_contig(dst, 'F', ndim) + */ + __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim); + + /* "View.MemoryView":1313 + * + * + * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + */ + goto __pyx_L12; + } + + /* "View.MemoryView":1315 + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + */ + __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1316 + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): + * direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<< + * + * if direct_copy: + */ + __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim); + + /* "View.MemoryView":1315 + * if slice_is_contig(src, 'C', ndim): + * direct_copy = slice_is_contig(dst, 'C', ndim) + * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + */ + } + __pyx_L12:; + + /* "View.MemoryView":1318 + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + * if direct_copy: # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + __pyx_t_2 = (__pyx_v_direct_copy != 0); + if (__pyx_t_2) { + + /* "View.MemoryView":1320 + * if direct_copy: + * + * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1321 + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<< + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) + */ + (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim))); + + /* "View.MemoryView":1322 + * refcount_copying(&dst, dtype_is_object, ndim, False) + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * free(tmpdata) + * return 0 + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1323 + * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) # <<<<<<<<<<<<<< + * return 0 + * + */ + free(__pyx_v_tmpdata); + + /* "View.MemoryView":1324 + * refcount_copying(&dst, dtype_is_object, ndim, True) + * free(tmpdata) + * return 0 # <<<<<<<<<<<<<< + * + * if order == 'F' == get_best_order(&dst, ndim): + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":1318 + * direct_copy = slice_is_contig(dst, 'F', ndim) + * + * if direct_copy: # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + } + + /* "View.MemoryView":1310 + * src = tmp + * + * if not broadcasting: # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":1326 + * return 0 + * + * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = (__pyx_v_order == 'F'); + if (__pyx_t_2) { + __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim)); + } + __pyx_t_8 = (__pyx_t_2 != 0); + if (__pyx_t_8) { + + /* "View.MemoryView":1329 + * + * + * transpose_memslice(&src) # <<<<<<<<<<<<<< + * transpose_memslice(&dst) + * + */ + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1329, __pyx_L1_error) + + /* "View.MemoryView":1330 + * + * transpose_memslice(&src) + * transpose_memslice(&dst) # <<<<<<<<<<<<<< + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + */ + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1330, __pyx_L1_error) + + /* "View.MemoryView":1326 + * return 0 + * + * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< + * + * + */ + } + + /* "View.MemoryView":1332 + * transpose_memslice(&dst) + * + * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * copy_strided_to_strided(&src, &dst, ndim, itemsize) + * refcount_copying(&dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1333 + * + * refcount_copying(&dst, dtype_is_object, ndim, False) + * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<< + * refcount_copying(&dst, dtype_is_object, ndim, True) + * + */ + copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize); + + /* "View.MemoryView":1334 + * refcount_copying(&dst, dtype_is_object, ndim, False) + * copy_strided_to_strided(&src, &dst, ndim, itemsize) + * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * + * free(tmpdata) + */ + __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1336 + * refcount_copying(&dst, dtype_is_object, ndim, True) + * + * free(tmpdata) # <<<<<<<<<<<<<< + * return 0 + * + */ + free(__pyx_v_tmpdata); + + /* "View.MemoryView":1337 + * + * free(tmpdata) + * return 0 # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_broadcast_leading') + */ + __pyx_r = 0; + goto __pyx_L0; + + /* "View.MemoryView":1268 + * + * @cname('__pyx_memoryview_copy_contents') + * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< + * __Pyx_memviewslice dst, + * int src_ndim, int dst_ndim, + */ + + /* function exit code */ + __pyx_L1_error:; + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + } + __pyx_r = -1; + __pyx_L0:; + return __pyx_r; +} + +/* "View.MemoryView":1340 + * + * @cname('__pyx_memoryview_broadcast_leading') + * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * int ndim, + * int ndim_other) nogil: + */ + +static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) { + int __pyx_v_i; + int __pyx_v_offset; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + + /* "View.MemoryView":1344 + * int ndim_other) nogil: + * cdef int i + * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<< + * + * for i in range(ndim - 1, -1, -1): + */ + __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim); + + /* "View.MemoryView":1346 + * cdef int offset = ndim_other - ndim + * + * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] + */ + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { + __pyx_v_i = __pyx_t_1; + + /* "View.MemoryView":1347 + * + * for i in range(ndim - 1, -1, -1): + * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<< + * mslice.strides[i + offset] = mslice.strides[i] + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + */ + (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]); + + /* "View.MemoryView":1348 + * for i in range(ndim - 1, -1, -1): + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<< + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * + */ + (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]); + + /* "View.MemoryView":1349 + * mslice.shape[i + offset] = mslice.shape[i] + * mslice.strides[i + offset] = mslice.strides[i] + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<< + * + * for i in range(offset): + */ + (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]); + } + + /* "View.MemoryView":1351 + * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * + * for i in range(offset): # <<<<<<<<<<<<<< + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] + */ + __pyx_t_1 = __pyx_v_offset; + __pyx_t_2 = __pyx_t_1; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1352 + * + * for i in range(offset): + * mslice.shape[i] = 1 # <<<<<<<<<<<<<< + * mslice.strides[i] = mslice.strides[0] + * mslice.suboffsets[i] = -1 + */ + (__pyx_v_mslice->shape[__pyx_v_i]) = 1; + + /* "View.MemoryView":1353 + * for i in range(offset): + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<< + * mslice.suboffsets[i] = -1 + * + */ + (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]); + + /* "View.MemoryView":1354 + * mslice.shape[i] = 1 + * mslice.strides[i] = mslice.strides[0] + * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L; + } + + /* "View.MemoryView":1340 + * + * @cname('__pyx_memoryview_broadcast_leading') + * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * int ndim, + * int ndim_other) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1362 + * + * @cname('__pyx_memoryview_refcount_copying') + * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< + * int ndim, bint inc) nogil: + * + */ + +static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) { + int __pyx_t_1; + + /* "View.MemoryView":1366 + * + * + * if dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, + * dst.strides, ndim, inc) + */ + __pyx_t_1 = (__pyx_v_dtype_is_object != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1367 + * + * if dtype_is_object: + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<< + * dst.strides, ndim, inc) + * + */ + __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc); + + /* "View.MemoryView":1366 + * + * + * if dtype_is_object: # <<<<<<<<<<<<<< + * refcount_objects_in_slice_with_gil(dst.data, dst.shape, + * dst.strides, ndim, inc) + */ + } + + /* "View.MemoryView":1362 + * + * @cname('__pyx_memoryview_refcount_copying') + * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< + * int ndim, bint inc) nogil: + * + */ + + /* function exit code */ +} + +/* "View.MemoryView":1371 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') + * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + */ + +static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { + __Pyx_RefNannyDeclarations + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); + + /* "View.MemoryView":1374 + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<< + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc); + + /* "View.MemoryView":1371 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') + * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * bint inc) with gil: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif +} + +/* "View.MemoryView":1377 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, bint inc): + * cdef Py_ssize_t i + */ + +static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + __Pyx_RefNannyDeclarations + Py_ssize_t __pyx_t_1; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0); + + /* "View.MemoryView":1381 + * cdef Py_ssize_t i + * + * for i in range(shape[0]): # <<<<<<<<<<<<<< + * if ndim == 1: + * if inc: + */ + __pyx_t_1 = (__pyx_v_shape[0]); + __pyx_t_2 = __pyx_t_1; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + + /* "View.MemoryView":1382 + * + * for i in range(shape[0]): + * if ndim == 1: # <<<<<<<<<<<<<< + * if inc: + * Py_INCREF(( data)[0]) + */ + __pyx_t_4 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":1383 + * for i in range(shape[0]): + * if ndim == 1: + * if inc: # <<<<<<<<<<<<<< + * Py_INCREF(( data)[0]) + * else: + */ + __pyx_t_4 = (__pyx_v_inc != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":1384 + * if ndim == 1: + * if inc: + * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<< + * else: + * Py_DECREF(( data)[0]) + */ + Py_INCREF((((PyObject **)__pyx_v_data)[0])); + + /* "View.MemoryView":1383 + * for i in range(shape[0]): + * if ndim == 1: + * if inc: # <<<<<<<<<<<<<< + * Py_INCREF(( data)[0]) + * else: + */ + goto __pyx_L6; + } + + /* "View.MemoryView":1386 + * Py_INCREF(( data)[0]) + * else: + * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<< + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, + */ + /*else*/ { + Py_DECREF((((PyObject **)__pyx_v_data)[0])); + } + __pyx_L6:; + + /* "View.MemoryView":1382 + * + * for i in range(shape[0]): + * if ndim == 1: # <<<<<<<<<<<<<< + * if inc: + * Py_INCREF(( data)[0]) + */ + goto __pyx_L5; + } + + /* "View.MemoryView":1388 + * Py_DECREF(( data)[0]) + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< + * ndim - 1, inc) + * + */ + /*else*/ { + + /* "View.MemoryView":1389 + * else: + * refcount_objects_in_slice(data, shape + 1, strides + 1, + * ndim - 1, inc) # <<<<<<<<<<<<<< + * + * data += strides[0] + */ + __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc); + } + __pyx_L5:; + + /* "View.MemoryView":1391 + * ndim - 1, inc) + * + * data += strides[0] # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); + } + + /* "View.MemoryView":1377 + * + * @cname('__pyx_memoryview_refcount_objects_in_slice') + * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, bint inc): + * cdef Py_ssize_t i + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "View.MemoryView":1397 + * + * @cname('__pyx_memoryview_slice_assign_scalar') + * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + */ + +static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) { + + /* "View.MemoryView":1400 + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + * itemsize, item) + */ + __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0); + + /* "View.MemoryView":1401 + * bint dtype_is_object) nogil: + * refcount_copying(dst, dtype_is_object, ndim, False) + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<< + * itemsize, item) + * refcount_copying(dst, dtype_is_object, ndim, True) + */ + __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item); + + /* "View.MemoryView":1403 + * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, + * itemsize, item) + * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< + * + * + */ + __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1); + + /* "View.MemoryView":1397 + * + * @cname('__pyx_memoryview_slice_assign_scalar') + * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< + * size_t itemsize, void *item, + * bint dtype_is_object) nogil: + */ + + /* function exit code */ +} + +/* "View.MemoryView":1407 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + +static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) { + CYTHON_UNUSED Py_ssize_t __pyx_v_i; + Py_ssize_t __pyx_v_stride; + Py_ssize_t __pyx_v_extent; + int __pyx_t_1; + Py_ssize_t __pyx_t_2; + Py_ssize_t __pyx_t_3; + Py_ssize_t __pyx_t_4; + + /* "View.MemoryView":1411 + * size_t itemsize, void *item) nogil: + * cdef Py_ssize_t i + * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<< + * cdef Py_ssize_t extent = shape[0] + * + */ + __pyx_v_stride = (__pyx_v_strides[0]); + + /* "View.MemoryView":1412 + * cdef Py_ssize_t i + * cdef Py_ssize_t stride = strides[0] + * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<< + * + * if ndim == 1: + */ + __pyx_v_extent = (__pyx_v_shape[0]); + + /* "View.MemoryView":1414 + * cdef Py_ssize_t extent = shape[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * for i in range(extent): + * memcpy(data, item, itemsize) + */ + __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); + if (__pyx_t_1) { + + /* "View.MemoryView":1415 + * + * if ndim == 1: + * for i in range(extent): # <<<<<<<<<<<<<< + * memcpy(data, item, itemsize) + * data += stride + */ + __pyx_t_2 = __pyx_v_extent; + __pyx_t_3 = __pyx_t_2; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "View.MemoryView":1416 + * if ndim == 1: + * for i in range(extent): + * memcpy(data, item, itemsize) # <<<<<<<<<<<<<< + * data += stride + * else: + */ + (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize)); + + /* "View.MemoryView":1417 + * for i in range(extent): + * memcpy(data, item, itemsize) + * data += stride # <<<<<<<<<<<<<< + * else: + * for i in range(extent): + */ + __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + } + + /* "View.MemoryView":1414 + * cdef Py_ssize_t extent = shape[0] + * + * if ndim == 1: # <<<<<<<<<<<<<< + * for i in range(extent): + * memcpy(data, item, itemsize) + */ + goto __pyx_L3; + } + + /* "View.MemoryView":1419 + * data += stride + * else: + * for i in range(extent): # <<<<<<<<<<<<<< + * _slice_assign_scalar(data, shape + 1, strides + 1, + * ndim - 1, itemsize, item) + */ + /*else*/ { + __pyx_t_2 = __pyx_v_extent; + __pyx_t_3 = __pyx_t_2; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + + /* "View.MemoryView":1420 + * else: + * for i in range(extent): + * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< + * ndim - 1, itemsize, item) + * data += stride + */ + __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item); + + /* "View.MemoryView":1422 + * _slice_assign_scalar(data, shape + 1, strides + 1, + * ndim - 1, itemsize, item) + * data += stride # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_data = (__pyx_v_data + __pyx_v_stride); + } + } + __pyx_L3:; + + /* "View.MemoryView":1407 + * + * @cname('__pyx_memoryview__slice_assign_scalar') + * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< + * Py_ssize_t *strides, int ndim, + * size_t itemsize, void *item) nogil: + */ + + /* function exit code */ +} + +/* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * cdef object __pyx_PickleError + * cdef object __pyx_result + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v___pyx_type = 0; + long __pyx_v___pyx_checksum; + PyObject *__pyx_v___pyx_state = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; + case 1: + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error) + } + CYTHON_FALLTHROUGH; + case 2: + if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error) + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(1, 1, __pyx_L3_error) + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v___pyx_type = values[0]; + __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error) + __pyx_v___pyx_state = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error) + __pyx_L3_error:; + __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_v___pyx_PickleError = 0; + PyObject *__pyx_v___pyx_result = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0); + + /* "(tree fragment)":4 + * cdef object __pyx_PickleError + * cdef object __pyx_result + * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): # <<<<<<<<<<<<<< + * from pickle import PickleError as __pyx_PickleError + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) + */ + __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__19, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = (__pyx_t_2 != 0); + if (__pyx_t_3) { + + /* "(tree fragment)":5 + * cdef object __pyx_result + * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): + * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<< + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) + * __pyx_result = Enum.__new__(__pyx_type) + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_PickleError); + __Pyx_GIVEREF(__pyx_n_s_PickleError); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError); + __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_1); + __pyx_v___pyx_PickleError = __pyx_t_1; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "(tree fragment)":6 + * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): + * from pickle import PickleError as __pyx_PickleError + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) # <<<<<<<<<<<<<< + * __pyx_result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: + */ + __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_INCREF(__pyx_v___pyx_PickleError); + __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __PYX_ERR(1, 6, __pyx_L1_error) + + /* "(tree fragment)":4 + * cdef object __pyx_PickleError + * cdef object __pyx_result + * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): # <<<<<<<<<<<<<< + * from pickle import PickleError as __pyx_PickleError + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) + */ + } + + /* "(tree fragment)":7 + * from pickle import PickleError as __pyx_PickleError + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) + * __pyx_result = Enum.__new__(__pyx_type) # <<<<<<<<<<<<<< + * if __pyx_state is not None: + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type); + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v___pyx_result = __pyx_t_4; + __pyx_t_4 = 0; + + /* "(tree fragment)":8 + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) + * __pyx_result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + * return __pyx_result + */ + __pyx_t_3 = (__pyx_v___pyx_state != Py_None); + __pyx_t_2 = (__pyx_t_3 != 0); + if (__pyx_t_2) { + + /* "(tree fragment)":9 + * __pyx_result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< + * return __pyx_result + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): + */ + if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error) + __pyx_t_4 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "(tree fragment)":8 + * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) + * __pyx_result = Enum.__new__(__pyx_type) + * if __pyx_state is not None: # <<<<<<<<<<<<<< + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + * return __pyx_result + */ + } + + /* "(tree fragment)":10 + * if __pyx_state is not None: + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + * return __pyx_result # <<<<<<<<<<<<<< + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): + * __pyx_result.name = __pyx_state[0] + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v___pyx_result); + __pyx_r = __pyx_v___pyx_result; + goto __pyx_L0; + + /* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * cdef object __pyx_PickleError + * cdef object __pyx_result + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v___pyx_PickleError); + __Pyx_XDECREF(__pyx_v___pyx_result); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "(tree fragment)":11 + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + * return __pyx_result + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< + * __pyx_result.name = __pyx_state[0] + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): + */ + +static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0); + + /* "(tree fragment)":12 + * return __pyx_result + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): + * __pyx_result.name = __pyx_state[0] # <<<<<<<<<<<<<< + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): + * __pyx_result.__dict__.update(__pyx_state[1]) + */ + if (unlikely(__pyx_v___pyx_state == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 12, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v___pyx_result->name); + __Pyx_DECREF(__pyx_v___pyx_result->name); + __pyx_v___pyx_result->name = __pyx_t_1; + __pyx_t_1 = 0; + + /* "(tree fragment)":13 + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): + * __pyx_result.name = __pyx_state[0] + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< + * __pyx_result.__dict__.update(__pyx_state[1]) + */ + if (unlikely(__pyx_v___pyx_state == Py_None)) { + PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); + __PYX_ERR(1, 13, __pyx_L1_error) + } + __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error) + __pyx_t_4 = ((__pyx_t_3 > 1) != 0); + if (__pyx_t_4) { + } else { + __pyx_t_2 = __pyx_t_4; + goto __pyx_L4_bool_binop_done; + } + __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error) + __pyx_t_5 = (__pyx_t_4 != 0); + __pyx_t_2 = __pyx_t_5; + __pyx_L4_bool_binop_done:; + if (__pyx_t_2) { + + /* "(tree fragment)":14 + * __pyx_result.name = __pyx_state[0] + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): + * __pyx_result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<< + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(__pyx_v___pyx_state == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + __PYX_ERR(1, 14, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_8 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "(tree fragment)":13 + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): + * __pyx_result.name = __pyx_state[0] + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< + * __pyx_result.__dict__.update(__pyx_state[1]) + */ + } + + /* "(tree fragment)":11 + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + * return __pyx_result + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< + * __pyx_result.name = __pyx_state[0] + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): + */ + + /* function exit code */ + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_array __pyx_vtable_array; + +static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_array_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_array_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_array; + p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_array(PyObject *o) { + struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_array___dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->mode); + Py_CLEAR(p->_format); + (*Py_TYPE(o)->tp_free)(o); +} +static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_array___setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) { + PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n); + if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + v = __pyx_array___getattr__(o, n); + } + return v; +} + +static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o); +} + +static PyMethodDef __pyx_methods_array[] = { + {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_array[] = { + {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_array = { + __pyx_array___len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_array, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_array = { + __pyx_array___len__, /*mp_length*/ + __pyx_array___getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_array = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + __pyx_array_getbuffer, /*bf_getbuffer*/ + 0, /*bf_releasebuffer*/ +}; + +static PyTypeObject __pyx_type___pyx_array = { + PyVarObject_HEAD_INIT(0, 0) + "strings_udf._lib.cudf_jit_udf.array", /*tp_name*/ + sizeof(struct __pyx_array_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_array, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_array, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_array, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + __pyx_tp_getattro_array, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_array, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_array, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_array, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_array, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_MemviewEnum_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_MemviewEnum_obj *)o); + p->name = Py_None; Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_Enum(PyObject *o) { + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->name); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + if (p->name) { + e = (*v)(p->name, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_Enum(PyObject *o) { + PyObject* tmp; + struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; + tmp = ((PyObject*)p->name); + p->name = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_Enum[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type___pyx_MemviewEnum = { + PyVarObject_HEAD_INIT(0, 0) + "strings_udf._lib.cudf_jit_udf.Enum", /*tp_name*/ + sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_Enum, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_MemviewEnum___repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_Enum, /*tp_traverse*/ + __pyx_tp_clear_Enum, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_Enum, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_MemviewEnum___init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_Enum, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview; + +static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_memoryview_obj *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_memoryview_obj *)o); + p->__pyx_vtab = __pyx_vtabptr_memoryview; + p->obj = Py_None; Py_INCREF(Py_None); + p->_size = Py_None; Py_INCREF(Py_None); + p->_array_interface = Py_None; Py_INCREF(Py_None); + p->view.obj = NULL; + if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad; + return o; + bad: + Py_DECREF(o); o = 0; + return NULL; +} + +static void __pyx_tp_dealloc_memoryview(PyObject *o) { + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_memoryview___dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->obj); + Py_CLEAR(p->_size); + Py_CLEAR(p->_array_interface); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + if (p->obj) { + e = (*v)(p->obj, a); if (e) return e; + } + if (p->_size) { + e = (*v)(p->_size, a); if (e) return e; + } + if (p->_array_interface) { + e = (*v)(p->_array_interface, a); if (e) return e; + } + if (p->view.obj) { + e = (*v)(p->view.obj, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_memoryview(PyObject *o) { + PyObject* tmp; + struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; + tmp = ((PyObject*)p->obj); + p->obj = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_size); + p->_size = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->_array_interface); + p->_array_interface = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + Py_CLEAR(p->view.obj); + return 0; +} +static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_memoryview___setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o); +} + +static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o); +} + +static PyMethodDef __pyx_methods_memoryview[] = { + {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0}, + {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0}, + {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0}, + {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0}, + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_memoryview[] = { + {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0}, + {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0}, + {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0}, + {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0}, + {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0}, + {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0}, + {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0}, + {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0}, + {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PySequenceMethods __pyx_tp_as_sequence_memoryview = { + __pyx_memoryview___len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_memoryview, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_memoryview = { + __pyx_memoryview___len__, /*mp_length*/ + __pyx_memoryview___getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_memoryview = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + __pyx_memoryview_getbuffer, /*bf_getbuffer*/ + 0, /*bf_releasebuffer*/ +}; + +static PyTypeObject __pyx_type___pyx_memoryview = { + PyVarObject_HEAD_INIT(0, 0) + "strings_udf._lib.cudf_jit_udf.memoryview", /*tp_name*/ + sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_memoryview, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + __pyx_memoryview___repr__, /*tp_repr*/ + 0, /*tp_as_number*/ + &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_memoryview___str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_memoryview, /*tp_traverse*/ + __pyx_tp_clear_memoryview, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_memoryview, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_memoryview, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_memoryview, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; +static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice; + +static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_memoryviewslice_obj *p; + PyObject *o = __pyx_tp_new_memoryview(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_memoryviewslice_obj *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice; + p->from_object = Py_None; Py_INCREF(Py_None); + p->from_slice.memview = NULL; + return o; +} + +static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) { + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + #if CYTHON_USE_TP_FINALIZE + if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); + __pyx_memoryviewslice___dealloc__(o); + __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); + PyErr_Restore(etype, eval, etb); + } + Py_CLEAR(p->from_object); + PyObject_GC_Track(o); + __pyx_tp_dealloc_memoryview(o); +} + +static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e; + if (p->from_object) { + e = (*v)(p->from_object, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear__memoryviewslice(PyObject *o) { + PyObject* tmp; + struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; + __pyx_tp_clear_memoryview(o); + tmp = ((PyObject*)p->from_object); + p->from_object = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + __PYX_XDEC_MEMVIEW(&p->from_slice, 1); + return 0; +} + +static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o); +} + +static PyMethodDef __pyx_methods__memoryviewslice[] = { + {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0}, + {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = { + {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type___pyx_memoryviewslice = { + PyVarObject_HEAD_INIT(0, 0) + "strings_udf._lib.cudf_jit_udf._memoryviewslice", /*tp_name*/ + sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/ + #if PY_VERSION_HEX < 0x030800b4 + 0, /*tp_print*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 + 0, /*tp_vectorcall_offset*/ + #endif + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #endif + #if PY_MAJOR_VERSION >= 3 + 0, /*tp_as_async*/ + #endif + #if CYTHON_COMPILING_IN_PYPY + __pyx_memoryview___repr__, /*tp_repr*/ + #else + 0, /*tp_repr*/ + #endif + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + #if CYTHON_COMPILING_IN_PYPY + __pyx_memoryview___str__, /*tp_str*/ + #else + 0, /*tp_str*/ + #endif + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "Internal class for passing memoryview slices to Python", /*tp_doc*/ + __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/ + __pyx_tp_clear__memoryviewslice, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods__memoryviewslice, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets__memoryviewslice, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new__memoryviewslice, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif + #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) + 0, /*tp_vectorcall*/ + #endif + #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 + 0, /*tp_print*/ + #endif + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 + 0, /*tp_pypy_flags*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_cudf_jit_udf(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_cudf_jit_udf}, + {0, NULL} +}; +#endif + +static struct PyModuleDef __pyx_moduledef = { + PyModuleDef_HEAD_INIT, + "cudf_jit_udf", + 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else + -1, /* m_size */ + #endif + __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else + NULL, /* m_reload */ + #endif + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) + #define CYTHON_SMALL_CODE __attribute__((cold)) +#else + #define CYTHON_SMALL_CODE +#endif +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1}, + {&__pyx_n_s_Buffer, __pyx_k_Buffer, sizeof(__pyx_k_Buffer), 0, 0, 1, 1}, + {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0}, + {&__pyx_n_u_CONDA_PREFIX, __pyx_k_CONDA_PREFIX, sizeof(__pyx_k_CONDA_PREFIX), 0, 1, 0, 1}, + {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0}, + {&__pyx_kp_s_Cannot_assign_to_read_only_memor, __pyx_k_Cannot_assign_to_read_only_memor, sizeof(__pyx_k_Cannot_assign_to_read_only_memor), 0, 0, 1, 0}, + {&__pyx_kp_s_Cannot_create_writable_memory_vi, __pyx_k_Cannot_create_writable_memory_vi, sizeof(__pyx_k_Cannot_create_writable_memory_vi), 0, 0, 1, 0}, + {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0}, + {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1}, + {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0}, + {&__pyx_kp_u_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 1, 0, 0}, + {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0}, + {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, + {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0}, + {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0}, + {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, + {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0}, + {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0}, + {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1}, + {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0}, + {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1}, + {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, + {&__pyx_kp_u_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 1, 0, 0}, + {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1}, + {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, + {&__pyx_n_s_buffer, __pyx_k_buffer, sizeof(__pyx_k_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, + {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, + {&__pyx_n_s_c_buffer, __pyx_k_c_buffer, sizeof(__pyx_k_c_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_c_columns, __pyx_k_c_columns, sizeof(__pyx_k_c_columns), 0, 0, 1, 1}, + {&__pyx_n_s_c_module, __pyx_k_c_module, sizeof(__pyx_k_c_module), 0, 0, 1, 1}, + {&__pyx_n_s_c_name, __pyx_k_c_name, sizeof(__pyx_k_c_name), 0, 0, 1, 1}, + {&__pyx_n_s_c_options, __pyx_k_c_options, sizeof(__pyx_k_c_options), 0, 0, 1, 1}, + {&__pyx_n_s_c_result, __pyx_k_c_result, sizeof(__pyx_k_c_result), 0, 0, 1, 1}, + {&__pyx_n_s_c_size, __pyx_k_c_size, sizeof(__pyx_k_c_size), 0, 0, 1, 1}, + {&__pyx_n_s_c_udf, __pyx_k_c_udf, sizeof(__pyx_k_c_udf), 0, 0, 1, 1}, + {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, + {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, + {&__pyx_n_s_cols, __pyx_k_cols, sizeof(__pyx_k_cols), 0, 0, 1, 1}, + {&__pyx_n_s_column, __pyx_k_column, sizeof(__pyx_k_column), 0, 0, 1, 1}, + {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, + {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_cudf_core_buffer, __pyx_k_cudf_core_buffer, sizeof(__pyx_k_cudf_core_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_d_buffer, __pyx_k_d_buffer, sizeof(__pyx_k_d_buffer), 0, 0, 1, 1}, + {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, + {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, + {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, + {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, + {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, + {&__pyx_n_s_environ, __pyx_k_environ, sizeof(__pyx_k_environ), 0, 0, 1, 1}, + {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, + {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, + {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, + {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, + {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, + {&__pyx_n_s_from_dstring_array, __pyx_k_from_dstring_array, sizeof(__pyx_k_from_dstring_array), 0, 0, 1, 1}, + {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, + {&__pyx_n_s_get_character_flags_table_ptr, __pyx_k_get_character_flags_table_ptr, sizeof(__pyx_k_get_character_flags_table_ptr), 0, 0, 1, 1}, + {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, + {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, + {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_kp_u_include, __pyx_k_include, sizeof(__pyx_k_include), 0, 1, 0, 0}, + {&__pyx_n_s_include_path, __pyx_k_include_path, sizeof(__pyx_k_include_path), 0, 0, 1, 1}, + {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1}, + {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, + {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, + {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, + {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, + {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, + {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, + {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, + {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, + {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, + {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, + {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1}, + {&__pyx_n_s_process_udf, __pyx_k_process_udf, sizeof(__pyx_k_process_udf), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, + {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, + {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, + {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, + {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, + {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, + {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, + {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1}, + {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, + {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0}, + {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0}, + {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, + {&__pyx_n_s_strings_col, __pyx_k_strings_col, sizeof(__pyx_k_strings_col), 0, 0, 1, 1}, + {&__pyx_n_s_strings_udf__lib_cudf_jit_udf, __pyx_k_strings_udf__lib_cudf_jit_udf, sizeof(__pyx_k_strings_udf__lib_cudf_jit_udf), 0, 0, 1, 1}, + {&__pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_k_strings_udf__lib_cudf_jit_udf_py, sizeof(__pyx_k_strings_udf__lib_cudf_jit_udf_py), 0, 0, 1, 0}, + {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0}, + {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, + {&__pyx_n_s_tbl_ptr, __pyx_k_tbl_ptr, sizeof(__pyx_k_tbl_ptr), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_to_string_view_array, __pyx_k_to_string_view_array, sizeof(__pyx_k_to_string_view_array), 0, 0, 1, 1}, + {&__pyx_n_s_udf, __pyx_k_udf, sizeof(__pyx_k_udf), 0, 0, 1, 1}, + {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0}, + {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0}, + {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, + {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 133, __pyx_L1_error) + __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 148, __pyx_L1_error) + __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 151, __pyx_L1_error) + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 180, __pyx_L1_error) + __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) + __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 404, __pyx_L1_error) + __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(1, 613, __pyx_L1_error) + __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 832, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "View.MemoryView":133 + * + * if not self.ndim: + * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< + * + * if itemsize <= 0: + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 133, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "View.MemoryView":136 + * + * if itemsize <= 0: + * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< + * + * if not isinstance(format, bytes): + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 136, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "View.MemoryView":148 + * + * if not self._shape: + * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 148, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "View.MemoryView":176 + * self.data = malloc(self.len) + * if not self.data: + * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< + * + * if self.dtype_is_object: + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 176, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "View.MemoryView":192 + * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS + * if not (flags & bufmode): + * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< + * info.buf = self.data + * info.len = self.len + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 192, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "View.MemoryView":418 + * def __setitem__(memoryview self, object index, object value): + * if self.view.readonly: + * raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<< + * + * have_slices, index = _unellipsify(index, self.view.ndim) + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 418, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "View.MemoryView":495 + * result = struct.unpack(self.view.format, bytesitem) + * except struct.error: + * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< + * else: + * if len(self.view.format) == 1: + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 495, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "View.MemoryView":520 + * def __getbuffer__(self, Py_buffer *info, int flags): + * if flags & PyBUF_WRITABLE and self.view.readonly: + * raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<< + * + * if flags & PyBUF_ND: + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 520, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "View.MemoryView":570 + * if self.view.strides == NULL: + * + * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< + * + * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 570, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "View.MemoryView":577 + * def suboffsets(self): + * if self.view.suboffsets == NULL: + * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + * + * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + */ + __pyx_tuple__12 = PyTuple_New(1); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 577, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_INCREF(__pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + PyTuple_SET_ITEM(__pyx_tuple__12, 0, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + + /* "View.MemoryView":682 + * if item is Ellipsis: + * if not seen_ellipsis: + * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< + * seen_ellipsis = True + * else: + */ + __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) __PYX_ERR(1, 682, __pyx_L1_error) + __Pyx_GOTREF(__pyx_slice__15); + __Pyx_GIVEREF(__pyx_slice__15); + + /* "View.MemoryView":703 + * for suboffset in suboffsets[:ndim]: + * if suboffset >= 0: + * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 703, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__16); + __Pyx_GIVEREF(__pyx_tuple__16); + + /* "(tree fragment)":2 + * def __reduce_cython__(self): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + */ + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 2, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); + + /* "(tree fragment)":4 + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") + * def __setstate_cython__(self, __pyx_state): + * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< + */ + __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__18); + __Pyx_GIVEREF(__pyx_tuple__18); + __pyx_tuple__19 = PyTuple_Pack(3, __pyx_int_184977713, __pyx_int_136983863, __pyx_int_112105877); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__19); + __Pyx_GIVEREF(__pyx_tuple__19); + + /* "strings_udf/_lib/cudf_jit_udf.pyx":35 + * import numpy as np + * + * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< + * cdef string c_udf + * cdef string c_name + */ + __pyx_tuple__20 = PyTuple_Pack(13, __pyx_n_s_udf, __pyx_n_s_name, __pyx_n_s_cols, __pyx_n_s_c_udf, __pyx_n_s_c_name, __pyx_n_s_c_size, __pyx_n_s_c_columns, __pyx_n_s_c_module, __pyx_n_s_c_options, __pyx_n_s_c_result, __pyx_n_s_col, __pyx_n_s_c, __pyx_n_s_include_path); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 35, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_process_udf, 35, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 35, __pyx_L1_error) + + /* "strings_udf/_lib/cudf_jit_udf.pyx":68 + * + * + * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< + * cdef unique_ptr[device_buffer] c_buffer + * + */ + __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_strings_col, __pyx_n_s_c_buffer, __pyx_n_s_buffer); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_to_string_view_array, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 68, __pyx_L1_error) + + /* "strings_udf/_lib/cudf_jit_udf.pyx":79 + * + * + * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< + * cdef size_t size = d_buffer.c_size() + * cdef void* data = d_buffer.c_data() + */ + __pyx_tuple__24 = PyTuple_Pack(4, __pyx_n_s_d_buffer, __pyx_n_s_size, __pyx_n_s_data, __pyx_n_s_c_result); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 79, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__24); + __Pyx_GIVEREF(__pyx_tuple__24); + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_from_dstring_array, 79, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 79, __pyx_L1_error) + + /* "strings_udf/_lib/cudf_jit_udf.pyx":90 + * return Column.from_unique_ptr(move(c_result)) + * + * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< + * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + * return np.int64(tbl_ptr) + */ + __pyx_tuple__26 = PyTuple_Pack(1, __pyx_n_s_tbl_ptr); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_get_character_flags_table_ptr, 90, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 90, __pyx_L1_error) + + /* "View.MemoryView":286 + * return self.name + * + * cdef generic = Enum("") # <<<<<<<<<<<<<< + * cdef strided = Enum("") # default + * cdef indirect = Enum("") + */ + __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(1, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); + + /* "View.MemoryView":287 + * + * cdef generic = Enum("") + * cdef strided = Enum("") # default # <<<<<<<<<<<<<< + * cdef indirect = Enum("") + * + */ + __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__29); + __Pyx_GIVEREF(__pyx_tuple__29); + + /* "View.MemoryView":288 + * cdef generic = Enum("") + * cdef strided = Enum("") # default + * cdef indirect = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(1, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + + /* "View.MemoryView":291 + * + * + * cdef contiguous = Enum("") # <<<<<<<<<<<<<< + * cdef indirect_contiguous = Enum("") + * + */ + __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(1, 291, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__31); + __Pyx_GIVEREF(__pyx_tuple__31); + + /* "View.MemoryView":292 + * + * cdef contiguous = Enum("") + * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(1, 292, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__32); + __Pyx_GIVEREF(__pyx_tuple__32); + + /* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * cdef object __pyx_PickleError + * cdef object __pyx_result + */ + __pyx_tuple__33 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__33); + __Pyx_GIVEREF(__pyx_tuple__33); + __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_112105877 = PyInt_FromLong(112105877L); if (unlikely(!__pyx_int_112105877)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_136983863 = PyInt_FromLong(136983863L); if (unlikely(!__pyx_int_136983863)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) + return 0; + __pyx_L1_error:; + return -1; +} + +static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ +static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + generic = Py_None; Py_INCREF(Py_None); + strided = Py_None; Py_INCREF(Py_None); + indirect = Py_None; Py_INCREF(Py_None); + contiguous = Py_None; Py_INCREF(Py_None); + indirect_contiguous = Py_None; Py_INCREF(Py_None); + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + __pyx_vtabptr_array = &__pyx_vtable_array; + __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview; + if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type___pyx_array.tp_print = 0; + #endif + if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error) + __pyx_array_type = &__pyx_type___pyx_array; + if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type___pyx_MemviewEnum.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error) + __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum; + __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview; + __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer; + __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice; + __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment; + __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar; + __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed; + __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object; + __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object; + if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type___pyx_memoryview.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error) + __pyx_memoryview_type = &__pyx_type___pyx_memoryview; + __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice; + __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview; + __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object; + __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object; + __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type; + if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error) + #if PY_VERSION_HEX < 0x030800B1 + __pyx_type___pyx_memoryviewslice.tp_print = 0; + #endif + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr; + } + if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error) + if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error) + __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __pyx_t_1 = PyImport_ImportModule("rmm._cuda.stream"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 22, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_3rmm_5_cuda_6stream_Stream = __Pyx_ImportType(__pyx_t_1, "rmm._cuda.stream", "Stream", sizeof(struct __pyx_obj_3rmm_5_cuda_6stream_Stream), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_5_cuda_6stream_Stream) __PYX_ERR(2, 22, __pyx_L1_error) + __pyx_vtabptr_3rmm_5_cuda_6stream_Stream = (struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream*)__Pyx_GetVtable(__pyx_ptype_3rmm_5_cuda_6stream_Stream->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_5_cuda_6stream_Stream)) __PYX_ERR(2, 22, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyImport_ImportModule("rmm._lib.memory_resource"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 27, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "DeviceMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource) __PYX_ERR(3, 27, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_DeviceMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_DeviceMemoryResource)) __PYX_ERR(3, 27, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "UpstreamResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor) __PYX_ERR(3, 31, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor)) __PYX_ERR(3, 31, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "CudaMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource) __PYX_ERR(3, 36, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaMemoryResource)) __PYX_ERR(3, 36, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "ManagedMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_ManagedMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource) __PYX_ERR(3, 39, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_ManagedMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_ManagedMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_ManagedMemoryResource)) __PYX_ERR(3, 39, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "CudaAsyncMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource) __PYX_ERR(3, 42, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource)) __PYX_ERR(3, 42, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "PoolMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_PoolMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource) __PYX_ERR(3, 45, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_PoolMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_PoolMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_PoolMemoryResource)) __PYX_ERR(3, 45, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "FixedSizeMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource) __PYX_ERR(3, 48, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource)) __PYX_ERR(3, 48, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "BinningMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource) __PYX_ERR(3, 51, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_BinningMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_BinningMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_BinningMemoryResource)) __PYX_ERR(3, 51, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "CallbackMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_CallbackMemoryResource), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource) __PYX_ERR(3, 60, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_CallbackMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CallbackMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_CallbackMemoryResource)) __PYX_ERR(3, 60, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "LoggingResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor) __PYX_ERR(3, 64, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor)) __PYX_ERR(3, 64, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "StatisticsResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor) __PYX_ERR(3, 69, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor)) __PYX_ERR(3, 69, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "TrackingResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor) __PYX_ERR(3, 72, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor)) __PYX_ERR(3, 72, __pyx_L1_error) + __pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "FailureCallbackResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor) __PYX_ERR(3, 75, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor)) __PYX_ERR(3, 75, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyImport_ImportModule("rmm._lib.device_buffer"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 36, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer = __Pyx_ImportType(__pyx_t_1, "rmm._lib.device_buffer", "DeviceBuffer", sizeof(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer) __PYX_ERR(4, 36, __pyx_L1_error) + __pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer = (struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer)) __PYX_ERR(4, 36, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyImport_ImportModule("cudf._lib.column"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_ptype_4cudf_4_lib_6column_Column = __Pyx_ImportType(__pyx_t_1, "cudf._lib.column", "Column", sizeof(struct __pyx_obj_4cudf_4_lib_6column_Column), __Pyx_ImportType_CheckSize_Warn); + if (!__pyx_ptype_4cudf_4_lib_6column_Column) __PYX_ERR(5, 13, __pyx_L1_error) + __pyx_vtabptr_4cudf_4_lib_6column_Column = (struct __pyx_vtabstruct_4cudf_4_lib_6column_Column*)__Pyx_GetVtable(__pyx_ptype_4cudf_4_lib_6column_Column->tp_dict); if (unlikely(!__pyx_vtabptr_4cudf_4_lib_6column_Column)) __PYX_ERR(5, 13, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#ifndef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#elif PY_MAJOR_VERSION < 3 +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" void +#else +#define __Pyx_PyMODINIT_FUNC void +#endif +#else +#ifdef __cplusplus +#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyObject * +#endif +#endif + + +#if PY_MAJOR_VERSION < 3 +__Pyx_PyMODINIT_FUNC initcudf_jit_udf(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initcudf_jit_udf(void) +#else +__Pyx_PyMODINIT_FUNC PyInit_cudf_jit_udf(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_cudf_jit_udf(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { + #if PY_VERSION_HEX >= 0x030700A1 + static PY_INT64_T main_interpreter_id = -1; + PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); + if (main_interpreter_id == -1) { + main_interpreter_id = current_id; + return (unlikely(current_id == -1)) ? -1 : 0; + } else if (unlikely(main_interpreter_id != current_id)) + #else + static PyInterpreterState *main_interpreter = NULL; + PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; + if (!main_interpreter) { + main_interpreter = current_interpreter; + } else if (unlikely(main_interpreter != current_interpreter)) + #endif + { + PyErr_SetString( + PyExc_ImportError, + "Interpreter change detected - this module can only be loaded into one interpreter per process."); + return -1; + } + return 0; +} +static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + if (allow_none || value != Py_None) { + result = PyDict_SetItemString(moddict, to_name, value); + } + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__Pyx_check_single_interpreter()) + return NULL; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static CYTHON_SMALL_CODE int __pyx_pymod_exec_cudf_jit_udf(PyObject *__pyx_pyinit_module) +#endif +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + static PyThread_type_lock __pyx_t_3[8]; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m) { + if (__pyx_m == __pyx_pyinit_module) return 0; + PyErr_SetString(PyExc_RuntimeError, "Module 'cudf_jit_udf' has already been imported. Re-initialisation is not supported."); + return -1; + } + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); + #endif + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cudf_jit_udf(void)", 0); + if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pxy_PyFrame_Initialize_Offsets + __Pxy_PyFrame_Initialize_Offsets(); + #endif + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) + #ifdef __Pyx_CyFunction_USED + if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Coroutine_USED + if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + #ifdef __Pyx_StopAsyncIteration_USED + if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + PyEval_InitThreads(); + #endif + /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("cudf_jit_udf", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_b); + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) + Py_INCREF(__pyx_cython_runtime); + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); + /*--- Initialize various global constants etc. ---*/ + if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + if (__pyx_module_is_main_strings_udf___lib__cudf_jit_udf) { + if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "strings_udf._lib.cudf_jit_udf")) { + if (unlikely(PyDict_SetItemString(modules, "strings_udf._lib.cudf_jit_udf", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + } + } + #endif + /*--- Builtin init code ---*/ + if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Constants init code ---*/ + if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); + /*--- Execution code ---*/ + #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) + if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif + + /* "strings_udf/_lib/cudf_jit_udf.pyx":6 + * # cython: c_string_type=unicode, c_string_encoding=utf8 + * + * import os # <<<<<<<<<<<<<< + * + * from libcpp.string cimport string + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":13 + * from libcpp.utility cimport move + * + * from cudf.core.buffer import Buffer # <<<<<<<<<<<<<< + * + * from cudf._lib.cpp.column.column cimport column + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_Buffer); + __Pyx_GIVEREF(__pyx_n_s_Buffer); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Buffer); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_cudf_core_buffer, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_Buffer, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":33 + * from libc.stdint cimport uintptr_t, uint8_t + * + * import numpy as np # <<<<<<<<<<<<<< + * + * def process_udf( udf, name, cols ): + */ + __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":35 + * import numpy as np + * + * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< + * cdef string c_udf + * cdef string c_name + */ + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_1process_udf, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_process_udf, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":68 + * + * + * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< + * cdef unique_ptr[device_buffer] c_buffer + * + */ + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_string_view_array, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":79 + * + * + * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< + * cdef size_t size = d_buffer.c_size() + * cdef void* data = d_buffer.c_data() + */ + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_from_dstring_array, __pyx_t_2) < 0) __PYX_ERR(0, 79, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":90 + * return Column.from_unique_ptr(move(c_result)) + * + * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< + * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + * return np.int64(tbl_ptr) + */ + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_character_flags_table_ptr, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "strings_udf/_lib/cudf_jit_udf.pyx":1 + * # Copyright (c) 2021-2022, NVIDIA CORPORATION. # <<<<<<<<<<<<<< + * # + * # distutils: language = c++ + */ + __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "View.MemoryView":209 + * info.obj = self + * + * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * def __dealloc__(array self): + */ + __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 209, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(1, 209, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + PyType_Modified(__pyx_array_type); + + /* "View.MemoryView":286 + * return self.name + * + * cdef generic = Enum("") # <<<<<<<<<<<<<< + * cdef strided = Enum("") # default + * cdef indirect = Enum("") + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 286, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(generic); + __Pyx_DECREF_SET(generic, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":287 + * + * cdef generic = Enum("") + * cdef strided = Enum("") # default # <<<<<<<<<<<<<< + * cdef indirect = Enum("") + * + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 287, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(strided); + __Pyx_DECREF_SET(strided, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":288 + * cdef generic = Enum("") + * cdef strided = Enum("") # default + * cdef indirect = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 288, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(indirect); + __Pyx_DECREF_SET(indirect, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":291 + * + * + * cdef contiguous = Enum("") # <<<<<<<<<<<<<< + * cdef indirect_contiguous = Enum("") + * + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 291, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(contiguous); + __Pyx_DECREF_SET(contiguous, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":292 + * + * cdef contiguous = Enum("") + * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 292, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(indirect_contiguous); + __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + + /* "View.MemoryView":316 + * + * DEF THREAD_LOCKS_PREALLOCATED = 8 + * cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<< + * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ + * PyThread_allocate_lock(), + */ + __pyx_memoryview_thread_locks_used = 0; + + /* "View.MemoryView":317 + * DEF THREAD_LOCKS_PREALLOCATED = 8 + * cdef int __pyx_memoryview_thread_locks_used = 0 + * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<< + * PyThread_allocate_lock(), + * PyThread_allocate_lock(), + */ + __pyx_t_3[0] = PyThread_allocate_lock(); + __pyx_t_3[1] = PyThread_allocate_lock(); + __pyx_t_3[2] = PyThread_allocate_lock(); + __pyx_t_3[3] = PyThread_allocate_lock(); + __pyx_t_3[4] = PyThread_allocate_lock(); + __pyx_t_3[5] = PyThread_allocate_lock(); + __pyx_t_3[6] = PyThread_allocate_lock(); + __pyx_t_3[7] = PyThread_allocate_lock(); + memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_3, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); + + /* "View.MemoryView":549 + * info.obj = self + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 549, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(1, 549, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + PyType_Modified(__pyx_memoryview_type); + + /* "View.MemoryView":995 + * return self.from_object + * + * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 995, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(1, 995, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + PyType_Modified(__pyx_memoryviewslice_type); + + /* "(tree fragment)":1 + * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< + * cdef object __pyx_PickleError + * cdef object __pyx_result + */ + __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "(tree fragment)":11 + * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) + * return __pyx_result + * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< + * __pyx_result.name = __pyx_state[0] + * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init strings_udf._lib.cudf_jit_udf", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_CLEAR(__pyx_m); + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init strings_udf._lib.cudf_jit_udf"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 + return __pyx_m; + #else + return; + #endif +} + +/* --- Runtime support code --- */ +/* Refnanny */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule(modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, "RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +/* RaiseArgTupleInvalid */ +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +/* RaiseDoubleKeywords */ +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +/* ParseKeywords */ +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + +/* PyCFunctionFastCall */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); + } +} +#endif + +/* PyFunctionFastCall */ +#if CYTHON_FAST_PYCALL +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = __Pyx_PyFrame_GetLocalsplus(f); + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, (int)nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + +/* PyObjectCall */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = Py_TYPE(func)->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCall2Args */ +static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { + PyObject *args, *result = NULL; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyFunction_FastCall(function, args, 2); + } + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(function)) { + PyObject *args[2] = {arg1, arg2}; + return __Pyx_PyCFunction_FastCall(function, args, 2); + } + #endif + args = PyTuple_New(2); + if (unlikely(!args)) goto done; + Py_INCREF(arg1); + PyTuple_SET_ITEM(args, 0, arg1); + Py_INCREF(arg2); + PyTuple_SET_ITEM(args, 1, arg2); + Py_INCREF(function); + result = __Pyx_PyObject_Call(function, args, NULL); + Py_DECREF(args); + Py_DECREF(function); +done: + return result; +} + +/* PyObjectCallMethO */ +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +/* PyObjectCallOneArg */ +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } +#endif + if (likely(PyCFunction_Check(func))) { + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (__Pyx_PyFastCFunction_Check(func)) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_Pack(1, arg); + if (unlikely(!args)) return NULL; + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +#endif + +/* GetItemInt */ +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, + CYTHON_NCP_UNUSED int wraparound, + CYTHON_NCP_UNUSED int boundscheck) { +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (!PyErr_ExceptionMatches(PyExc_OverflowError)) + return NULL; + PyErr_Clear(); + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +/* ExtTypeTest */ +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(__Pyx_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +/* GetBuiltinName */ +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +/* PyDictVersioning */ +#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; +} +static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { + PyObject **dictptr = NULL; + Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; + if (offset) { +#if CYTHON_COMPILING_IN_CPYTHON + dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); +#else + dictptr = _PyObject_GetDictPtr(obj); +#endif + } + return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; +} +static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { + PyObject *dict = Py_TYPE(obj)->tp_dict; + if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) + return 0; + return obj_dict_version == __Pyx_get_object_dict_version(obj); +} +#endif + +/* GetModuleGlobalName */ +#if CYTHON_USE_DICT_VERSIONS +static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) +#else +static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) +#endif +{ + PyObject *result; +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } else if (unlikely(PyErr_Occurred())) { + return NULL; + } +#else + result = PyDict_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } +#endif +#else + result = PyObject_GetItem(__pyx_d, name); + __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) + if (likely(result)) { + return __Pyx_NewRef(result); + } + PyErr_Clear(); +#endif + return __Pyx_GetBuiltinName(name); +} + +/* ArgTypeTest */ +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + else if (exact) { + #if PY_MAJOR_VERSION == 2 + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(__Pyx_TypeCheck(obj, type))) return 1; + } + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); + return 0; +} + +/* PyErrFetchRestore */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +} +#endif + +/* RaiseException */ +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + __Pyx_PyThreadState_declare + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_PyThreadState_assign + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + int is_subclass = PyObject_IsSubclass(instance_class, type); + if (!is_subclass) { + instance_class = NULL; + } else if (unlikely(is_subclass == -1)) { + goto bad; + } else { + type = instance_class; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } + if (cause) { + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +/* BytesEquals */ +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY + return PyObject_RichCompareBool(s1, s2, equals); +#else + if (s1 == s2) { + return (equals == Py_EQ); + } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { + const char *ps1, *ps2; + Py_ssize_t length = PyBytes_GET_SIZE(s1); + if (length != PyBytes_GET_SIZE(s2)) + return (equals == Py_NE); + ps1 = PyBytes_AS_STRING(s1); + ps2 = PyBytes_AS_STRING(s2); + if (ps1[0] != ps2[0]) { + return (equals == Py_NE); + } else if (length == 1) { + return (equals == Py_EQ); + } else { + int result; +#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) + Py_hash_t hash1, hash2; + hash1 = ((PyBytesObject*)s1)->ob_shash; + hash2 = ((PyBytesObject*)s2)->ob_shash; + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + return (equals == Py_NE); + } +#endif + result = memcmp(ps1, ps2, (size_t)length); + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { + return (equals == Py_NE); + } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { + return (equals == Py_NE); + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +#endif +} + +/* UnicodeEquals */ +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { +#if CYTHON_COMPILING_IN_PYPY + return PyObject_RichCompareBool(s1, s2, equals); +#else +#if PY_MAJOR_VERSION < 3 + PyObject* owned_ref = NULL; +#endif + int s1_is_unicode, s2_is_unicode; + if (s1 == s2) { + goto return_eq; + } + s1_is_unicode = PyUnicode_CheckExact(s1); + s2_is_unicode = PyUnicode_CheckExact(s2); +#if PY_MAJOR_VERSION < 3 + if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { + owned_ref = PyUnicode_FromObject(s2); + if (unlikely(!owned_ref)) + return -1; + s2 = owned_ref; + s2_is_unicode = 1; + } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { + owned_ref = PyUnicode_FromObject(s1); + if (unlikely(!owned_ref)) + return -1; + s1 = owned_ref; + s1_is_unicode = 1; + } else if (((!s2_is_unicode) & (!s1_is_unicode))) { + return __Pyx_PyBytes_Equals(s1, s2, equals); + } +#endif + if (s1_is_unicode & s2_is_unicode) { + Py_ssize_t length; + int kind; + void *data1, *data2; + if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) + return -1; + length = __Pyx_PyUnicode_GET_LENGTH(s1); + if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { + goto return_ne; + } +#if CYTHON_USE_UNICODE_INTERNALS + { + Py_hash_t hash1, hash2; + #if CYTHON_PEP393_ENABLED + hash1 = ((PyASCIIObject*)s1)->hash; + hash2 = ((PyASCIIObject*)s2)->hash; + #else + hash1 = ((PyUnicodeObject*)s1)->hash; + hash2 = ((PyUnicodeObject*)s2)->hash; + #endif + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + goto return_ne; + } + } +#endif + kind = __Pyx_PyUnicode_KIND(s1); + if (kind != __Pyx_PyUnicode_KIND(s2)) { + goto return_ne; + } + data1 = __Pyx_PyUnicode_DATA(s1); + data2 = __Pyx_PyUnicode_DATA(s2); + if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { + goto return_ne; + } else if (length == 1) { + goto return_eq; + } else { + int result = memcmp(data1, data2, (size_t)(length * kind)); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ) ? (result == 0) : (result != 0); + } + } else if ((s1 == Py_None) & s2_is_unicode) { + goto return_ne; + } else if ((s2 == Py_None) & s1_is_unicode) { + goto return_ne; + } else { + int result; + PyObject* py_result = PyObject_RichCompare(s1, s2, equals); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + if (!py_result) + return -1; + result = __Pyx_PyObject_IsTrue(py_result); + Py_DECREF(py_result); + return result; + } +return_eq: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_EQ); +return_ne: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(owned_ref); + #endif + return (equals == Py_NE); +#endif +} + +/* DivInt[Py_ssize_t] */ +static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) { + Py_ssize_t q = a / b; + Py_ssize_t r = a - q*b; + q -= ((r != 0) & ((r ^ b) < 0)); + return q; +} + +/* GetAttr */ +static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { +#if CYTHON_USE_TYPE_SLOTS +#if PY_MAJOR_VERSION >= 3 + if (likely(PyUnicode_Check(n))) +#else + if (likely(PyString_Check(n))) +#endif + return __Pyx_PyObject_GetAttrStr(o, n); +#endif + return PyObject_GetAttr(o, n); +} + +/* ObjectGetItem */ +#if CYTHON_USE_TYPE_SLOTS +static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { + PyObject *runerr; + Py_ssize_t key_value; + PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; + if (unlikely(!(m && m->sq_item))) { + PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); + return NULL; + } + key_value = __Pyx_PyIndex_AsSsize_t(index); + if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { + return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); + } + if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { + PyErr_Clear(); + PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); + } + return NULL; +} +static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { + PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; + if (likely(m && m->mp_subscript)) { + return m->mp_subscript(obj, key); + } + return __Pyx_PyObject_GetIndex(obj, key); +} +#endif + +/* decode_c_string */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_string( + const char* cstring, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + Py_ssize_t length; + if (unlikely((start < 0) | (stop < 0))) { + size_t slen = strlen(cstring); + if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { + PyErr_SetString(PyExc_OverflowError, + "c-string too long to convert to Python"); + return NULL; + } + length = (Py_ssize_t) slen; + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (unlikely(stop <= start)) + return __Pyx_NewRef(__pyx_empty_unicode); + length = stop - start; + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/* PyErrExceptionMatches */ +#if CYTHON_FAST_THREAD_STATE +static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; icurexc_type; + if (exc_type == err) return 1; + if (unlikely(!exc_type)) return 0; + if (unlikely(PyTuple_Check(err))) + return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); + return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); +} +#endif + +/* GetAttr3 */ +static PyObject *__Pyx_GetAttr3Default(PyObject *d) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + return NULL; + __Pyx_PyErr_Clear(); + Py_INCREF(d); + return d; +} +static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { + PyObject *r = __Pyx_GetAttr(o, n); + return (likely(r)) ? r : __Pyx_GetAttr3Default(d); +} + +/* RaiseTooManyValuesToUnpack */ +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +/* RaiseNeedMoreValuesToUnpack */ +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +/* RaiseNoneIterError */ +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +/* GetTopmostException */ +#if CYTHON_USE_EXC_INFO_STACK +static _PyErr_StackItem * +__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) +{ + _PyErr_StackItem *exc_info = tstate->exc_info; + while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && + exc_info->previous_item != NULL) + { + exc_info = exc_info->previous_item; + } + return exc_info; +} +#endif + +/* SaveResetException */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); + *type = exc_info->exc_type; + *value = exc_info->exc_value; + *tb = exc_info->exc_traceback; + #else + *type = tstate->exc_type; + *value = tstate->exc_value; + *tb = tstate->exc_traceback; + #endif + Py_XINCREF(*type); + Py_XINCREF(*value); + Py_XINCREF(*tb); +} +static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = type; + exc_info->exc_value = value; + exc_info->exc_traceback = tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = type; + tstate->exc_value = value; + tstate->exc_traceback = tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +} +#endif + +/* GetException */ +#if CYTHON_FAST_THREAD_STATE +static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) +#else +static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) +#endif +{ + PyObject *local_type, *local_value, *local_tb; +#if CYTHON_FAST_THREAD_STATE + PyObject *tmp_type, *tmp_value, *tmp_tb; + local_type = tstate->curexc_type; + local_value = tstate->curexc_value; + local_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(&local_type, &local_value, &local_tb); +#endif + PyErr_NormalizeException(&local_type, &local_value, &local_tb); +#if CYTHON_FAST_THREAD_STATE + if (unlikely(tstate->curexc_type)) +#else + if (unlikely(PyErr_Occurred())) +#endif + goto bad; + #if PY_MAJOR_VERSION >= 3 + if (local_tb) { + if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) + goto bad; + } + #endif + Py_XINCREF(local_tb); + Py_XINCREF(local_type); + Py_XINCREF(local_value); + *type = local_type; + *value = local_value; + *tb = local_tb; +#if CYTHON_FAST_THREAD_STATE + #if CYTHON_USE_EXC_INFO_STACK + { + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = local_type; + exc_info->exc_value = local_value; + exc_info->exc_traceback = local_tb; + } + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = local_type; + tstate->exc_value = local_value; + tstate->exc_traceback = local_tb; + #endif + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_SetExcInfo(local_type, local_value, local_tb); +#endif + return 0; +bad: + *type = 0; + *value = 0; + *tb = 0; + Py_XDECREF(local_type); + Py_XDECREF(local_value); + Py_XDECREF(local_tb); + return -1; +} + +/* SwapException */ +#if CYTHON_FAST_THREAD_STATE +static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + #if CYTHON_USE_EXC_INFO_STACK + _PyErr_StackItem *exc_info = tstate->exc_info; + tmp_type = exc_info->exc_type; + tmp_value = exc_info->exc_value; + tmp_tb = exc_info->exc_traceback; + exc_info->exc_type = *type; + exc_info->exc_value = *value; + exc_info->exc_traceback = *tb; + #else + tmp_type = tstate->exc_type; + tmp_value = tstate->exc_value; + tmp_tb = tstate->exc_traceback; + tstate->exc_type = *type; + tstate->exc_value = *value; + tstate->exc_traceback = *tb; + #endif + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#else +static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); + PyErr_SetExcInfo(*type, *value, *tb); + *type = tmp_type; + *value = tmp_value; + *tb = tmp_tb; +} +#endif + +/* Import */ +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_MAJOR_VERSION < 3 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_MAJOR_VERSION < 3 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +/* FastTypeChecks */ +#if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { + Py_ssize_t i, n; + assert(PyExceptionClass_Check(exc_type)); + n = PyTuple_GET_SIZE(tuple); +#if PY_MAJOR_VERSION >= 3 + for (i=0; i= 0 || (x^b) >= 0)) + return PyInt_FromLong(x); + return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + #endif + #if CYTHON_USE_PYLONG_INTERNALS + if (likely(PyLong_CheckExact(op1))) { + const long b = intval; + long a, x; +#ifdef HAVE_LONG_LONG + const PY_LONG_LONG llb = intval; + PY_LONG_LONG lla, llx; +#endif + const digit* digits = ((PyLongObject*)op1)->ob_digit; + const Py_ssize_t size = Py_SIZE(op1); + if (likely(__Pyx_sst_abs(size) <= 1)) { + a = likely(size) ? digits[0] : 0; + if (size == -1) a = -a; + } else { + switch (size) { + case -2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 2: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 3: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case -4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + case 4: + if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); + break; +#ifdef HAVE_LONG_LONG + } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); + goto long_long; +#endif + } + CYTHON_FALLTHROUGH; + default: return PyLong_Type.tp_as_number->nb_add(op1, op2); + } + } + x = a + b; + return PyLong_FromLong(x); +#ifdef HAVE_LONG_LONG + long_long: + llx = lla + llb; + return PyLong_FromLongLong(llx); +#endif + + + } + #endif + if (PyFloat_CheckExact(op1)) { + const long b = intval; + double a = PyFloat_AS_DOUBLE(op1); + double result; + PyFPE_START_PROTECT("add", return NULL) + result = ((double)a) + (double)b; + PyFPE_END_PROTECT(result) + return PyFloat_FromDouble(result); + } + return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); +} +#endif + +/* None */ +static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { + PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); +} + +/* DivInt[long] */ +static CYTHON_INLINE long __Pyx_div_long(long a, long b) { + long q = a / b; + long r = a - q*b; + q -= ((r != 0) & ((r ^ b) < 0)); + return q; +} + +/* ImportFrom */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + +/* HasAttr */ +static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { + PyObject *r; + if (unlikely(!__Pyx_PyBaseString_Check(n))) { + PyErr_SetString(PyExc_TypeError, + "hasattr(): attribute name must be string"); + return -1; + } + r = __Pyx_GetAttr(o, n); + if (unlikely(!r)) { + PyErr_Clear(); + return 0; + } else { + Py_DECREF(r); + return 1; + } +} + +/* PyObject_GenericGetAttrNoDict */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, attr_name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(attr_name)); +#endif + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { + PyObject *descr; + PyTypeObject *tp = Py_TYPE(obj); + if (unlikely(!PyString_Check(attr_name))) { + return PyObject_GenericGetAttr(obj, attr_name); + } + assert(!tp->tp_dictoffset); + descr = _PyType_Lookup(tp, attr_name); + if (unlikely(!descr)) { + return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); + } + Py_INCREF(descr); + #if PY_MAJOR_VERSION < 3 + if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) + #endif + { + descrgetfunc f = Py_TYPE(descr)->tp_descr_get; + if (unlikely(f)) { + PyObject *res = f(descr, obj, (PyObject *)tp); + Py_DECREF(descr); + return res; + } + } + return descr; +} +#endif + +/* PyObject_GenericGetAttr */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { + if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { + return PyObject_GenericGetAttr(obj, attr_name); + } + return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); +} +#endif + +/* SetVTable */ +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +/* PyObjectGetAttrStrNoError */ +static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) + __Pyx_PyErr_Clear(); +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { + return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); + } +#endif + result = __Pyx_PyObject_GetAttrStr(obj, attr_name); + if (unlikely(!result)) { + __Pyx_PyObject_GetAttrStr_ClearAttributeError(); + } + return result; +} + +/* SetupReduce */ +static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { + int ret; + PyObject *name_attr; + name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2); + if (likely(name_attr)) { + ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); + } else { + ret = -1; + } + if (unlikely(ret < 0)) { + PyErr_Clear(); + ret = 0; + } + Py_XDECREF(name_attr); + return ret; +} +static int __Pyx_setup_reduce(PyObject* type_obj) { + int ret = 0; + PyObject *object_reduce = NULL; + PyObject *object_getstate = NULL; + PyObject *object_reduce_ex = NULL; + PyObject *reduce = NULL; + PyObject *reduce_ex = NULL; + PyObject *reduce_cython = NULL; + PyObject *setstate = NULL; + PyObject *setstate_cython = NULL; + PyObject *getstate = NULL; +#if CYTHON_USE_PYTYPE_LOOKUP + getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate); +#else + getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate); + if (!getstate && PyErr_Occurred()) { + goto __PYX_BAD; + } +#endif + if (getstate) { +#if CYTHON_USE_PYTYPE_LOOKUP + object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate); +#else + object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate); + if (!object_getstate && PyErr_Occurred()) { + goto __PYX_BAD; + } +#endif + if (object_getstate != getstate) { + goto __PYX_GOOD; + } + } +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; +#else + object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; +#endif + reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; + if (reduce_ex == object_reduce_ex) { +#if CYTHON_USE_PYTYPE_LOOKUP + object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; +#else + object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; +#endif + reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD; + if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { + reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython); + if (likely(reduce_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (reduce == object_reduce || PyErr_Occurred()) { + goto __PYX_BAD; + } + setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); + if (!setstate) PyErr_Clear(); + if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { + setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython); + if (likely(setstate_cython)) { + ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; + } else if (!setstate || PyErr_Occurred()) { + goto __PYX_BAD; + } + } + PyType_Modified((PyTypeObject*)type_obj); + } + } + goto __PYX_GOOD; +__PYX_BAD: + if (!PyErr_Occurred()) + PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); + ret = -1; +__PYX_GOOD: +#if !CYTHON_USE_PYTYPE_LOOKUP + Py_XDECREF(object_reduce); + Py_XDECREF(object_reduce_ex); + Py_XDECREF(object_getstate); + Py_XDECREF(getstate); +#endif + Py_XDECREF(reduce); + Py_XDECREF(reduce_ex); + Py_XDECREF(reduce_cython); + Py_XDECREF(setstate); + Py_XDECREF(setstate_cython); + return ret; +} + +/* TypeImport */ +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, + size_t size, enum __Pyx_ImportType_CheckSize check_size) +{ + PyObject *result = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + result = PyObject_GetAttrString(module, class_name); + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if ((size_t)basicsize < size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + goto bad; + } + else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility. " + "Expected %zd from C header, got %zd from PyObject", + module_name, class_name, size, basicsize); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(result); + return NULL; +} +#endif + +/* GetVTable */ +static void* __Pyx_GetVtable(PyObject *dict) { + void* ptr; + PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); + if (!ob) + goto bad; +#if PY_VERSION_HEX >= 0x02070000 + ptr = PyCapsule_GetPointer(ob, 0); +#else + ptr = PyCObject_AsVoidPtr(ob); +#endif + if (!ptr && !PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); + Py_DECREF(ob); + return ptr; +bad: + Py_XDECREF(ob); + return NULL; +} + +/* CLineInTraceback */ +#ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + __PYX_PY_DICT_LOOKUP_IF_MODIFIED( + use_cline, *cython_runtime_dict, + __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + +/* CodeObjectCache */ +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = start + (end - start) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +/* AddTraceback */ +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +#if PY_VERSION_HEX >= 0x030b00a6 + #ifndef Py_BUILD_CORE + #define Py_BUILD_CORE 1 + #endif + #include "internal/pycore_frame.h" +#endif +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = NULL; + PyObject *py_funcname = NULL; + #if PY_MAJOR_VERSION < 3 + PyObject *py_srcfile = NULL; + py_srcfile = PyString_FromString(filename); + if (!py_srcfile) goto bad; + #endif + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + if (!py_funcname) goto bad; + funcname = PyUnicode_AsUTF8(py_funcname); + if (!funcname) goto bad; + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + if (!py_funcname) goto bad; + #endif + } + #if PY_MAJOR_VERSION < 3 + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + #else + py_code = PyCode_NewEmpty(filename, funcname, py_line); + #endif + Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline + return py_code; +bad: + Py_XDECREF(py_funcname); + #if PY_MAJOR_VERSION < 3 + Py_XDECREF(py_srcfile); + #endif + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject *ptype, *pvalue, *ptraceback; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); + if (!py_code) { + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) { + /* If the code object creation fails, then we should clear the + fetched exception references and propagate the new exception */ + Py_XDECREF(ptype); + Py_XDECREF(pvalue); + Py_XDECREF(ptraceback); + goto bad; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); + } + py_frame = PyFrame_New( + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +/* CIntFromPyVerify */ +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) +#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ + __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) +#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ + {\ + func_type value = func_value;\ + if (sizeof(target_type) < sizeof(func_type)) {\ + if (unlikely(value != (func_type) (target_type) value)) {\ + func_type zero = 0;\ + if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ + return (target_type) -1;\ + if (is_unsigned && unlikely(value < zero))\ + goto raise_neg_overflow;\ + else\ + goto raise_overflow;\ + }\ + }\ + return (target_type) value;\ + } + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags); + if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags); + PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + if ((0)) {} + view->obj = NULL; + Py_DECREF(obj); +} +#endif + + +/* MemviewSliceIsContig */ +static int +__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim) +{ + int i, index, step, start; + Py_ssize_t itemsize = mvs.memview->view.itemsize; + if (order == 'F') { + step = 1; + start = 0; + } else { + step = -1; + start = ndim - 1; + } + for (i = 0; i < ndim; i++) { + index = start + step * i; + if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize) + return 0; + itemsize *= mvs.shape[index]; + } + return 1; +} + +/* OverlappingSlices */ +static void +__pyx_get_array_memory_extents(__Pyx_memviewslice *slice, + void **out_start, void **out_end, + int ndim, size_t itemsize) +{ + char *start, *end; + int i; + start = end = slice->data; + for (i = 0; i < ndim; i++) { + Py_ssize_t stride = slice->strides[i]; + Py_ssize_t extent = slice->shape[i]; + if (extent == 0) { + *out_start = *out_end = start; + return; + } else { + if (stride > 0) + end += stride * (extent - 1); + else + start += stride * (extent - 1); + } + } + *out_start = start; + *out_end = end + itemsize; +} +static int +__pyx_slices_overlap(__Pyx_memviewslice *slice1, + __Pyx_memviewslice *slice2, + int ndim, size_t itemsize) +{ + void *start1, *end1, *start2, *end2; + __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize); + __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize); + return (start1 < end2) && (start2 < end1); +} + +/* Capsule */ +static CYTHON_INLINE PyObject * +__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) +{ + PyObject *cobj; +#if PY_VERSION_HEX >= 0x02070000 + cobj = PyCapsule_New(p, sig, NULL); +#else + cobj = PyCObject_FromVoidPtr(p, NULL); +#endif + return cobj; +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +/* CIntFromPy */ +static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int32_t) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int32_t) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int32_t) 0; + case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0]) + case 2: + if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) { + return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) { + return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) >= 4 * PyLong_SHIFT) { + return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int32_t) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int32_t) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int32_t) 0; + case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, +digits[0]) + case -2: + if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) { + return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) { + return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) { + return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) { + return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) { + return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) { + return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int32_t) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int32_t val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int32_t) -1; + } + } else { + int32_t val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int32_t) -1; + val = __Pyx_PyInt_As_int32_t(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int32_t"); + return (int32_t) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int32_t"); + return (int32_t) -1; +} + +/* MemviewSliceCopyTemplate */ +static __Pyx_memviewslice +__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, + const char *mode, int ndim, + size_t sizeof_dtype, int contig_flag, + int dtype_is_object) +{ + __Pyx_RefNannyDeclarations + int i; + __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } }; + struct __pyx_memoryview_obj *from_memview = from_mvs->memview; + Py_buffer *buf = &from_memview->view; + PyObject *shape_tuple = NULL; + PyObject *temp_int = NULL; + struct __pyx_array_obj *array_obj = NULL; + struct __pyx_memoryview_obj *memview_obj = NULL; + __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0); + for (i = 0; i < ndim; i++) { + if (unlikely(from_mvs->suboffsets[i] >= 0)) { + PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with " + "indirect dimensions (axis %d)", i); + goto fail; + } + } + shape_tuple = PyTuple_New(ndim); + if (unlikely(!shape_tuple)) { + goto fail; + } + __Pyx_GOTREF(shape_tuple); + for(i = 0; i < ndim; i++) { + temp_int = PyInt_FromSsize_t(from_mvs->shape[i]); + if(unlikely(!temp_int)) { + goto fail; + } else { + PyTuple_SET_ITEM(shape_tuple, i, temp_int); + temp_int = NULL; + } + } + array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL); + if (unlikely(!array_obj)) { + goto fail; + } + __Pyx_GOTREF(array_obj); + memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( + (PyObject *) array_obj, contig_flag, + dtype_is_object, + from_mvs->memview->typeinfo); + if (unlikely(!memview_obj)) + goto fail; + if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0)) + goto fail; + if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim, + dtype_is_object) < 0)) + goto fail; + goto no_fail; +fail: + __Pyx_XDECREF(new_mvs.memview); + new_mvs.memview = NULL; + new_mvs.data = NULL; +no_fail: + __Pyx_XDECREF(shape_tuple); + __Pyx_XDECREF(temp_int); + __Pyx_XDECREF(array_obj); + __Pyx_RefNannyFinishContext(); + return new_mvs; +} + +/* MemviewSliceInit */ +static int +__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, + int ndim, + __Pyx_memviewslice *memviewslice, + int memview_is_new_reference) +{ + __Pyx_RefNannyDeclarations + int i, retval=-1; + Py_buffer *buf = &memview->view; + __Pyx_RefNannySetupContext("init_memviewslice", 0); + if (unlikely(memviewslice->memview || memviewslice->data)) { + PyErr_SetString(PyExc_ValueError, + "memviewslice is already initialized!"); + goto fail; + } + if (buf->strides) { + for (i = 0; i < ndim; i++) { + memviewslice->strides[i] = buf->strides[i]; + } + } else { + Py_ssize_t stride = buf->itemsize; + for (i = ndim - 1; i >= 0; i--) { + memviewslice->strides[i] = stride; + stride *= buf->shape[i]; + } + } + for (i = 0; i < ndim; i++) { + memviewslice->shape[i] = buf->shape[i]; + if (buf->suboffsets) { + memviewslice->suboffsets[i] = buf->suboffsets[i]; + } else { + memviewslice->suboffsets[i] = -1; + } + } + memviewslice->memview = memview; + memviewslice->data = (char *)buf->buf; + if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) { + Py_INCREF(memview); + } + retval = 0; + goto no_fail; +fail: + memviewslice->memview = 0; + memviewslice->data = 0; + retval = -1; +no_fail: + __Pyx_RefNannyFinishContext(); + return retval; +} +#ifndef Py_NO_RETURN +#define Py_NO_RETURN +#endif +static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN { + va_list vargs; + char msg[200]; +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, fmt); +#else + va_start(vargs); +#endif + vsnprintf(msg, 200, fmt, vargs); + va_end(vargs); + Py_FatalError(msg); +} +static CYTHON_INLINE int +__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) +{ + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)++; + PyThread_release_lock(lock); + return result; +} +static CYTHON_INLINE int +__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count, + PyThread_type_lock lock) +{ + int result; + PyThread_acquire_lock(lock, 1); + result = (*acquisition_count)--; + PyThread_release_lock(lock); + return result; +} +static CYTHON_INLINE void +__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno) +{ + int first_time; + struct __pyx_memoryview_obj *memview = memslice->memview; + if (unlikely(!memview || (PyObject *) memview == Py_None)) + return; + if (unlikely(__pyx_get_slice_count(memview) < 0)) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + first_time = __pyx_add_acquisition_count(memview) == 0; + if (unlikely(first_time)) { + if (have_gil) { + Py_INCREF((PyObject *) memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_INCREF((PyObject *) memview); + PyGILState_Release(_gilstate); + } + } +} +static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, + int have_gil, int lineno) { + int last_time; + struct __pyx_memoryview_obj *memview = memslice->memview; + if (unlikely(!memview || (PyObject *) memview == Py_None)) { + memslice->memview = NULL; + return; + } + if (unlikely(__pyx_get_slice_count(memview) <= 0)) + __pyx_fatalerror("Acquisition count is %d (line %d)", + __pyx_get_slice_count(memview), lineno); + last_time = __pyx_sub_acquisition_count(memview) == 1; + memslice->data = NULL; + if (unlikely(last_time)) { + if (have_gil) { + Py_CLEAR(memslice->memview); + } else { + PyGILState_STATE _gilstate = PyGILState_Ensure(); + Py_CLEAR(memslice->memview); + PyGILState_Release(_gilstate); + } + } else { + memslice->memview = NULL; + } +} + +/* CIntFromPy */ +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (int) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (int) 0; + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) + case -2: + if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(int) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(int) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(int) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); + } + } + break; + } +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +/* CIntFromPy */ +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const long neg_one = (long) -1, const_zero = (long) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (long) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (long) 0; + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) + case -2: + if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(long) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(long) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(long) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); + } + } + break; + } +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +/* CIntToPy */ +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const int neg_one = (int) -1, const_zero = (int) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { + return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG + } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { + return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +/* CIntFromPy */ +static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif + const char neg_one = (char) -1, const_zero = (char) 0; +#ifdef __Pyx_HAS_GCC_DIAGNOSTIC +#pragma GCC diagnostic pop +#endif + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(char) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (char) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (char) 0; + case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0]) + case 2: + if (8 * sizeof(char) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) { + return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + } + } + break; + case 3: + if (8 * sizeof(char) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) { + return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + } + } + break; + case 4: + if (8 * sizeof(char) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) { + return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); + } + } + break; + } +#endif +#if CYTHON_COMPILING_IN_CPYTHON + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } +#else + { + int result = PyObject_RichCompareBool(x, Py_False, Py_LT); + if (unlikely(result < 0)) + return (char) -1; + if (unlikely(result == 1)) + goto raise_neg_overflow; + } +#endif + if (sizeof(char) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif + } + } else { +#if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)x)->ob_digit; + switch (Py_SIZE(x)) { + case 0: return (char) 0; + case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0])) + case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0]) + case -2: + if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case 2: + if (8 * sizeof(char) > 1 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case -3: + if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case 3: + if (8 * sizeof(char) > 2 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case -4: + if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { + return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + case 4: + if (8 * sizeof(char) > 3 * PyLong_SHIFT) { + if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) + } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { + return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); + } + } + break; + } +#endif + if (sizeof(char) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG + } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { + __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + char val; + PyObject *v = __Pyx_PyNumber_IntOrLong(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (char) -1; + } + } else { + char val; + PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); + if (!tmp) return (char) -1; + val = __Pyx_PyInt_As_char(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to char"); + return (char) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to char"); + return (char) -1; +} + +/* CheckBinaryVersion */ +static int __Pyx_check_binary_version(void) { + char ctversion[5]; + int same=1, i, found_dot; + const char* rt_from_call = Py_GetVersion(); + PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + found_dot = 0; + for (i = 0; i < 4; i++) { + if (!ctversion[i]) { + same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); + break; + } + if (rt_from_call[i] != ctversion[i]) { + same = 0; + break; + } + } + if (!same) { + char rtversion[5] = {'\0'}; + char message[200]; + for (i=0; i<4; ++i) { + if (rt_from_call[i] == '.') { + if (found_dot) break; + found_dot = 1; + } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { + break; + } + rtversion[i] = rt_from_call[i]; + } + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +/* InitStrings */ +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + if (PyObject_Hash(*t->p) == -1) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} +#else +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); + } else +#endif +#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { + int retval; + if (unlikely(!x)) return -1; + retval = __Pyx_PyObject_IsTrue(x); + Py_DECREF(x); + return retval; +} +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS + PyNumberMethods *m; +#endif + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x) || PyLong_Check(x))) +#else + if (likely(PyLong_Check(x))) +#endif + return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS + m = Py_TYPE(x)->tp_as_number; + #if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = m->nb_int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = m->nb_long(x); + } + #else + if (likely(m && m->nb_int)) { + name = "int"; + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); + } +#endif + if (likely(res)) { +#if PY_MAJOR_VERSION < 3 + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { +#else + if (unlikely(!PyLong_CheckExact(res))) { +#endif + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) { + if (sizeof(Py_ssize_t) >= sizeof(long)) + return PyInt_AS_LONG(b); + else + return PyInt_AsSsize_t(b); + } +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_USE_PYLONG_INTERNALS + const digit* digits = ((PyLongObject*)b)->ob_digit; + const Py_ssize_t size = Py_SIZE(b); + if (likely(__Pyx_sst_abs(size) <= 1)) { + ival = likely(size) ? digits[0] : 0; + if (size == -1) ival = -ival; + return ival; + } else { + switch (size) { + case 2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -2: + if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -3: + if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case 4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + case -4: + if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); + } + break; + } + } + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { + if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { + return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); +#if PY_MAJOR_VERSION < 3 + } else if (likely(PyInt_CheckExact(o))) { + return PyInt_AS_LONG(o); +#endif + } else { + Py_ssize_t ival; + PyObject *x; + x = PyNumber_Index(o); + if (!x) return -1; + ival = PyInt_AsLong(x); + Py_DECREF(x); + return ival; + } +} +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx new file mode 100644 index 00000000000..8e86abbe7f4 --- /dev/null +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -0,0 +1,92 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# +# distutils: language = c++ +# cython: c_string_type=unicode, c_string_encoding=utf8 + +import os + +from libcpp.string cimport string +from libcpp.vector cimport vector +from libcpp.memory cimport unique_ptr +from libcpp.utility cimport move + +from cudf.core.buffer import Buffer + +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type +from cudf._lib.column cimport Column + +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + +from strings_udf._lib.cpp.strings_udf cimport ( + call_udf as cpp_call_udf, + create_udf_module as cpp_create_udf_module, + from_dstring_array as cpp_from_dstring_array, + to_string_view_array as cpp_to_string_view_array, + udf_module as cpp_udf_module, + get_character_flags_table as cpp_get_character_flags_table +) + +from libc.stdint cimport uintptr_t, uint8_t + +import numpy as np + +def process_udf( udf, name, cols ): + cdef string c_udf + cdef string c_name + cdef size_type c_size + + cdef vector[column_view] c_columns + cdef unique_ptr[cpp_udf_module] c_module + cdef vector[string] c_options + + cdef unique_ptr[column] c_result + + c_udf = udf.encode('UTF-8') + c_name = name.encode('UTF-8') + + cdef Column col = cols[0]._column + c_size = col.size + for c in cols: + col = c._column + c_columns.push_back(col.view()) + + include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" + c_options.push_back(str(include_path).encode('UTF-8')) + + #with nogil: + c_module = move(cpp_create_udf_module(c_udf, c_options)) + # c_module will be nullptr if there is a compile error + + #with nogil: + c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) + + return Column.from_unique_ptr(move(c_result)) + + +def to_string_view_array(Column strings_col): + cdef unique_ptr[device_buffer] c_buffer + + #with nogil: + c_buffer = move(cpp_to_string_view_array(strings_col.view())) + + buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) + buffer = Buffer(buffer) + return buffer + + +def from_dstring_array(DeviceBuffer d_buffer): + cdef size_t size = d_buffer.c_size() + cdef void* data = d_buffer.c_data() + cdef unique_ptr[column] c_result + # data = + + #with nogil: + c_result = move(cpp_from_dstring_array(data, size)) + + return Column.from_unique_ptr(move(c_result)) + +def get_character_flags_table_ptr(): + cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + return np.int64(tbl_ptr) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py new file mode 100644 index 00000000000..30ff520405e --- /dev/null +++ b/python/strings_udf/strings_udf/_typing.py @@ -0,0 +1,481 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from numba import cuda, types +from numba.core.extending import models, register_model +from numba.core.typing import signature as nb_signature +from numba.core.typing.templates import AbstractTemplate +from numba.cuda.cudadecl import registry as cuda_decl_registry + +import operator + +import llvmlite.binding as ll +from numba.cuda.cudadrv import nvvm +from numba.core.datamodel import default_manager + +import operator + +data_layout = nvvm.data_layout + +# workaround for numba < 0.56 +if isinstance(data_layout, dict): + data_layout = data_layout[64] +target_data = ll.create_target_data(data_layout) + +# String object definitions +class DString(types.Type): + def __init__(self): + super().__init__(name="dstring") + llty = default_manager[self].get_value_type() + self.size_bytes = llty.get_abi_size(target_data) + + +class StringView(types.Type): + def __init__(self): + super().__init__(name="string_view") + llty = default_manager[self].get_value_type() + self.size_bytes = llty.get_abi_size(target_data) + + +@register_model(StringView) +class stringview_model(models.StructModel): + # from string_view.hpp: + _members = ( + # const char* _data{} + # Pointer to device memory contain char array for this string + ("data", types.CPointer(types.char)), + # size_type _bytes{}; + # Number of bytes in _data for this string + ("bytes", types.int32), + # mutable size_type _length{}; + # Number of characters in this string (computed) + ("length", types.int32), + ) + + def __init__(self, dmm, fe_type): + super().__init__(dmm, fe_type, self._members) + + +@register_model(DString) +class dstring_model(models.StructModel): + # from dstring.hpp: + # private: + # char* m_data{}; + # cudf::size_type m_bytes{}; + # cudf::size_type m_size{}; + + _members = ( + ("m_data", types.CPointer(types.char)), + ("m_bytes", types.int32), + ("m_size", types.int32), + ) + + def __init__(self, dmm, fe_type): + super().__init__(dmm, fe_type, self._members) + + +any_string_ty = (StringView, DString, types.StringLiteral) +string_view = StringView() + + +class StrViewArgHandler: + """ + As part of Numbas preprocessing step incoming function arguments are + modified based on the associated type for that argument that was used + to JIT the kernel. However it only knows how to handle built in array + types natively. With string UDFs, the jitted type is string_view*, + which numba does not know how to handle. + + This small piece of code implements the necessary handling. Really all + it does is funnel the handling of string_view* to the handling + of raw pointer arguments, which numba knows how to use. + + See numba.cuda.compiler._prepare_args for details. + """ + + def prepare_args(self, ty, val, **kwargs): + if isinstance(ty, types.CPointer) and isinstance(ty.dtype, StringView): + return types.uint64, val.ptr + else: + return ty, val + + +str_view_arg_handler = StrViewArgHandler() + + +# String functions +@cuda_decl_registry.register_global(len) +class StringLength(AbstractTemplate): + """ + provide the length of a cudf::string_view like struct + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and len(args) == 1 + ): + # length: + # string_view -> int32 + # dstring -> int32 + # literal -> int32 + return nb_signature(types.int32, args[0]) + + +_string_view_len = cuda.declare_device("len", types.int32(types.CPointer(string_view))) + +@cuda_decl_registry.register_global(operator.contains) +class StringViewContains(AbstractTemplate): + """ + Return True if a string view contains a substring view + """ + + def generic(self, args, kws): + if isinstance( + args[0], (StringView, DString, types.StringLiteral) + ) and isinstance(args[1], (StringView, DString, types.StringLiteral)): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_contains = cuda.declare_device( + "contains", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + +@cuda_decl_registry.register_global(operator.eq) +class StringViewEq(AbstractTemplate): + """ + Compare two cudf::string_view with == + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and isinstance(args[1], (StringView, DString, types.StringLiteral)) + and len(args) == 2 + ): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_eq = cuda.declare_device( + "eq", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + + +@cuda_decl_registry.register_global(operator.ne) +class StringViewNe(AbstractTemplate): + """ + Compare two cudf::string_view with != + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and isinstance(args[1], (StringView, DString, types.StringLiteral)) + and len(args) == 2 + ): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_ne = cuda.declare_device( + "ne", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + + +@cuda_decl_registry.register_global(operator.ge) +class StringViewGe(AbstractTemplate): + """ + Compare two cudf::string_view with >= + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and isinstance(args[1], (StringView, DString, types.StringLiteral)) + and len(args) == 2 + ): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_ge = cuda.declare_device( + "ge", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + + +@cuda_decl_registry.register_global(operator.le) +class StringViewLe(AbstractTemplate): + """ + Compare two cudf::string_view with <= + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and isinstance(args[1], (StringView, DString, types.StringLiteral)) + and len(args) == 2 + ): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_le = cuda.declare_device( + "le", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + + +@cuda_decl_registry.register_global(operator.gt) +class StringViewGt(AbstractTemplate): + """ + Compare two cudf::string_view with > + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and isinstance(args[1], (StringView, DString, types.StringLiteral)) + and len(args) == 2 + ): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_gt = cuda.declare_device( + "gt", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + + +@cuda_decl_registry.register_global(operator.lt) +class StringViewLt(AbstractTemplate): + """ + Compare two cudf::string_view with < + """ + + def generic(self, args, kws): + if ( + isinstance(args[0], (StringView, DString, types.StringLiteral)) + and isinstance(args[1], (StringView, DString, types.StringLiteral)) + and len(args) == 2 + ): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_lt = cuda.declare_device( + "lt", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + + +def starts_with(st, substr): + return st.startswith(substr) + + +@cuda_decl_registry.register_global(starts_with) +class StringViewStartsWith(AbstractTemplate): + """ + return True if a stringview starts with a substring + """ + + def generic(self, args, kws): + if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_startswith = cuda.declare_device( + "startswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + + +def ends_with(st, substr): + return st.endswith(substr) + + +@cuda_decl_registry.register_global(ends_with) +class StringViewEndsWith(AbstractTemplate): + """ + return True if a stringview ends with a substring + """ + + def generic(self, args, kws): + if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): + return nb_signature(types.boolean, string_view, string_view) + + +_string_view_endswith = cuda.declare_device( + "endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) + +def find(st, substr): + return st.find(substr) + +@cuda_decl_registry.register_global(find) +class StringViewFind(AbstractTemplate): + """ + Return the index of a substring within a stringview + """ + + def generic(self, args, kws): + if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): + return nb_signature(types.int32, string_view, string_view) + +_string_view_find = cuda.declare_device( + "find", + types.int32(types.CPointer(string_view), types.CPointer(string_view)) +) + +def rfind(st, substr): + return st.rfind(substr) + +@cuda_decl_registry.register_global(rfind) +class StringViewFind(AbstractTemplate): + """ + Return the index of a substring within a stringview + """ + + def generic(self, args, kws): + if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): + return nb_signature(types.int32, string_view, string_view) + +_string_view_rfind = cuda.declare_device( + "rfind", + types.int32(types.CPointer(string_view), types.CPointer(string_view)) +) + +def isdigit(st): + return st.isdigit() + +@cuda_decl_registry.register_global(isdigit) +class StringViewIsdigit(AbstractTemplate): + """ + Return True if the string is all numeric characters else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isdigit = cuda.declare_device( + "pyisdigit", + types.boolean(types.CPointer(string_view), types.int64) +) + +def isalnum(st): + return st.isalnum() + +@cuda_decl_registry.register_global(isalnum) +class StringViewIsalnum(AbstractTemplate): + """ + Return True if the string is all alphanumeric characters else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isalnum = cuda.declare_device( + "pyisalnum", + types.boolean(types.CPointer(string_view), types.int64) +) + +def isdecimal(st): + return st.isdecimal() + +@cuda_decl_registry.register_global(isdecimal) +class StringViewIsdecimal(AbstractTemplate): + """ + Return True if the string is all decimal characters else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isdecimal = cuda.declare_device( + "pyisdecimal", + types.boolean(types.CPointer(string_view), types.int64) +) + +def isnumeric(st): + return st.isnumeric() + +@cuda_decl_registry.register_global(isnumeric) +class StringViewIsnumeric(AbstractTemplate): + """ + Return True if the string represents a valid number else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isnumeric = cuda.declare_device( + "pyisnumeric", + types.boolean(types.CPointer(string_view), types.int64) +) + +def isspace(st): + return st.isspace() + +@cuda_decl_registry.register_global(isspace) +class StringViewIsspace(AbstractTemplate): + """ + Return True if the string is all white space else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isspace = cuda.declare_device( + "pyisspace", + types.boolean(types.CPointer(string_view), types.int64) +) + +def isupper(st): + return st.isupper() + +@cuda_decl_registry.register_global(isupper) +class StringViewIsupper(AbstractTemplate): + """ + Return True if the string's alphabetic characters are all uppercase else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isupper = cuda.declare_device( + "pyisupper", + types.boolean(types.CPointer(string_view), types.int64) +) + +def islower(st): + return st.islower() + +@cuda_decl_registry.register_global(islower) +class StringViewIslower(AbstractTemplate): + """ + Return True if the string's alphabetic characters are all lowercase else false + """ + + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_islower = cuda.declare_device( + "pyislower", + types.boolean(types.CPointer(string_view), types.int64) +) + + +def count(st, substr): + return st.count(substr) + +@cuda_decl_registry.register_global(count) +class StringViewCount(AbstractTemplate): + """ + Return the number of non-overlapping occurences of a substring within a string + """ + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and isinstance(args[1], any_string_ty): + return nb_signature(types.int32, string_view, string_view) + +_string_view_count = cuda.declare_device( + "pycount", + types.int32(types.CPointer(string_view), types.CPointer(string_view)) +) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py new file mode 100644 index 00000000000..7d7f068e798 --- /dev/null +++ b/python/strings_udf/strings_udf/lowering.py @@ -0,0 +1,516 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from numba import types +from numba.core import cgutils +from numba.core.typing import signature as nb_signature +from numba.cuda.cudadrv import nvvm +from numba.cuda.cudaimpl import lower as cuda_lower +from numba.cuda.cudaimpl import registry as cuda_lowering_registry +from strings_udf._typing import ( + StringView, + _string_view_endswith, + _string_view_len, + _string_view_startswith, + _string_view_contains, + _string_view_eq, + _string_view_ne, + _string_view_ge, + _string_view_le, + _string_view_gt, + _string_view_lt, + _string_view_find, + _string_view_rfind, + _string_view_isdigit, + _string_view_isalnum, + _string_view_isnumeric, + _string_view_isdecimal, + _string_view_isspace, + _string_view_isupper, + _string_view_islower, + _string_view_count, + isdigit, + isalnum, + isnumeric, + isdecimal, + isspace, + isupper, + islower, + ends_with, + starts_with, + string_view, + find, + rfind, + count, +) + +import operator + +# String function implementations +def call_len_string_view(st): + return _string_view_len(st) + + +@cuda_lower(len, string_view) +def string_view_len_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + result = context.compile_internal( + builder, + call_len_string_view, + nb_signature(types.int32, types.CPointer(string_view)), + (sv_ptr,), + ) + + return result + + +def call_string_view_contains(st, substr): + return _string_view_contains(st, substr) + + +@cuda_lower(operator.contains, string_view, string_view) +def string_view_contains_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + substr_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], substr_ptr) + result = context.compile_internal( + builder, + call_string_view_contains, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, substr_ptr), + ) + + return result + + +def call_string_view_eq(st, rhs): + return _string_view_eq(st, rhs) + + +@cuda_lower(operator.eq, string_view, string_view) +def string_view_eq_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], rhs_ptr) + + result = context.compile_internal( + builder, + call_string_view_eq, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, rhs_ptr), + ) + + return result + + +def call_string_view_ne(st, rhs): + return _string_view_ne(st, rhs) + + +@cuda_lower(operator.ne, string_view, string_view) +def string_view_ne_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], rhs_ptr) + + result = context.compile_internal( + builder, + call_string_view_ne, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, rhs_ptr), + ) + + return result + + +def call_string_view_ge(st, rhs): + return _string_view_ge(st, rhs) + + +@cuda_lower(operator.ge, string_view, string_view) +def string_view_ge_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], rhs_ptr) + + result = context.compile_internal( + builder, + call_string_view_ge, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, rhs_ptr), + ) + + return result + + +def call_string_view_le(st, rhs): + return _string_view_le(st, rhs) + + +@cuda_lower(operator.le, string_view, string_view) +def string_view_le_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], rhs_ptr) + + result = context.compile_internal( + builder, + call_string_view_le, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, rhs_ptr), + ) + + return result + + +def call_string_view_gt(st, rhs): + return _string_view_gt(st, rhs) + + +@cuda_lower(operator.gt, string_view, string_view) +def string_view_gt_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], rhs_ptr) + + result = context.compile_internal( + builder, + call_string_view_gt, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, rhs_ptr), + ) + + return result + + +def call_string_view_lt(st, rhs): + return _string_view_lt(st, rhs) + + +@cuda_lower(operator.lt, string_view, string_view) +def string_view_lt_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], rhs_ptr) + + result = context.compile_internal( + builder, + call_string_view_lt, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, rhs_ptr), + ) + + return result + + +# read-only functions +# We will provide only one overload for this set of functions, which will expect a +# string_view. When a literal is encountered, numba will promote it to a string_view +# whereas when a dstring is encountered, numba will convert it to a view via its native +# view() method + +# casts +@cuda_lowering_registry.lower_cast(types.StringLiteral, string_view) +def cast_string_literal_to_string_view(context, builder, fromty, toty, val): + """ + cast a literal to a string_view + """ + # create an empty string_view + sv = cgutils.create_struct_proxy(string_view)(context, builder) + + # set the empty strview data pointer to point to the literal value + s = context.insert_const_string(builder.module, fromty.literal_value) + sv.data = context.insert_addrspace_conv(builder, s, nvvm.ADDRSPACE_CONSTANT) + sv.length = context.get_constant(types.int32, len(fromty.literal_value)) + sv.bytes = context.get_constant( + types.int32, len(fromty.literal_value.encode("UTF-8")) + ) + + return sv._getvalue() + + +def call_string_view_startswith(sv, substr): + return _string_view_startswith(sv, substr) + + +@cuda_lower(starts_with, string_view, string_view) +def string_view_startswith_impl(context, builder, sig, args): + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], substr_ptr) + + result = context.compile_internal( + builder, + call_string_view_startswith, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, substr_ptr), + ) + + return result + + +def call_string_view_endswith(sv, substr): + return _string_view_endswith(sv, substr) + + +@cuda_lower(ends_with, string_view, string_view) +def string_view_endswith_impl(context, builder, sig, args): + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], substr_ptr) + + result = context.compile_internal( + builder, + call_string_view_endswith, + nb_signature( + types.boolean, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, substr_ptr), + ) + + return result + + +def call_string_view_count(st, substr): + return _string_view_count(st, substr) + +@cuda_lower(count, string_view, string_view) +def string_view_coount_impl(context, builder, sig, args): + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], substr_ptr) + + result = context.compile_internal( + builder, + call_string_view_count, + nb_signature( + types.int32, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, substr_ptr), + ) + + return result + + +def call_string_view_find(sv, substr): + return _string_view_find(sv, substr) + +@cuda_lower(find, string_view, string_view) +def string_view_find_impl(context, builder, sig, args): + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], substr_ptr) + + result = context.compile_internal( + builder, + call_string_view_find, + nb_signature( + types.int32, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, substr_ptr), + ) + + return result + +def call_string_view_rfind(sv, substr): + return _string_view_rfind(sv, substr) + +@cuda_lower(rfind, string_view, string_view) +def string_view_rfind_impl(context, builder, sig, args): + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + + builder.store(args[0], sv_ptr) + builder.store(args[1], substr_ptr) + + result = context.compile_internal( + builder, + call_string_view_rfind, + nb_signature( + types.int32, types.CPointer(string_view), types.CPointer(string_view) + ), + (sv_ptr, substr_ptr), + ) + + return result + +def call_string_view_isdigit(st, tbl): + return _string_view_isdigit(st, tbl) + + +@cuda_lower(isdigit, string_view) +def string_view_isdigit_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isdigit, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + +def call_string_view_isalnum(st, tbl): + return _string_view_isalnum(st, tbl) + + +@cuda_lower(isalnum, string_view) +def string_view_isalnum_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isalnum, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + +def call_string_view_isnumeric(st, tbl): + return _string_view_isnumeric(st, tbl) + + +@cuda_lower(isnumeric, string_view) +def string_view_isnumeric_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isnumeric, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + +def call_string_view_isdecimal(st, tbl): + return _string_view_isdecimal(st, tbl) + + +@cuda_lower(isdecimal, string_view) +def string_view_isdecimal_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isdecimal, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + +def call_string_view_isspace(st, tbl): + return _string_view_isspace(st, tbl) + + +@cuda_lower(isspace, string_view) +def string_view_isspace_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isspace, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + +def call_string_view_isupper(st, tbl): + return _string_view_isupper(st, tbl) + + +@cuda_lower(isupper, string_view) +def string_view_isupper_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isupper, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + + +def call_string_view_islower(st, tbl): + return _string_view_islower(st, tbl) + + +@cuda_lower(islower, string_view) +def string_view_islower_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_islower, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result diff --git a/python/strings_udf/strings_udf/tests/__init__.py b/python/strings_udf/strings_udf/tests/__init__.py new file mode 100644 index 00000000000..c7efe5c838e --- /dev/null +++ b/python/strings_udf/strings_udf/tests/__init__.py @@ -0,0 +1,6 @@ +from strings_udf import lowering +from strings_udf._lib.cudf_jit_udf import get_character_flags_table_ptr + +character_flags_table_ptr = get_character_flags_table_ptr() +lowering.character_flags_table_ptr = character_flags_table_ptr + diff --git a/python/strings_udf/strings_udf/tests/test_cmpops.py b/python/strings_udf/strings_udf/tests/test_cmpops.py new file mode 100644 index 00000000000..95e4a9cc66a --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_cmpops.py @@ -0,0 +1,71 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +import strings_udf.lowering + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_eq(data, rhs): + # tests the `==` operator in string udfs + + def func(st): + return st == rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_ne(data, rhs): + # tests the `!=` operator in string udfs + + def func(st): + return st != rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_ge(data, rhs): + # tests the `>=` operator in string udfs + + def func(st): + return st >= rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_le(data, rhs): + # tests the `<=` operator in string udfs + + def func(st): + return st <= rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_gt(data, rhs): + # tests the `>` operator in string udfs + + def func(st): + return st > rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_lt(data, rhs): + # tests the `<` operator in string udfs + + def func(st): + return st < rhs + + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_contains.py b/python/strings_udf/strings_udf/tests/test_contains.py new file mode 100644 index 00000000000..ca397209c88 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_contains.py @@ -0,0 +1,15 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) +def test_string_udf_contains(data, substr): + # Tests contains for string UDFs + + def func(st): + return substr in st + + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_count.py b/python/strings_udf/strings_udf/tests/test_count.py new file mode 100644 index 00000000000..b30dd29332b --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_count.py @@ -0,0 +1,19 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import count + +@pytest.mark.parametrize( + "data", [ + ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] + ] +) +@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc", ""]) +def test_string_udf_count(data, substr): + # tests the `count` function in string udfs + + def func(st): + return count(st, substr) + + run_udf_test(data, func, 'int32') diff --git a/python/strings_udf/strings_udf/tests/test_endswith.py b/python/strings_udf/strings_udf/tests/test_endswith.py new file mode 100644 index 00000000000..8b72ea561a2 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_endswith.py @@ -0,0 +1,19 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import ends_with + +@pytest.mark.parametrize( + "data", [ + ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] + ] +) +@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc"]) +def test_string_udf_endswith(data, substr): + # tests the `endswith` function in string udfs + + def func(st): + return ends_with(st, substr) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_find.py b/python/strings_udf/strings_udf/tests/test_find.py new file mode 100644 index 00000000000..e287a7b2943 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_find.py @@ -0,0 +1,19 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import find + +@pytest.mark.parametrize( + "data", [ + ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] + ] +) +@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc", "", "gpu"]) +def test_string_udf_find(data, substr): + # tests the `find` function in string udfs + + def func(st): + return find(st, substr) + + run_udf_test(data, func, 'int32') diff --git a/python/strings_udf/strings_udf/tests/test_isalnum.py b/python/strings_udf/strings_udf/tests/test_isalnum.py new file mode 100644 index 00000000000..9bbc959582e --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isalnum.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isalnum + +@pytest.mark.parametrize("data", [["1", "1@2", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isalnum(data): + # tests the `rfind` function in string udfs + + def func(st): + return isalnum(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isdecimal.py b/python/strings_udf/strings_udf/tests/test_isdecimal.py new file mode 100644 index 00000000000..e4053ac52df --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isdecimal.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isdecimal + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isdecimal(data): + # tests the `isdecimal` function in string udfs + + def func(st): + return isdecimal(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isdigit.py b/python/strings_udf/strings_udf/tests/test_isdigit.py new file mode 100644 index 00000000000..59e2a467433 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isdigit.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isdigit + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isdigit(data): + # tests the `isdigit` function in string udfs + + def func(st): + return isdigit(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_islower.py b/python/strings_udf/strings_udf/tests/test_islower.py new file mode 100644 index 00000000000..23e732185d4 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_islower.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import islower + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003", 'abc', 'b a', 'AbC']]) +def test_string_udf_islower(data): + # tests the `islower` function in string udfs + + def func(st): + return islower(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isnumeric.py b/python/strings_udf/strings_udf/tests/test_isnumeric.py new file mode 100644 index 00000000000..6e0d9ad4d9b --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isnumeric.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isnumeric + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isnumeric(data): + # tests the `isnumeric` function in string udfs + + def func(st): + return isnumeric(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isspace.py b/python/strings_udf/strings_udf/tests/test_isspace.py new file mode 100644 index 00000000000..556ed1b4b87 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isspace.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isspace + +@pytest.mark.parametrize("data", [["1", " x ", " ", "2.1", "", "0003"]]) +def test_string_udf_isspace(data): + # tests the `isspace` function in string udfs + + def func(st): + return isspace(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isupper.py b/python/strings_udf/strings_udf/tests/test_isupper.py new file mode 100644 index 00000000000..08fbc3163da --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isupper.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isupper + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]]) +def test_string_udf_isupper(data): + # tests the `isupper` function in string udfs + + def func(st): + return isupper(st) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_length.py b/python/strings_udf/strings_udf/tests/test_length.py new file mode 100644 index 00000000000..53f57d9510e --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_length.py @@ -0,0 +1,15 @@ +# Copyright (c) 2021-2022, NVIDIA CORPORATION. + +import pytest + +from .utils import run_udf_test + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022"]]) +def test_string_udf_len(data): + # tests the `len` function in string udfs + + def func(st): + return len(st) + + run_udf_test(data, func, "int64") diff --git a/python/strings_udf/strings_udf/tests/test_rfind.py b/python/strings_udf/strings_udf/tests/test_rfind.py new file mode 100644 index 00000000000..369826bfa5c --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_rfind.py @@ -0,0 +1,19 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import rfind + +@pytest.mark.parametrize( + "data", [ + ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] + ] +) +@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc", "", "gpu"]) +def test_string_udf_rfind(data, substr): + # tests the `rfind` function in string udfs + + def func(st): + return rfind(st, substr) + + run_udf_test(data, func, 'int32') diff --git a/python/strings_udf/strings_udf/tests/test_startswith.py b/python/strings_udf/strings_udf/tests/test_startswith.py new file mode 100644 index 00000000000..1550b11476e --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_startswith.py @@ -0,0 +1,19 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import starts_with + +@pytest.mark.parametrize( + "data", [ + ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] + ] +) +@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc"]) +def test_string_udf_startswith(data, substr): + # tests the `startswith` function in string udfs + + def func(st): + return starts_with(st, substr) + + run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py new file mode 100644 index 00000000000..cecfe10bb1c --- /dev/null +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -0,0 +1,46 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +import cudf +import numba +import numpy as np +import pandas as pd +from cudf.testing._utils import assert_eq +from numba import cuda +from numba.core.typing import signature as nb_signature +from numba.types import CPointer, void +from strings_udf import ptxpath +from strings_udf._lib.cudf_jit_udf import to_string_view_array +from strings_udf._typing import str_view_arg_handler, string_view + + +def run_udf_test(data, func, dtype): + dtype = np.dtype(dtype) + cudf_column = cudf.Series(data)._column + str_view_ary = to_string_view_array(cudf_column) + + output_ary = cudf.core.column.column_empty(len(data), dtype=dtype) + + kernel = get_kernel(func, dtype) + kernel.forall(len(data))(str_view_ary, output_ary) + got = cudf.Series(output_ary, dtype=dtype) + expect = pd.Series(data).apply(func) + assert_eq(expect, got, check_dtype=False) + + +def get_kernel(func, dtype): + func = cuda.jit(device=True)(func) + + def execute_function(input_strings, output_col): + id = cuda.grid(1) + if id < len(output_col): + st = input_strings[id] + result = func(st) + output_col[id] = result + + outty = numba.np.numpy_support.from_dtype(dtype) + sig = nb_signature(void, CPointer(string_view), outty[::1]) + kernel = cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler])( + execute_function + ) + + return kernel From f9f0ac2ef595fb13f407c8214a6b2b41e171b7ad Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 20 Jul 2022 07:05:44 -0700 Subject: [PATCH 041/212] add other _is_ functions --- python/cudf/cudf/core/udf/masked_typing.py | 7 + python/cudf/cudf/core/udf/strings_lowering.py | 155 +++++++++++++++ python/cudf/cudf/core/udf/strings_typing.py | 93 +++++++++ python/cudf/cudf/core/udf/utils.py | 3 +- python/cudf/cudf/tests/test_udf_masked_ops.py | 185 ++++++++++++++++++ .../strings_udf/cpp/src/strings/udf/shim.cu | 11 ++ python/strings_udf/strings_udf/_typing.py | 19 +- python/strings_udf/strings_udf/lowering.py | 25 +++ .../strings_udf/tests/test_isalpha.py | 14 ++ 9 files changed, 510 insertions(+), 2 deletions(-) create mode 100644 python/strings_udf/strings_udf/tests/test_isalpha.py diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index f3a25231839..41a4ef230fe 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -53,6 +53,13 @@ def __init__(self, value): # TODO - replace object with stringview immediately if isinstance(value, (types.PyObject, StringView)): self.value_type = string_view + + from strings_udf import lowering + from strings_udf._lib.cudf_jit_udf import get_character_flags_table_ptr + + character_flags_table_ptr = get_character_flags_table_ptr() + lowering.character_flags_table_ptr = character_flags_table_ptr + elif isinstance(value, SUPPORTED_NUMBA_TYPES): self.value_type = value else: diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index 43f613b791d..77fb5f90dde 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -8,6 +8,13 @@ string_view_find_impl, string_view_rfind_impl, string_view_contains_impl, + string_view_isalnum_impl, + string_view_isalpha_impl, + string_view_isdecimal_impl, + string_view_isdigit_impl, + string_view_isupper_impl, + string_view_islower_impl, + string_view_isspace_impl ) from numba import types @@ -149,3 +156,151 @@ def masked_string_view_contains_impl(context, builder, sig, args): ret.value = result ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) return ret._getvalue() + +@cuda_lower( + "MaskedType.isalnum", MaskedType(string_view) +) +def masked_string_view_isalnum_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_isalnum_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() + +@cuda_lower( + "MaskedType.isalpha", MaskedType(string_view) +) +def masked_string_view_isalpha_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_isalpha_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() + +@cuda_lower( + "MaskedType.isdigit", MaskedType(string_view) +) +def masked_string_view_isdigit_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_isdigit_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() + +@cuda_lower( + "MaskedType.isdecimal", MaskedType(string_view) +) +def masked_string_view_isdecimal_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_isdecimal_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() + +@cuda_lower( + "MaskedType.isupper", MaskedType(string_view) +) +def masked_string_view_isupper_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_isupper_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() + +@cuda_lower( + "MaskedType.islower", MaskedType(string_view) +) +def masked_string_view_islower_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_islower_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() + + +@cuda_lower( + "MaskedType.isspace", MaskedType(string_view) +) +def masked_string_view_isspace_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + + result = string_view_isspace_impl( + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,) + ) + + ret.value = result + ret.valid = masked_sv_str.valid + return ret._getvalue() diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 2fce695ed5b..f27b8d36622 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -103,6 +103,63 @@ def generic(self, args, kws): MaskedType(types.int32), MaskedType(string_view), recvr=self.this ) +class MaskedStringViewIsAlnum(AbstractTemplate): + key = "MaskedType.isalnum" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + +class MaskedStringViewIsAlpha(AbstractTemplate): + key = "MaskedType.isalpha" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + +class MaskedStringViewIsDecimal(AbstractTemplate): + key = "MaskedType.isdecimal" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + +class MaskedStringViewIsDigit(AbstractTemplate): + key = "MaskedType.isdigit" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + +class MaskedStringViewIsLower(AbstractTemplate): + key = "MaskedType.islower" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + +class MaskedStringViewIsUpper(AbstractTemplate): + key = "MaskedType.isupper" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + +class MaskedStringViewIsSpace(AbstractTemplate): + key = "MaskedType.isspace" + + def generic(self, args, kws): + return nb_signature( + MaskedType(types.boolean), recvr=self.this + ) + + @cuda_decl_registry.register_attr class MaskedStringViewAttrs(AttributeTemplate): key = MaskedType(string_view) @@ -127,6 +184,42 @@ def resolve_rfind(self, mod): MaskedStringViewRFind, MaskedType(string_view) ) + def resolve_isalnum(self, mod): + return types.BoundFunction( + MaskedStringViewIsAlnum, MaskedType(string_view) + ) + + def resolve_isalpha(self, mod): + return types.BoundFunction( + MaskedStringViewIsAlpha, MaskedType(string_view) + ) + + def resolve_isdecimal(self, mod): + return types.BoundFunction( + MaskedStringViewIsDecimal, MaskedType(string_view) + ) + + def resolve_isdigit(self, mod): + return types.BoundFunction( + MaskedStringViewIsDigit, MaskedType(string_view) + ) + + def resolve_islower(self, mod): + return types.BoundFunction( + MaskedStringViewIsLower, MaskedType(string_view) + ) + + def resolve_isupper(self, mod): + return types.BoundFunction( + MaskedStringViewIsUpper, MaskedType(string_view) + ) + + def resolve_isspace(self, mod): + return types.BoundFunction( + MaskedStringViewIsSpace, MaskedType(string_view) + ) + + def resolve_value(self, mod): return string_view diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index b19543cf651..ee7fff9f771 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -24,7 +24,6 @@ from cudf.api.types import is_string_dtype from strings_udf._typing import str_view_arg_handler, string_view from strings_udf import ptxpath -from strings_udf._lib.cudf_jit_udf import to_string_view_array from cudf.utils.utils import _cudf_nvtx_annotate @@ -240,6 +239,8 @@ def _get_kernel(kernel_string, globals_, sig, func): return kernel def _launch_arg_from_col(col): + from strings_udf._lib.cudf_jit_udf import to_string_view_array + data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(col) mask = col.mask if mask is None: diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 14d83e8564f..b599114202c 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -840,3 +840,188 @@ def func(row): return cmpop(st, other) run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "gpu", + "2022", + "cuDF", + "again_gpu", + ] + } + ], +) +def test_string_udf_isalnum(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.isalnum() + + run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "", + " ", + "12 ab", + "@2a", + ] + } + ], +) +def test_string_udf_isalpha(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.isalpha() + + run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "123", + "", + " ", + "12 ab", + "@2a", + ] + } + ], +) +def test_string_udf_isdigit(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.isdigit() + + run_masked_udf_test(func, data, check_dtype=False) + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "", + " ", + "12 ab", + "@2a", + "12.34", + "0.123", + ".123" + ".12abc" + ] + } + ], +) +def test_string_udf_isdecimal(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.isdecimal() + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "", + "rApIdS", + "12 ab", + "@2a", + "12.34", + "ABC DEF" + ] + } + ], +) +def test_string_udf_isupper(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.isupper() + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "rapids", + "AI", + "", + "rApIdS", + "12 ab", + "@2a", + "12.34", + "abc def" + ] + } + ], +) +def test_string_udf_islower(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.islower() + + run_masked_udf_test(func, data, check_dtype=False) + + +@pytest.mark.parametrize( + "data", + [ + { + "str_col": [ + "cudf", + "", + " ", + " 123 ", + "2022 2222", + "cuDF", + ] + } + ], +) +def test_string_udf_isspace(data): + data = cudf.DataFrame(data) + + def func(row): + st = row['str_col'] + return st.isspace() + + run_masked_udf_test(func, data, check_dtype=False) diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu index 9d5cd6684c1..ec12d9be1d0 100644 --- a/python/strings_udf/cpp/src/strings/udf/shim.cu +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -254,6 +254,17 @@ __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) { return 0; } +/* +isalpha +*/ +extern "C" +__device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t chars_table) { + cudf::string_view* str_view = reinterpret_cast(str); + + *nb_retval = is_alpha(reinterpret_cast(chars_table), *str_view); + return 0; +} + /* count */ diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index 30ff520405e..7b04915e43f 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -358,7 +358,7 @@ def isalnum(st): return st.isalnum() @cuda_decl_registry.register_global(isalnum) -class StringViewIsalnum(AbstractTemplate): +class StringViewIsAlnum(AbstractTemplate): """ Return True if the string is all alphanumeric characters else false """ @@ -372,6 +372,23 @@ def generic(self, args, kws): types.boolean(types.CPointer(string_view), types.int64) ) +def isalpha(st): + return st.isalpha() + +@cuda_decl_registry.register_global(isalpha) +class StringViewIsAlpha(AbstractTemplate): + """ + Return True if the string is all alphabetical characters else false + """ + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and len(args) == 1: + return nb_signature(types.boolean, string_view) + +_string_view_isalpha = cuda.declare_device( + "pyisalpha", + types.boolean(types.CPointer(string_view), types.int64) +) + def isdecimal(st): return st.isdecimal() diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 7d7f068e798..f8a6df3b201 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -22,6 +22,7 @@ _string_view_rfind, _string_view_isdigit, _string_view_isalnum, + _string_view_isalpha, _string_view_isnumeric, _string_view_isdecimal, _string_view_isspace, @@ -30,6 +31,7 @@ _string_view_count, isdigit, isalnum, + isalpha, isnumeric, isdecimal, isspace, @@ -45,6 +47,8 @@ import operator +character_flags_table_ptr = None + # String function implementations def call_len_string_view(st): return _string_view_len(st) @@ -409,6 +413,27 @@ def string_view_isalnum_impl(context, builder, sig, args): return result +def call_string_view_isalpha(st, tbl): + return _string_view_isalpha(st, tbl) + + +@cuda_lower(isalpha, string_view) +def string_view_isalpha_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isalpha, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result + def call_string_view_isnumeric(st, tbl): return _string_view_isnumeric(st, tbl) diff --git a/python/strings_udf/strings_udf/tests/test_isalpha.py b/python/strings_udf/strings_udf/tests/test_isalpha.py new file mode 100644 index 00000000000..b2f54f5c273 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_isalpha.py @@ -0,0 +1,14 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +from .utils import run_udf_test +import pytest +from strings_udf._typing import isalpha + +@pytest.mark.parametrize("data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]]) +def test_string_udf_isalpha(data): + # tests the `isalpha` function in string udfs + + def func(st): + return isalpha(st) + + run_udf_test(data, func, 'bool') From 35d238b0fda77fad1d4e281ee636ddd009807e7a Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 20 Jul 2022 12:15:53 -0700 Subject: [PATCH 042/212] updates --- .../cudf/_lib/cpp/column/column_factories.pxd | 7 - python/cudf/cudf/core/indexed_frame.py | 2 +- python/cudf/cudf/core/udf/__init__.py | 1 + python/cudf/cudf/core/udf/masked_typing.py | 4 +- python/cudf/cudf/core/udf/row_function.py | 1 - python/cudf/cudf/core/udf/utils.py | 16 +- .../strings_udf/_lib/cudf_jit_udf.cpp | 25684 ---------------- 7 files changed, 5 insertions(+), 25710 deletions(-) delete mode 100644 python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp diff --git a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd index feb20b9ffa2..d3148dd28cc 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd @@ -6,9 +6,6 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type, mask_state, size_type -cdef extern from "cudf/strings/string_view.hpp" namespace "cudf" nogil: - cdef cppclass string_view - cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_numeric_column(data_type type, size_type size, @@ -16,7 +13,3 @@ cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_column_from_scalar (const scalar & s, size_type size) except + - - cdef unique_ptr[column] make_strings_column( - string_view* inp, - ) diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 351a26e3aef..4fa2a1b13fa 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -1809,7 +1809,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): offsets.append(col.offset) launch_args += offsets launch_args += list(args) - + try: kernel.forall(len(self))(*launch_args) except Exception as e: diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 62db19401b5..0977238935d 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -1 +1,2 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. from . import masked_typing, masked_lowering, strings_typing, strings_lowering diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 41a4ef230fe..60feea74aa7 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -70,7 +70,7 @@ def __init__(self, value): self.value_type = types.Poison( "\n\n\n Unsupported MaskedType. This is usually caused by " "attempting to use a column of unsupported dtype in a UDF. " - f"Supported dtypes are {SUPPORTED_NUMBA_TYPES}" + f"Supported dtypes are {SUPPORTED_NUMBA_TYPES}\n\n\n" ) super().__init__(name=f"Masked({self.value_type})") @@ -160,7 +160,7 @@ class MaskedConstructor(ConcreteTemplate): | datetime_cases | timedelta_cases | {types.boolean} - | {types.pyobject, string_view} + | {string_view} ) ] diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index d5c86c393a8..fb9e9690ce0 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -55,7 +55,6 @@ def _get_frame_row_type(dtype): else: sizes.append(field[0].itemsize) - #sizes = [val[0].itemsize for val in dtype.fields.values()] for i, (name, info) in enumerate(dtype.fields.items()): # *info* consists of the element dtype, its offset from the beginning # of the record, and an optional "title" containing metadata. diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index ee7fff9f771..936c638fcb0 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -219,10 +219,7 @@ def _compile_or_get(frame, func, args, kernel_getter=None): # could be a MaskedType or a scalar type. kernel, scalar_return_type = kernel_getter(frame, func, args) - - #np_return_type = scalar_return_type if scalar_return_type is dstring else numpy_support.as_dtype(scalar_return_type) np_return_type = numpy_support.as_dtype(scalar_return_type) - precompiled[cache_key] = (kernel, np_return_type) return kernel, np_return_type @@ -249,18 +246,7 @@ def _launch_arg_from_col(col): return data, mask def _return_col_from_dtype(dt, size): - #if dt is dstring: - # # - # return rmm.DeviceBuffer( - # size=int(size * dstring_model.size_bytes) - # ) - #else: - # return cp.empty(size, dtype=dt) return cp.empty(size, dtype=dt) def _post_process_output_col(col, retty): - #if retty == dstring: - # return from_dstring_array(col) - #else: - # return as_column(col) - return as_column(col) + return as_column(col, retty) diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp deleted file mode 100644 index b23779aef4d..00000000000 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.cpp +++ /dev/null @@ -1,25684 +0,0 @@ -/* Generated by Cython 0.29.30 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "depends": [ - "../../cpp/include/cudf/column/column.hpp", - "../../cpp/include/cudf/column/column_view.hpp", - "../../cpp/include/cudf/strings/detail/char_tables.hpp", - "../../cpp/include/cudf/types.hpp", - "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib/python3.8/site-packages/cuda" - ], - "extra_compile_args": [ - "-std=c++17" - ], - "include_dirs": [ - "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib/python3.8/site-packages/cuda", - "/home/nfs/brmiller/anaconda3/envs/cudf_dev/include/cudf", - "/home/nfs/brmiller/anaconda3/envs/cudf_dev/include/rapids/libcudacxx", - "../../cpp/include", - "/usr/local/cuda/include" - ], - "language": "c++", - "libraries": [ - "cudart", - "cudf", - "nvrtc", - "cudf_strings_udf" - ], - "library_dirs": [ - "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib/python3.8/site-packages", - "/home/nfs/brmiller/anaconda3/envs/cudf_dev/lib", - "/usr/local/cuda/lib64", - "../../cpp/build" - ], - "name": "strings_udf._lib.cudf_jit_udf", - "sources": [ - "strings_udf/_lib/cudf_jit_udf.pyx" - ] - }, - "module_name": "strings_udf._lib.cudf_jit_udf" -} -END: Cython Metadata */ - -#ifndef PY_SSIZE_T_CLEAN -#define PY_SSIZE_T_CLEAN -#endif /* PY_SSIZE_T_CLEAN */ -#include "Python.h" -#ifndef Py_PYTHON_H - #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_29_30" -#define CYTHON_HEX_VERSION 0x001D1EF0 -#define CYTHON_FUTURE_DIVISION 1 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif - #ifndef __fastcall - #define __fastcall - #endif -#endif -#ifndef DL_IMPORT - #define DL_IMPORT(t) t -#endif -#ifndef DL_EXPORT - #define DL_EXPORT(t) t -#endif -#define __PYX_COMMA , -#ifndef HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #undef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 0 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #undef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 1 - #undef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 - #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC - #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_HEX >= 0x07030900) - #endif -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 - #undef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS 0 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 - #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC - #define CYTHON_UPDATE_DESCRIPTOR_DOC 0 - #endif -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 || PY_VERSION_HEX >= 0x030B00A2 - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #elif !defined(CYTHON_USE_UNICODE_WRITER) - #define CYTHON_USE_UNICODE_WRITER 1 - #endif - #ifndef CYTHON_AVOID_BORROWED_REFS - #define CYTHON_AVOID_BORROWED_REFS 0 - #endif - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #if PY_VERSION_HEX >= 0x030B00A4 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #elif !defined(CYTHON_FAST_THREAD_STATE) - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL (PY_VERSION_HEX < 0x030A0000) - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif - #ifndef CYTHON_USE_DICT_VERSIONS - #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1) - #endif - #if PY_VERSION_HEX >= 0x030B00A4 - #undef CYTHON_USE_EXC_INFO_STACK - #define CYTHON_USE_EXC_INFO_STACK 0 - #elif !defined(CYTHON_USE_EXC_INFO_STACK) - #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3) - #endif - #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC - #define CYTHON_UPDATE_DESCRIPTOR_DOC 1 - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #if PY_MAJOR_VERSION < 3 - #include "longintrepr.h" - #endif - #undef SHIFT - #undef BASE - #undef MASK - #ifdef SIZEOF_VOID_P - enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) }; - #endif -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict - #else - #define CYTHON_RESTRICT - #endif -#endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #endif - #endif - #ifndef CYTHON_FALLTHROUGH - #if __has_attribute(fallthrough) - #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) - #else - #define CYTHON_FALLTHROUGH - #endif - #endif - #if defined(__clang__ ) && defined(__apple_build_version__) - #if __apple_build_version__ < 7000000 - #undef CYTHON_FALLTHROUGH - #define CYTHON_FALLTHROUGH - #endif - #endif -#endif - -#ifndef __cplusplus - #error "Cython files generated with the C++ option must be compiled with a C++ compiler." -#endif -#ifndef CYTHON_INLINE - #if defined(__clang__) - #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) - #else - #define CYTHON_INLINE inline - #endif -#endif -template -void __Pyx_call_destructor(T& x) { - x.~T(); -} -template -class __Pyx_FakeReference { - public: - __Pyx_FakeReference() : ptr(NULL) { } - __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } - T *operator->() { return ptr; } - T *operator&() { return ptr; } - operator T&() { return *ptr; } - template bool operator ==(U other) { return *ptr == other; } - template bool operator !=(U other) { return *ptr != other; } - private: - T *ptr; -}; - -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_DefaultClassType PyType_Type -#if PY_VERSION_HEX >= 0x030B00A1 - static CYTHON_INLINE PyCodeObject* __Pyx_PyCode_New(int a, int k, int l, int s, int f, - PyObject *code, PyObject *c, PyObject* n, PyObject *v, - PyObject *fv, PyObject *cell, PyObject* fn, - PyObject *name, int fline, PyObject *lnos) { - PyObject *kwds=NULL, *argcount=NULL, *posonlyargcount=NULL, *kwonlyargcount=NULL; - PyObject *nlocals=NULL, *stacksize=NULL, *flags=NULL, *replace=NULL, *call_result=NULL, *empty=NULL; - const char *fn_cstr=NULL; - const char *name_cstr=NULL; - PyCodeObject* co=NULL; - PyObject *type, *value, *traceback; - PyErr_Fetch(&type, &value, &traceback); - if (!(kwds=PyDict_New())) goto end; - if (!(argcount=PyLong_FromLong(a))) goto end; - if (PyDict_SetItemString(kwds, "co_argcount", argcount) != 0) goto end; - if (!(posonlyargcount=PyLong_FromLong(0))) goto end; - if (PyDict_SetItemString(kwds, "co_posonlyargcount", posonlyargcount) != 0) goto end; - if (!(kwonlyargcount=PyLong_FromLong(k))) goto end; - if (PyDict_SetItemString(kwds, "co_kwonlyargcount", kwonlyargcount) != 0) goto end; - if (!(nlocals=PyLong_FromLong(l))) goto end; - if (PyDict_SetItemString(kwds, "co_nlocals", nlocals) != 0) goto end; - if (!(stacksize=PyLong_FromLong(s))) goto end; - if (PyDict_SetItemString(kwds, "co_stacksize", stacksize) != 0) goto end; - if (!(flags=PyLong_FromLong(f))) goto end; - if (PyDict_SetItemString(kwds, "co_flags", flags) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_code", code) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_consts", c) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_names", n) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_varnames", v) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_freevars", fv) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_cellvars", cell) != 0) goto end; - if (PyDict_SetItemString(kwds, "co_linetable", lnos) != 0) goto end; - if (!(fn_cstr=PyUnicode_AsUTF8AndSize(fn, NULL))) goto end; - if (!(name_cstr=PyUnicode_AsUTF8AndSize(name, NULL))) goto end; - if (!(co = PyCode_NewEmpty(fn_cstr, name_cstr, fline))) goto end; - if (!(replace = PyObject_GetAttrString((PyObject*)co, "replace"))) goto cleanup_code_too; - if (!(empty = PyTuple_New(0))) goto cleanup_code_too; // unfortunately __pyx_empty_tuple isn't available here - if (!(call_result = PyObject_Call(replace, empty, kwds))) goto cleanup_code_too; - Py_XDECREF((PyObject*)co); - co = (PyCodeObject*)call_result; - call_result = NULL; - if (0) { - cleanup_code_too: - Py_XDECREF((PyObject*)co); - co = NULL; - } - end: - Py_XDECREF(kwds); - Py_XDECREF(argcount); - Py_XDECREF(posonlyargcount); - Py_XDECREF(kwonlyargcount); - Py_XDECREF(nlocals); - Py_XDECREF(stacksize); - Py_XDECREF(replace); - Py_XDECREF(call_result); - Py_XDECREF(empty); - if (type) { - PyErr_Restore(type, value, traceback); - } - return co; - } -#else - #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\ - PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) -#endif - #define __Pyx_DefaultClassType PyType_Type -#endif -#ifndef Py_TPFLAGS_CHECKTYPES - #define Py_TPFLAGS_CHECKTYPES 0 -#endif -#ifndef Py_TPFLAGS_HAVE_INDEX - #define Py_TPFLAGS_HAVE_INDEX 0 -#endif -#ifndef Py_TPFLAGS_HAVE_NEWBUFFER - #define Py_TPFLAGS_HAVE_NEWBUFFER 0 -#endif -#ifndef Py_TPFLAGS_HAVE_FINALIZE - #define Py_TPFLAGS_HAVE_FINALIZE 0 -#endif -#ifndef METH_STACKLESS - #define METH_STACKLESS 0 -#endif -#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1 - #define PyMem_RawMalloc(n) PyMem_Malloc(n) - #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n) - #define PyMem_RawFree(p) PyMem_Free(p) -#endif -#if CYTHON_COMPILING_IN_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) -#else - #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) - #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#endif -#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) -#include "pythread.h" -#define Py_tss_NEEDS_INIT 0 -typedef int Py_tss_t; -static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { - *key = PyThread_create_key(); - return 0; -} -static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { - Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); - *key = Py_tss_NEEDS_INIT; - return key; -} -static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { - PyObject_Free(key); -} -static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { - return *key != Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { - PyThread_delete_key(*key); - *key = Py_tss_NEEDS_INIT; -} -static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { - return PyThread_set_key_value(*key, value); -} -static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { - return PyThread_get_key_value(*key); -} -#endif -#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) -#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) -#else -#define __Pyx_PyDict_NewPresized(n) PyDict_New() -#endif -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS -#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) -#else -#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #if defined(PyUnicode_IS_READY) - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #else - #define __Pyx_PyUnicode_READY(op) (0) - #endif - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) - #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) - #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) - #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) - #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE) - #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000 - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length)) - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) - #endif - #else - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u)) - #endif -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#endif -#if CYTHON_COMPILING_IN_PYPY - #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) -#else - #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) - #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\ - PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#endif -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#ifndef PyObject_Unicode - #define PyObject_Unicode PyObject_Str -#endif -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#if PY_VERSION_HEX >= 0x030900A4 - #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size) -#else - #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt) - #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size) -#endif -#if CYTHON_ASSUME_SAFE_MACROS - #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) -#else - #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsHash_t -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t __Pyx_PyIndex_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#endif - -#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS) - #if !defined(_USE_MATH_DEFINES) - #define _USE_MATH_DEFINES - #endif -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - -#define __PYX_MARK_ERR_POS(f_index, lineno) \ - { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; } -#define __PYX_ERR(f_index, lineno, Ln_error) \ - { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; } - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__strings_udf___lib__cudf_jit_udf -#define __PYX_HAVE_API__strings_udf___lib__cudf_jit_udf -/* Early includes */ -#include -#include -#include "ios" -#include "new" -#include "stdexcept" -#include "typeinfo" -#include -#include -#include - - #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600) - // move should be defined for these versions of MSVC, but __cplusplus isn't set usefully - #include - - namespace cython_std { - template typename std::remove_reference::type&& move(T& t) noexcept { return std::move(t); } - template typename std::remove_reference::type&& move(T&& t) noexcept { return std::move(t); } - } - - #endif - -#include -#include "rmm/cuda_stream_view.hpp" -#include "rmm/mr/device/device_memory_resource.hpp" -#include "rmm/device_buffer.hpp" -#include "cudf/types.hpp" -#include "cudf/column/column_view.hpp" -#include "cudf/column/column.hpp" -#include "cudf/strings/udf/udf_apis.hpp" -#include "cudf/strings/detail/char_tables.hpp" -#include "pythread.h" -#include -#include -#include "pystate.h" -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 1 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8) -#define __PYX_DEFAULT_STRING_ENCODING "utf8" -#define __Pyx_PyObject_FromString __Pyx_PyUnicode_FromString -#define __Pyx_PyObject_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#define __Pyx_uchar_cast(c) ((unsigned char)c) -#define __Pyx_long_cast(x) ((long)x) -#define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\ - (sizeof(type) < sizeof(Py_ssize_t)) ||\ - (sizeof(type) > sizeof(Py_ssize_t) &&\ - likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX) &&\ - (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\ - v == (type)PY_SSIZE_T_MIN))) ||\ - (sizeof(type) == sizeof(Py_ssize_t) &&\ - (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\ - v == (type)PY_SSIZE_T_MAX))) ) -static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) { - return (size_t) i < (size_t) limit; -} -#if defined (__cplusplus) && __cplusplus >= 201103L - #include - #define __Pyx_sst_abs(value) std::abs(value) -#elif SIZEOF_INT >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) abs(value) -#elif SIZEOF_LONG >= SIZEOF_SIZE_T - #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) - #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define __Pyx_sst_abs(value) llabs(value) -#elif defined (__GNUC__) - #define __Pyx_sst_abs(value) __builtin_llabs(value) -#else - #define __Pyx_sst_abs(value) ((value<0) ? -value : value) -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) -#define __Pyx_PyBytes_FromString PyBytes_FromString -#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); -#if PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) -#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); -#define __Pyx_PySequence_Tuple(obj)\ - (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#endif - - -/* Test for GCC > 2.95 */ -#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) - #define likely(x) __builtin_expect(!!(x), 1) - #define unlikely(x) __builtin_expect(!!(x), 0) -#else /* !__GNUC__ or GCC < 2.95 */ - #define likely(x) (x) - #define unlikely(x) (x) -#endif /* __GNUC__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime = NULL; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "strings_udf/_lib/cudf_jit_udf.pyx", - "stringsource", - "stream.pxd", - "memory_resource.pxd", - "device_buffer.pxd", - "column.pxd", -}; -/* ForceInitThreads.proto */ -#ifndef __PYX_FORCE_INIT_THREADS - #define __PYX_FORCE_INIT_THREADS 0 -#endif - -/* NoFastGil.proto */ -#define __Pyx_PyGILState_Ensure PyGILState_Ensure -#define __Pyx_PyGILState_Release PyGILState_Release -#define __Pyx_FastGIL_Remember() -#define __Pyx_FastGIL_Forget() -#define __Pyx_FastGilFuncInit() - -/* BufferFormatStructs.proto */ -#define IS_UNSIGNED(type) (((type) -1) > 0) -struct __Pyx_StructField_; -#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) -typedef struct { - const char* name; - struct __Pyx_StructField_* fields; - size_t size; - size_t arraysize[8]; - int ndim; - char typegroup; - char is_unsigned; - int flags; -} __Pyx_TypeInfo; -typedef struct __Pyx_StructField_ { - __Pyx_TypeInfo* type; - const char* name; - size_t offset; -} __Pyx_StructField; -typedef struct { - __Pyx_StructField* field; - size_t parent_offset; -} __Pyx_BufFmt_StackElem; -typedef struct { - __Pyx_StructField root; - __Pyx_BufFmt_StackElem* head; - size_t fmt_offset; - size_t new_count, enc_count; - size_t struct_alignment; - int is_complex; - char enc_type; - char new_packmode; - char enc_packmode; - char is_valid_array; -} __Pyx_BufFmt_Context; - -/* Atomics.proto */ -#include -#ifndef CYTHON_ATOMICS - #define CYTHON_ATOMICS 1 -#endif -#define __pyx_atomic_int_type int -#if CYTHON_ATOMICS && __GNUC__ >= 4 && (__GNUC_MINOR__ > 1 ||\ - (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL >= 2)) &&\ - !defined(__i386__) - #define __pyx_atomic_incr_aligned(value, lock) __sync_fetch_and_add(value, 1) - #define __pyx_atomic_decr_aligned(value, lock) __sync_fetch_and_sub(value, 1) - #ifdef __PYX_DEBUG_ATOMICS - #warning "Using GNU atomics" - #endif -#elif CYTHON_ATOMICS && defined(_MSC_VER) && 0 - #include - #undef __pyx_atomic_int_type - #define __pyx_atomic_int_type LONG - #define __pyx_atomic_incr_aligned(value, lock) InterlockedIncrement(value) - #define __pyx_atomic_decr_aligned(value, lock) InterlockedDecrement(value) - #ifdef __PYX_DEBUG_ATOMICS - #pragma message ("Using MSVC atomics") - #endif -#elif CYTHON_ATOMICS && (defined(__ICC) || defined(__INTEL_COMPILER)) && 0 - #define __pyx_atomic_incr_aligned(value, lock) _InterlockedIncrement(value) - #define __pyx_atomic_decr_aligned(value, lock) _InterlockedDecrement(value) - #ifdef __PYX_DEBUG_ATOMICS - #warning "Using Intel atomics" - #endif -#else - #undef CYTHON_ATOMICS - #define CYTHON_ATOMICS 0 - #ifdef __PYX_DEBUG_ATOMICS - #warning "Not using atomics" - #endif -#endif -typedef volatile __pyx_atomic_int_type __pyx_atomic_int; -#if CYTHON_ATOMICS - #define __pyx_add_acquisition_count(memview)\ - __pyx_atomic_incr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock) - #define __pyx_sub_acquisition_count(memview)\ - __pyx_atomic_decr_aligned(__pyx_get_slice_count_pointer(memview), memview->lock) -#else - #define __pyx_add_acquisition_count(memview)\ - __pyx_add_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) - #define __pyx_sub_acquisition_count(memview)\ - __pyx_sub_acquisition_count_locked(__pyx_get_slice_count_pointer(memview), memview->lock) -#endif - -/* MemviewSliceStruct.proto */ -struct __pyx_memoryview_obj; -typedef struct { - struct __pyx_memoryview_obj *memview; - char *data; - Py_ssize_t shape[8]; - Py_ssize_t strides[8]; - Py_ssize_t suboffsets[8]; -} __Pyx_memviewslice; -#define __Pyx_MemoryView_Len(m) (m.shape[0]) - - -/* "cuda/ccudart.pxd":1058 - * cudaFormatModeAuto = 1 - * - * ctypedef unsigned long long cudaSurfaceObject_t # <<<<<<<<<<<<<< - * - * cdef enum cudaTextureAddressMode: - */ -typedef unsigned PY_LONG_LONG __pyx_t_4cuda_7ccudart_cudaSurfaceObject_t; - -/* "cuda/ccudart.pxd":1089 - * int seamlessCubemap - * - * ctypedef unsigned long long cudaTextureObject_t # <<<<<<<<<<<<<< - * - * cdef enum cudaDataType_t: - */ -typedef unsigned PY_LONG_LONG __pyx_t_4cuda_7ccudart_cudaTextureObject_t; - -/* "cuda/ccudart.pxd":1664 - * - * - * ctypedef unsigned int GLenum # <<<<<<<<<<<<<< - * - * ctypedef unsigned int GLuint - */ -typedef unsigned int __pyx_t_4cuda_7ccudart_GLenum; - -/* "cuda/ccudart.pxd":1666 - * ctypedef unsigned int GLenum - * - * ctypedef unsigned int GLuint # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef unsigned int __pyx_t_4cuda_7ccudart_GLuint; - -/* "cuda/ccudart.pxd":1678 - * ctypedef void* EGLStreamKHR - * - * ctypedef unsigned int EGLint # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef unsigned int __pyx_t_4cuda_7ccudart_EGLint; - -/* "cuda/ccudart.pxd":1685 - * ctypedef void* EGLSyncKHR - * - * ctypedef uint32_t VdpDevice # <<<<<<<<<<<<<< - * - * ctypedef unsigned long long VdpGetProcAddress - */ -typedef uint32_t __pyx_t_4cuda_7ccudart_VdpDevice; - -/* "cuda/ccudart.pxd":1687 - * ctypedef uint32_t VdpDevice - * - * ctypedef unsigned long long VdpGetProcAddress # <<<<<<<<<<<<<< - * - * ctypedef uint32_t VdpVideoSurface - */ -typedef unsigned PY_LONG_LONG __pyx_t_4cuda_7ccudart_VdpGetProcAddress; - -/* "cuda/ccudart.pxd":1689 - * ctypedef unsigned long long VdpGetProcAddress - * - * ctypedef uint32_t VdpVideoSurface # <<<<<<<<<<<<<< - * - * ctypedef uint32_t VdpOutputSurface - */ -typedef uint32_t __pyx_t_4cuda_7ccudart_VdpVideoSurface; - -/* "cuda/ccudart.pxd":1691 - * ctypedef uint32_t VdpVideoSurface - * - * ctypedef uint32_t VdpOutputSurface # <<<<<<<<<<<<<< - * - * cdef cudaError_t cudaVDPAUGetDevice(int* device, VdpDevice vdpDevice, VdpGetProcAddress* vdpGetProcAddress) nogil except ?cudaErrorCallRequiresNewerDriver - */ -typedef uint32_t __pyx_t_4cuda_7ccudart_VdpOutputSurface; - -/*--- Type declarations ---*/ -struct __pyx_obj_3rmm_5_cuda_6stream_Stream; -struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor; -struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_ManagedMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_PoolMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_CallbackMemoryResource; -struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor; -struct __pyx_obj_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor; -struct __pyx_obj_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor; -struct __pyx_obj_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor; -struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer; -struct __pyx_obj_4cudf_4_lib_6column_Column; -struct __pyx_array_obj; -struct __pyx_MemviewEnum_obj; -struct __pyx_memoryview_obj; -struct __pyx_memoryviewslice_obj; -struct __pyx_t_4cuda_7ccudart_dim3; -struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc; -struct __pyx_t_4cuda_7ccudart__cudaArraySparseProperties_tileExtent_s; -struct __pyx_t_4cuda_7ccudart_cudaArraySparseProperties; -struct __pyx_t_4cuda_7ccudart_cudaArrayMemoryRequirements; -struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr; -struct __pyx_t_4cuda_7ccudart_cudaExtent; -struct __pyx_t_4cuda_7ccudart_cudaPos; -struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DParms; -struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DPeerParms; -struct __pyx_t_4cuda_7ccudart_cudaMemsetParams; -struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow; -struct __pyx_t_4cuda_7ccudart_cudaHostNodeParams; -union __pyx_t_4cuda_7ccudart_cudaStreamAttrValue; -union __pyx_t_4cuda_7ccudart_cudaKernelNodeAttrValue; -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_array_s; -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_mipmap_s; -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_linear_s; -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_pitch2D_s; -union __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_u; -struct __pyx_t_4cuda_7ccudart_cudaResourceDesc; -struct __pyx_t_4cuda_7ccudart_cudaResourceViewDesc; -struct __pyx_t_4cuda_7ccudart_cudaPointerAttributes; -struct __pyx_t_4cuda_7ccudart_cudaFuncAttributes; -struct __pyx_t_4cuda_7ccudart_cudaMemLocation; -struct __pyx_t_4cuda_7ccudart_cudaMemAccessDesc; -struct __pyx_t_4cuda_7ccudart_cudaMemPoolProps; -struct __pyx_t_4cuda_7ccudart_cudaMemPoolPtrExportData; -struct __pyx_t_4cuda_7ccudart_cudaMemAllocNodeParams; -struct __pyx_t_4cuda_7ccudart_CUuuid_st; -struct __pyx_t_4cuda_7ccudart_cudaDeviceProp; -struct __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_st; -struct __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_st; -struct __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_handle_win32_s; -union __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_u; -struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleDesc; -struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryBufferDesc; -struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryMipmappedArrayDesc; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_handle_win32_s; -union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_u; -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleDesc; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_fence_s; -union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_s; -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalParams; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_fence_s; -union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s; -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_s; -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitParams; -struct __pyx_t_4cuda_7ccudart_cudaKernelNodeParams; -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalNodeParams; -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitNodeParams; -struct __pyx_t_4cuda_7ccudart_cudaTextureDesc; -struct __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc_st; -union __pyx_t_4cuda_7ccudart__cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u; -struct __pyx_t_4cuda_7ccudart_cudaEglFrame_st; - -/* "cuda/ccudart.pxd":9 - * # is strictly prohibited. - * - * cdef enum cudaRoundMode: # <<<<<<<<<<<<<< - * cudaRoundNearest = 0 - * cudaRoundZero = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaRoundMode { - __pyx_e_4cuda_7ccudart_cudaRoundNearest = 0, - __pyx_e_4cuda_7ccudart_cudaRoundZero = 1, - __pyx_e_4cuda_7ccudart_cudaRoundPosInf = 2, - __pyx_e_4cuda_7ccudart_cudaRoundMinInf = 3 -}; - -/* "cuda/ccudart.pxd":20 - * unsigned int z - * - * cdef enum cudaError: # <<<<<<<<<<<<<< - * cudaSuccess = 0 - * cudaErrorInvalidValue = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaError { - __pyx_e_4cuda_7ccudart_cudaSuccess = 0, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidValue = 1, - __pyx_e_4cuda_7ccudart_cudaErrorMemoryAllocation = 2, - __pyx_e_4cuda_7ccudart_cudaErrorInitializationError = 3, - __pyx_e_4cuda_7ccudart_cudaErrorCudartUnloading = 4, - __pyx_e_4cuda_7ccudart_cudaErrorProfilerDisabled = 5, - __pyx_e_4cuda_7ccudart_cudaErrorProfilerNotInitialized = 6, - __pyx_e_4cuda_7ccudart_cudaErrorProfilerAlreadyStarted = 7, - __pyx_e_4cuda_7ccudart_cudaErrorProfilerAlreadyStopped = 8, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidConfiguration = 9, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidPitchValue = 12, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidSymbol = 13, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidHostPointer = 16, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidDevicePointer = 17, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidTexture = 18, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidTextureBinding = 19, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidChannelDescriptor = 20, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidMemcpyDirection = 21, - __pyx_e_4cuda_7ccudart_cudaErrorAddressOfConstant = 22, - __pyx_e_4cuda_7ccudart_cudaErrorTextureFetchFailed = 23, - __pyx_e_4cuda_7ccudart_cudaErrorTextureNotBound = 24, - __pyx_e_4cuda_7ccudart_cudaErrorSynchronizationError = 25, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidFilterSetting = 26, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidNormSetting = 27, - __pyx_e_4cuda_7ccudart_cudaErrorMixedDeviceExecution = 28, - __pyx_e_4cuda_7ccudart_cudaErrorNotYetImplemented = 31, - __pyx_e_4cuda_7ccudart_cudaErrorMemoryValueTooLarge = 32, - __pyx_e_4cuda_7ccudart_cudaErrorStubLibrary = 34, - __pyx_e_4cuda_7ccudart_cudaErrorInsufficientDriver = 35, - __pyx_e_4cuda_7ccudart_cudaErrorCallRequiresNewerDriver = 36, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidSurface = 37, - __pyx_e_4cuda_7ccudart_cudaErrorDuplicateVariableName = 43, - __pyx_e_4cuda_7ccudart_cudaErrorDuplicateTextureName = 44, - __pyx_e_4cuda_7ccudart_cudaErrorDuplicateSurfaceName = 45, - __pyx_e_4cuda_7ccudart_cudaErrorDevicesUnavailable = 46, - __pyx_e_4cuda_7ccudart_cudaErrorIncompatibleDriverContext = 49, - __pyx_e_4cuda_7ccudart_cudaErrorMissingConfiguration = 52, - __pyx_e_4cuda_7ccudart_cudaErrorPriorLaunchFailure = 53, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchMaxDepthExceeded = 65, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchFileScopedTex = 66, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchFileScopedSurf = 67, - __pyx_e_4cuda_7ccudart_cudaErrorSyncDepthExceeded = 68, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchPendingCountExceeded = 69, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidDeviceFunction = 98, - __pyx_e_4cuda_7ccudart_cudaErrorNoDevice = 0x64, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidDevice = 0x65, - __pyx_e_4cuda_7ccudart_cudaErrorDeviceNotLicensed = 0x66, - __pyx_e_4cuda_7ccudart_cudaErrorSoftwareValidityNotEstablished = 0x67, - __pyx_e_4cuda_7ccudart_cudaErrorStartupFailure = 0x7F, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidKernelImage = 0xC8, - __pyx_e_4cuda_7ccudart_cudaErrorDeviceUninitialized = 0xC9, - __pyx_e_4cuda_7ccudart_cudaErrorMapBufferObjectFailed = 0xCD, - __pyx_e_4cuda_7ccudart_cudaErrorUnmapBufferObjectFailed = 0xCE, - __pyx_e_4cuda_7ccudart_cudaErrorArrayIsMapped = 0xCF, - __pyx_e_4cuda_7ccudart_cudaErrorAlreadyMapped = 0xD0, - __pyx_e_4cuda_7ccudart_cudaErrorNoKernelImageForDevice = 0xD1, - __pyx_e_4cuda_7ccudart_cudaErrorAlreadyAcquired = 0xD2, - __pyx_e_4cuda_7ccudart_cudaErrorNotMapped = 0xD3, - __pyx_e_4cuda_7ccudart_cudaErrorNotMappedAsArray = 0xD4, - __pyx_e_4cuda_7ccudart_cudaErrorNotMappedAsPointer = 0xD5, - __pyx_e_4cuda_7ccudart_cudaErrorECCUncorrectable = 0xD6, - __pyx_e_4cuda_7ccudart_cudaErrorUnsupportedLimit = 0xD7, - __pyx_e_4cuda_7ccudart_cudaErrorDeviceAlreadyInUse = 0xD8, - __pyx_e_4cuda_7ccudart_cudaErrorPeerAccessUnsupported = 0xD9, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidPtx = 0xDA, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidGraphicsContext = 0xDB, - __pyx_e_4cuda_7ccudart_cudaErrorNvlinkUncorrectable = 0xDC, - __pyx_e_4cuda_7ccudart_cudaErrorJitCompilerNotFound = 0xDD, - __pyx_e_4cuda_7ccudart_cudaErrorUnsupportedPtxVersion = 0xDE, - __pyx_e_4cuda_7ccudart_cudaErrorJitCompilationDisabled = 0xDF, - __pyx_e_4cuda_7ccudart_cudaErrorUnsupportedExecAffinity = 0xE0, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidSource = 0x12C, - __pyx_e_4cuda_7ccudart_cudaErrorFileNotFound = 0x12D, - __pyx_e_4cuda_7ccudart_cudaErrorSharedObjectSymbolNotFound = 0x12E, - __pyx_e_4cuda_7ccudart_cudaErrorSharedObjectInitFailed = 0x12F, - __pyx_e_4cuda_7ccudart_cudaErrorOperatingSystem = 0x130, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidResourceHandle = 0x190, - __pyx_e_4cuda_7ccudart_cudaErrorIllegalState = 0x191, - __pyx_e_4cuda_7ccudart_cudaErrorSymbolNotFound = 0x1F4, - __pyx_e_4cuda_7ccudart_cudaErrorNotReady = 0x258, - __pyx_e_4cuda_7ccudart_cudaErrorIllegalAddress = 0x2BC, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchOutOfResources = 0x2BD, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchTimeout = 0x2BE, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchIncompatibleTexturing = 0x2BF, - __pyx_e_4cuda_7ccudart_cudaErrorPeerAccessAlreadyEnabled = 0x2C0, - __pyx_e_4cuda_7ccudart_cudaErrorPeerAccessNotEnabled = 0x2C1, - __pyx_e_4cuda_7ccudart_cudaErrorSetOnActiveProcess = 0x2C4, - __pyx_e_4cuda_7ccudart_cudaErrorContextIsDestroyed = 0x2C5, - __pyx_e_4cuda_7ccudart_cudaErrorAssert = 0x2C6, - __pyx_e_4cuda_7ccudart_cudaErrorTooManyPeers = 0x2C7, - __pyx_e_4cuda_7ccudart_cudaErrorHostMemoryAlreadyRegistered = 0x2C8, - __pyx_e_4cuda_7ccudart_cudaErrorHostMemoryNotRegistered = 0x2C9, - __pyx_e_4cuda_7ccudart_cudaErrorHardwareStackError = 0x2CA, - __pyx_e_4cuda_7ccudart_cudaErrorIllegalInstruction = 0x2CB, - __pyx_e_4cuda_7ccudart_cudaErrorMisalignedAddress = 0x2CC, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidAddressSpace = 0x2CD, - __pyx_e_4cuda_7ccudart_cudaErrorInvalidPc = 0x2CE, - __pyx_e_4cuda_7ccudart_cudaErrorLaunchFailure = 0x2CF, - __pyx_e_4cuda_7ccudart_cudaErrorCooperativeLaunchTooLarge = 0x2D0, - __pyx_e_4cuda_7ccudart_cudaErrorNotPermitted = 0x320, - __pyx_e_4cuda_7ccudart_cudaErrorNotSupported = 0x321, - __pyx_e_4cuda_7ccudart_cudaErrorSystemNotReady = 0x322, - __pyx_e_4cuda_7ccudart_cudaErrorSystemDriverMismatch = 0x323, - __pyx_e_4cuda_7ccudart_cudaErrorCompatNotSupportedOnDevice = 0x324, - __pyx_e_4cuda_7ccudart_cudaErrorMpsConnectionFailed = 0x325, - __pyx_e_4cuda_7ccudart_cudaErrorMpsRpcFailure = 0x326, - __pyx_e_4cuda_7ccudart_cudaErrorMpsServerNotReady = 0x327, - __pyx_e_4cuda_7ccudart_cudaErrorMpsMaxClientsReached = 0x328, - __pyx_e_4cuda_7ccudart_cudaErrorMpsMaxConnectionsReached = 0x329, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureUnsupported = 0x384, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureInvalidated = 0x385, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureMerge = 0x386, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureUnmatched = 0x387, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureUnjoined = 0x388, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureIsolation = 0x389, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureImplicit = 0x38A, - __pyx_e_4cuda_7ccudart_cudaErrorCapturedEvent = 0x38B, - __pyx_e_4cuda_7ccudart_cudaErrorStreamCaptureWrongThread = 0x38C, - __pyx_e_4cuda_7ccudart_cudaErrorTimeout = 0x38D, - __pyx_e_4cuda_7ccudart_cudaErrorGraphExecUpdateFailure = 0x38E, - __pyx_e_4cuda_7ccudart_cudaErrorExternalDevice = 0x38F, - __pyx_e_4cuda_7ccudart_cudaErrorUnknown = 0x3E7, - __pyx_e_4cuda_7ccudart_cudaErrorApiFailureBase = 0x2710 -}; - -/* "cuda/ccudart.pxd":145 - * cudaErrorApiFailureBase = 10000 - * - * cdef enum cudaChannelFormatKind: # <<<<<<<<<<<<<< - * cudaChannelFormatKindSigned = 0 - * cudaChannelFormatKindUnsigned = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaChannelFormatKind { - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSigned = 0, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsigned = 1, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindFloat = 2, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindNone = 3, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindNV12 = 4, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized8X1 = 5, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized8X2 = 6, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized8X4 = 7, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized16X1 = 8, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized16X2 = 9, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedNormalized16X4 = 10, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized8X1 = 11, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized8X2 = 12, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized8X4 = 13, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized16X1 = 14, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized16X2 = 15, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedNormalized16X4 = 16, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed1 = 17, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed1SRGB = 18, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed2 = 19, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed2SRGB = 20, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed3 = 21, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed3SRGB = 22, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed4 = 23, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedBlockCompressed4 = 24, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed5 = 25, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedBlockCompressed5 = 26, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed6H = 27, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindSignedBlockCompressed6H = 28, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed7 = 29, - __pyx_e_4cuda_7ccudart_cudaChannelFormatKindUnsignedBlockCompressed7SRGB = 30 -}; - -/* "cuda/ccudart.pxd":224 - * unsigned int reserved[4] - * - * cdef enum cudaMemoryType: # <<<<<<<<<<<<<< - * cudaMemoryTypeUnregistered = 0 - * cudaMemoryTypeHost = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemoryType { - __pyx_e_4cuda_7ccudart_cudaMemoryTypeUnregistered = 0, - __pyx_e_4cuda_7ccudart_cudaMemoryTypeHost = 1, - __pyx_e_4cuda_7ccudart_cudaMemoryTypeDevice = 2, - __pyx_e_4cuda_7ccudart_cudaMemoryTypeManaged = 3 -}; - -/* "cuda/ccudart.pxd":230 - * cudaMemoryTypeManaged = 3 - * - * cdef enum cudaMemcpyKind: # <<<<<<<<<<<<<< - * cudaMemcpyHostToHost = 0 - * cudaMemcpyHostToDevice = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemcpyKind { - __pyx_e_4cuda_7ccudart_cudaMemcpyHostToHost = 0, - __pyx_e_4cuda_7ccudart_cudaMemcpyHostToDevice = 1, - __pyx_e_4cuda_7ccudart_cudaMemcpyDeviceToHost = 2, - __pyx_e_4cuda_7ccudart_cudaMemcpyDeviceToDevice = 3, - __pyx_e_4cuda_7ccudart_cudaMemcpyDefault = 4 -}; - -/* "cuda/ccudart.pxd":282 - * size_t height - * - * cdef enum cudaAccessProperty: # <<<<<<<<<<<<<< - * cudaAccessPropertyNormal = 0 - * cudaAccessPropertyStreaming = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaAccessProperty { - __pyx_e_4cuda_7ccudart_cudaAccessPropertyNormal = 0, - __pyx_e_4cuda_7ccudart_cudaAccessPropertyStreaming = 1, - __pyx_e_4cuda_7ccudart_cudaAccessPropertyPersisting = 2 -}; - -/* "cuda/ccudart.pxd":300 - * void* userData - * - * cdef enum cudaStreamCaptureStatus: # <<<<<<<<<<<<<< - * cudaStreamCaptureStatusNone = 0 - * cudaStreamCaptureStatusActive = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaStreamCaptureStatus { - __pyx_e_4cuda_7ccudart_cudaStreamCaptureStatusNone = 0, - __pyx_e_4cuda_7ccudart_cudaStreamCaptureStatusActive = 1, - __pyx_e_4cuda_7ccudart_cudaStreamCaptureStatusInvalidated = 2 -}; - -/* "cuda/ccudart.pxd":305 - * cudaStreamCaptureStatusInvalidated = 2 - * - * cdef enum cudaStreamCaptureMode: # <<<<<<<<<<<<<< - * cudaStreamCaptureModeGlobal = 0 - * cudaStreamCaptureModeThreadLocal = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaStreamCaptureMode { - __pyx_e_4cuda_7ccudart_cudaStreamCaptureModeGlobal = 0, - __pyx_e_4cuda_7ccudart_cudaStreamCaptureModeThreadLocal = 1, - __pyx_e_4cuda_7ccudart_cudaStreamCaptureModeRelaxed = 2 -}; - -/* "cuda/ccudart.pxd":310 - * cudaStreamCaptureModeRelaxed = 2 - * - * cdef enum cudaSynchronizationPolicy: # <<<<<<<<<<<<<< - * cudaSyncPolicyAuto = 1 - * cudaSyncPolicySpin = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaSynchronizationPolicy { - __pyx_e_4cuda_7ccudart_cudaSyncPolicyAuto = 1, - __pyx_e_4cuda_7ccudart_cudaSyncPolicySpin = 2, - __pyx_e_4cuda_7ccudart_cudaSyncPolicyYield = 3, - __pyx_e_4cuda_7ccudart_cudaSyncPolicyBlockingSync = 4 -}; - -/* "cuda/ccudart.pxd":316 - * cudaSyncPolicyBlockingSync = 4 - * - * cdef enum cudaStreamAttrID: # <<<<<<<<<<<<<< - * cudaStreamAttributeAccessPolicyWindow = 1 - * cudaStreamAttributeSynchronizationPolicy = 3 - */ -enum __pyx_t_4cuda_7ccudart_cudaStreamAttrID { - __pyx_e_4cuda_7ccudart_cudaStreamAttributeAccessPolicyWindow = 1, - __pyx_e_4cuda_7ccudart_cudaStreamAttributeSynchronizationPolicy = 3 -}; - -/* "cuda/ccudart.pxd":324 - * cudaSynchronizationPolicy syncPolicy - * - * cdef enum cudaStreamUpdateCaptureDependenciesFlags: # <<<<<<<<<<<<<< - * cudaStreamAddCaptureDependencies = 0 - * cudaStreamSetCaptureDependencies = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaStreamUpdateCaptureDependenciesFlags { - __pyx_e_4cuda_7ccudart_cudaStreamAddCaptureDependencies = 0, - __pyx_e_4cuda_7ccudart_cudaStreamSetCaptureDependencies = 1 -}; - -/* "cuda/ccudart.pxd":328 - * cudaStreamSetCaptureDependencies = 1 - * - * cdef enum cudaUserObjectFlags: # <<<<<<<<<<<<<< - * cudaUserObjectNoDestructorSync = 1 - * - */ -enum __pyx_t_4cuda_7ccudart_cudaUserObjectFlags { - __pyx_e_4cuda_7ccudart_cudaUserObjectNoDestructorSync = 1 -}; - -/* "cuda/ccudart.pxd":331 - * cudaUserObjectNoDestructorSync = 1 - * - * cdef enum cudaUserObjectRetainFlags: # <<<<<<<<<<<<<< - * cudaGraphUserObjectMove = 1 - * - */ -enum __pyx_t_4cuda_7ccudart_cudaUserObjectRetainFlags { - __pyx_e_4cuda_7ccudart_cudaGraphUserObjectMove = 1 -}; - -/* "cuda/ccudart.pxd":335 - * - * - * cdef enum cudaGraphicsRegisterFlags: # <<<<<<<<<<<<<< - * cudaGraphicsRegisterFlagsNone = 0 - * cudaGraphicsRegisterFlagsReadOnly = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphicsRegisterFlags { - __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsNone = 0, - __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsReadOnly = 1, - __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsWriteDiscard = 2, - __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsSurfaceLoadStore = 4, - __pyx_e_4cuda_7ccudart_cudaGraphicsRegisterFlagsTextureGather = 8 -}; - -/* "cuda/ccudart.pxd":342 - * cudaGraphicsRegisterFlagsTextureGather = 8 - * - * cdef enum cudaGraphicsMapFlags: # <<<<<<<<<<<<<< - * cudaGraphicsMapFlagsNone = 0 - * cudaGraphicsMapFlagsReadOnly = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphicsMapFlags { - __pyx_e_4cuda_7ccudart_cudaGraphicsMapFlagsNone = 0, - __pyx_e_4cuda_7ccudart_cudaGraphicsMapFlagsReadOnly = 1, - __pyx_e_4cuda_7ccudart_cudaGraphicsMapFlagsWriteDiscard = 2 -}; - -/* "cuda/ccudart.pxd":347 - * cudaGraphicsMapFlagsWriteDiscard = 2 - * - * cdef enum cudaGraphicsCubeFace: # <<<<<<<<<<<<<< - * cudaGraphicsCubeFacePositiveX = 0 - * cudaGraphicsCubeFaceNegativeX = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphicsCubeFace { - __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFacePositiveX = 0, - __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFaceNegativeX = 1, - __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFacePositiveY = 2, - __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFaceNegativeY = 3, - __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFacePositiveZ = 4, - __pyx_e_4cuda_7ccudart_cudaGraphicsCubeFaceNegativeZ = 5 -}; - -/* "cuda/ccudart.pxd":355 - * cudaGraphicsCubeFaceNegativeZ = 5 - * - * cdef enum cudaKernelNodeAttrID: # <<<<<<<<<<<<<< - * cudaKernelNodeAttributeAccessPolicyWindow = 1 - * cudaKernelNodeAttributeCooperative = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaKernelNodeAttrID { - __pyx_e_4cuda_7ccudart_cudaKernelNodeAttributeAccessPolicyWindow = 1, - __pyx_e_4cuda_7ccudart_cudaKernelNodeAttributeCooperative = 2 -}; - -/* "cuda/ccudart.pxd":363 - * int cooperative - * - * cdef enum cudaResourceType: # <<<<<<<<<<<<<< - * cudaResourceTypeArray = 0 - * cudaResourceTypeMipmappedArray = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaResourceType { - __pyx_e_4cuda_7ccudart_cudaResourceTypeArray = 0, - __pyx_e_4cuda_7ccudart_cudaResourceTypeMipmappedArray = 1, - __pyx_e_4cuda_7ccudart_cudaResourceTypeLinear = 2, - __pyx_e_4cuda_7ccudart_cudaResourceTypePitch2D = 3 -}; - -/* "cuda/ccudart.pxd":369 - * cudaResourceTypePitch2D = 3 - * - * cdef enum cudaResourceViewFormat: # <<<<<<<<<<<<<< - * cudaResViewFormatNone = 0 - * cudaResViewFormatUnsignedChar1 = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaResourceViewFormat { - __pyx_e_4cuda_7ccudart_cudaResViewFormatNone = 0, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedChar1 = 1, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedChar2 = 2, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedChar4 = 3, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedChar1 = 4, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedChar2 = 5, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedChar4 = 6, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedShort1 = 7, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedShort2 = 8, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedShort4 = 9, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedShort1 = 10, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedShort2 = 11, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedShort4 = 12, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedInt1 = 13, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedInt2 = 14, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedInt4 = 15, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedInt1 = 16, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedInt2 = 17, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedInt4 = 18, - __pyx_e_4cuda_7ccudart_cudaResViewFormatHalf1 = 19, - __pyx_e_4cuda_7ccudart_cudaResViewFormatHalf2 = 20, - __pyx_e_4cuda_7ccudart_cudaResViewFormatHalf4 = 21, - __pyx_e_4cuda_7ccudart_cudaResViewFormatFloat1 = 22, - __pyx_e_4cuda_7ccudart_cudaResViewFormatFloat2 = 23, - __pyx_e_4cuda_7ccudart_cudaResViewFormatFloat4 = 24, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed1 = 25, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed2 = 26, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed3 = 27, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed4 = 28, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedBlockCompressed4 = 29, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed5 = 30, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedBlockCompressed5 = 31, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed6H = 32, - __pyx_e_4cuda_7ccudart_cudaResViewFormatSignedBlockCompressed6H = 33, - __pyx_e_4cuda_7ccudart_cudaResViewFormatUnsignedBlockCompressed7 = 34 -}; - -/* "cuda/ccudart.pxd":462 - * int preferredShmemCarveout - * - * cdef enum cudaFuncAttribute: # <<<<<<<<<<<<<< - * cudaFuncAttributeMaxDynamicSharedMemorySize = 8 - * cudaFuncAttributePreferredSharedMemoryCarveout = 9 - */ -enum __pyx_t_4cuda_7ccudart_cudaFuncAttribute { - __pyx_e_4cuda_7ccudart_cudaFuncAttributeMaxDynamicSharedMemorySize = 8, - __pyx_e_4cuda_7ccudart_cudaFuncAttributePreferredSharedMemoryCarveout = 9, - __pyx_e_4cuda_7ccudart_cudaFuncAttributeMax = 10 -}; - -/* "cuda/ccudart.pxd":467 - * cudaFuncAttributeMax = 10 - * - * cdef enum cudaFuncCache: # <<<<<<<<<<<<<< - * cudaFuncCachePreferNone = 0 - * cudaFuncCachePreferShared = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaFuncCache { - __pyx_e_4cuda_7ccudart_cudaFuncCachePreferNone = 0, - __pyx_e_4cuda_7ccudart_cudaFuncCachePreferShared = 1, - __pyx_e_4cuda_7ccudart_cudaFuncCachePreferL1 = 2, - __pyx_e_4cuda_7ccudart_cudaFuncCachePreferEqual = 3 -}; - -/* "cuda/ccudart.pxd":473 - * cudaFuncCachePreferEqual = 3 - * - * cdef enum cudaSharedMemConfig: # <<<<<<<<<<<<<< - * cudaSharedMemBankSizeDefault = 0 - * cudaSharedMemBankSizeFourByte = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaSharedMemConfig { - __pyx_e_4cuda_7ccudart_cudaSharedMemBankSizeDefault = 0, - __pyx_e_4cuda_7ccudart_cudaSharedMemBankSizeFourByte = 1, - __pyx_e_4cuda_7ccudart_cudaSharedMemBankSizeEightByte = 2 -}; - -/* "cuda/ccudart.pxd":478 - * cudaSharedMemBankSizeEightByte = 2 - * - * cdef enum cudaSharedCarveout: # <<<<<<<<<<<<<< - * cudaSharedmemCarveoutDefault = -1 - * cudaSharedmemCarveoutMaxShared = 100 - */ -enum __pyx_t_4cuda_7ccudart_cudaSharedCarveout { - __pyx_e_4cuda_7ccudart_cudaSharedmemCarveoutDefault = -1L, - __pyx_e_4cuda_7ccudart_cudaSharedmemCarveoutMaxShared = 0x64, - __pyx_e_4cuda_7ccudart_cudaSharedmemCarveoutMaxL1 = 0 -}; - -/* "cuda/ccudart.pxd":483 - * cudaSharedmemCarveoutMaxL1 = 0 - * - * cdef enum cudaComputeMode: # <<<<<<<<<<<<<< - * cudaComputeModeDefault = 0 - * cudaComputeModeExclusive = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaComputeMode { - __pyx_e_4cuda_7ccudart_cudaComputeModeDefault = 0, - __pyx_e_4cuda_7ccudart_cudaComputeModeExclusive = 1, - __pyx_e_4cuda_7ccudart_cudaComputeModeProhibited = 2, - __pyx_e_4cuda_7ccudart_cudaComputeModeExclusiveProcess = 3 -}; - -/* "cuda/ccudart.pxd":489 - * cudaComputeModeExclusiveProcess = 3 - * - * cdef enum cudaLimit: # <<<<<<<<<<<<<< - * cudaLimitStackSize = 0 - * cudaLimitPrintfFifoSize = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaLimit { - __pyx_e_4cuda_7ccudart_cudaLimitStackSize = 0, - __pyx_e_4cuda_7ccudart_cudaLimitPrintfFifoSize = 1, - __pyx_e_4cuda_7ccudart_cudaLimitMallocHeapSize = 2, - __pyx_e_4cuda_7ccudart_cudaLimitDevRuntimeSyncDepth = 3, - __pyx_e_4cuda_7ccudart_cudaLimitDevRuntimePendingLaunchCount = 4, - __pyx_e_4cuda_7ccudart_cudaLimitMaxL2FetchGranularity = 5, - __pyx_e_4cuda_7ccudart_cudaLimitPersistingL2CacheSize = 6 -}; - -/* "cuda/ccudart.pxd":498 - * cudaLimitPersistingL2CacheSize = 6 - * - * cdef enum cudaMemoryAdvise: # <<<<<<<<<<<<<< - * cudaMemAdviseSetReadMostly = 1 - * cudaMemAdviseUnsetReadMostly = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemoryAdvise { - __pyx_e_4cuda_7ccudart_cudaMemAdviseSetReadMostly = 1, - __pyx_e_4cuda_7ccudart_cudaMemAdviseUnsetReadMostly = 2, - __pyx_e_4cuda_7ccudart_cudaMemAdviseSetPreferredLocation = 3, - __pyx_e_4cuda_7ccudart_cudaMemAdviseUnsetPreferredLocation = 4, - __pyx_e_4cuda_7ccudart_cudaMemAdviseSetAccessedBy = 5, - __pyx_e_4cuda_7ccudart_cudaMemAdviseUnsetAccessedBy = 6 -}; - -/* "cuda/ccudart.pxd":506 - * cudaMemAdviseUnsetAccessedBy = 6 - * - * cdef enum cudaMemRangeAttribute: # <<<<<<<<<<<<<< - * cudaMemRangeAttributeReadMostly = 1 - * cudaMemRangeAttributePreferredLocation = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemRangeAttribute { - __pyx_e_4cuda_7ccudart_cudaMemRangeAttributeReadMostly = 1, - __pyx_e_4cuda_7ccudart_cudaMemRangeAttributePreferredLocation = 2, - __pyx_e_4cuda_7ccudart_cudaMemRangeAttributeAccessedBy = 3, - __pyx_e_4cuda_7ccudart_cudaMemRangeAttributeLastPrefetchLocation = 4 -}; - -/* "cuda/ccudart.pxd":512 - * cudaMemRangeAttributeLastPrefetchLocation = 4 - * - * cdef enum cudaOutputMode: # <<<<<<<<<<<<<< - * cudaKeyValuePair = 0 - * cudaCSV = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaOutputMode { - __pyx_e_4cuda_7ccudart_cudaKeyValuePair = 0, - __pyx_e_4cuda_7ccudart_cudaCSV = 1 -}; - -/* "cuda/ccudart.pxd":516 - * cudaCSV = 1 - * - * cdef enum cudaFlushGPUDirectRDMAWritesOptions: # <<<<<<<<<<<<<< - * cudaFlushGPUDirectRDMAWritesOptionHost = 1 - * cudaFlushGPUDirectRDMAWritesOptionMemOps = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesOptions { - __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesOptionHost = 1, - __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesOptionMemOps = 2 -}; - -/* "cuda/ccudart.pxd":520 - * cudaFlushGPUDirectRDMAWritesOptionMemOps = 2 - * - * cdef enum cudaGPUDirectRDMAWritesOrdering: # <<<<<<<<<<<<<< - * cudaGPUDirectRDMAWritesOrderingNone = 0 - * cudaGPUDirectRDMAWritesOrderingOwner = 100 - */ -enum __pyx_t_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrdering { - __pyx_e_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrderingNone = 0, - __pyx_e_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrderingOwner = 0x64, - __pyx_e_4cuda_7ccudart_cudaGPUDirectRDMAWritesOrderingAllDevices = 0xC8 -}; - -/* "cuda/ccudart.pxd":525 - * cudaGPUDirectRDMAWritesOrderingAllDevices = 200 - * - * cdef enum cudaFlushGPUDirectRDMAWritesScope: # <<<<<<<<<<<<<< - * cudaFlushGPUDirectRDMAWritesToOwner = 100 - * cudaFlushGPUDirectRDMAWritesToAllDevices = 200 - */ -enum __pyx_t_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesScope { - __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesToOwner = 0x64, - __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesToAllDevices = 0xC8 -}; - -/* "cuda/ccudart.pxd":529 - * cudaFlushGPUDirectRDMAWritesToAllDevices = 200 - * - * cdef enum cudaFlushGPUDirectRDMAWritesTarget: # <<<<<<<<<<<<<< - * cudaFlushGPUDirectRDMAWritesTargetCurrentDevice = 0 - * - */ -enum __pyx_t_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesTarget { - __pyx_e_4cuda_7ccudart_cudaFlushGPUDirectRDMAWritesTargetCurrentDevice = 0 -}; - -/* "cuda/ccudart.pxd":532 - * cudaFlushGPUDirectRDMAWritesTargetCurrentDevice = 0 - * - * cdef enum cudaDeviceAttr: # <<<<<<<<<<<<<< - * cudaDevAttrMaxThreadsPerBlock = 1 - * cudaDevAttrMaxBlockDimX = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaDeviceAttr { - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxThreadsPerBlock = 1, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlockDimX = 2, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlockDimY = 3, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlockDimZ = 4, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxGridDimX = 5, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxGridDimY = 6, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxGridDimZ = 7, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSharedMemoryPerBlock = 8, - __pyx_e_4cuda_7ccudart_cudaDevAttrTotalConstantMemory = 9, - __pyx_e_4cuda_7ccudart_cudaDevAttrWarpSize = 10, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxPitch = 11, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxRegistersPerBlock = 12, - __pyx_e_4cuda_7ccudart_cudaDevAttrClockRate = 13, - __pyx_e_4cuda_7ccudart_cudaDevAttrTextureAlignment = 14, - __pyx_e_4cuda_7ccudart_cudaDevAttrGpuOverlap = 15, - __pyx_e_4cuda_7ccudart_cudaDevAttrMultiProcessorCount = 16, - __pyx_e_4cuda_7ccudart_cudaDevAttrKernelExecTimeout = 17, - __pyx_e_4cuda_7ccudart_cudaDevAttrIntegrated = 18, - __pyx_e_4cuda_7ccudart_cudaDevAttrCanMapHostMemory = 19, - __pyx_e_4cuda_7ccudart_cudaDevAttrComputeMode = 20, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DWidth = 21, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DWidth = 22, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DHeight = 23, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DWidth = 24, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DHeight = 25, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DDepth = 26, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLayeredWidth = 27, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLayeredHeight = 28, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLayeredLayers = 29, - __pyx_e_4cuda_7ccudart_cudaDevAttrSurfaceAlignment = 30, - __pyx_e_4cuda_7ccudart_cudaDevAttrConcurrentKernels = 31, - __pyx_e_4cuda_7ccudart_cudaDevAttrEccEnabled = 32, - __pyx_e_4cuda_7ccudart_cudaDevAttrPciBusId = 33, - __pyx_e_4cuda_7ccudart_cudaDevAttrPciDeviceId = 34, - __pyx_e_4cuda_7ccudart_cudaDevAttrTccDriver = 35, - __pyx_e_4cuda_7ccudart_cudaDevAttrMemoryClockRate = 36, - __pyx_e_4cuda_7ccudart_cudaDevAttrGlobalMemoryBusWidth = 37, - __pyx_e_4cuda_7ccudart_cudaDevAttrL2CacheSize = 38, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxThreadsPerMultiProcessor = 39, - __pyx_e_4cuda_7ccudart_cudaDevAttrAsyncEngineCount = 40, - __pyx_e_4cuda_7ccudart_cudaDevAttrUnifiedAddressing = 41, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DLayeredWidth = 42, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DLayeredLayers = 43, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DGatherWidth = 45, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DGatherHeight = 46, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DWidthAlt = 47, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DHeightAlt = 48, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture3DDepthAlt = 49, - __pyx_e_4cuda_7ccudart_cudaDevAttrPciDomainId = 50, - __pyx_e_4cuda_7ccudart_cudaDevAttrTexturePitchAlignment = 51, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTextureCubemapWidth = 52, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTextureCubemapLayeredWidth = 53, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTextureCubemapLayeredLayers = 54, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface1DWidth = 55, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DWidth = 56, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DHeight = 57, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface3DWidth = 58, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface3DHeight = 59, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface3DDepth = 60, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface1DLayeredWidth = 61, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface1DLayeredLayers = 62, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DLayeredWidth = 63, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DLayeredHeight = 64, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurface2DLayeredLayers = 65, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurfaceCubemapWidth = 66, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurfaceCubemapLayeredWidth = 67, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSurfaceCubemapLayeredLayers = 68, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DLinearWidth = 69, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLinearWidth = 70, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLinearHeight = 71, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DLinearPitch = 72, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DMipmappedWidth = 73, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture2DMipmappedHeight = 74, - __pyx_e_4cuda_7ccudart_cudaDevAttrComputeCapabilityMajor = 75, - __pyx_e_4cuda_7ccudart_cudaDevAttrComputeCapabilityMinor = 76, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTexture1DMipmappedWidth = 77, - __pyx_e_4cuda_7ccudart_cudaDevAttrStreamPrioritiesSupported = 78, - __pyx_e_4cuda_7ccudart_cudaDevAttrGlobalL1CacheSupported = 79, - __pyx_e_4cuda_7ccudart_cudaDevAttrLocalL1CacheSupported = 80, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSharedMemoryPerMultiprocessor = 81, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxRegistersPerMultiprocessor = 82, - __pyx_e_4cuda_7ccudart_cudaDevAttrManagedMemory = 83, - __pyx_e_4cuda_7ccudart_cudaDevAttrIsMultiGpuBoard = 84, - __pyx_e_4cuda_7ccudart_cudaDevAttrMultiGpuBoardGroupID = 85, - __pyx_e_4cuda_7ccudart_cudaDevAttrHostNativeAtomicSupported = 86, - __pyx_e_4cuda_7ccudart_cudaDevAttrSingleToDoublePrecisionPerfRatio = 87, - __pyx_e_4cuda_7ccudart_cudaDevAttrPageableMemoryAccess = 88, - __pyx_e_4cuda_7ccudart_cudaDevAttrConcurrentManagedAccess = 89, - __pyx_e_4cuda_7ccudart_cudaDevAttrComputePreemptionSupported = 90, - __pyx_e_4cuda_7ccudart_cudaDevAttrCanUseHostPointerForRegisteredMem = 91, - __pyx_e_4cuda_7ccudart_cudaDevAttrReserved92 = 92, - __pyx_e_4cuda_7ccudart_cudaDevAttrReserved93 = 93, - __pyx_e_4cuda_7ccudart_cudaDevAttrReserved94 = 94, - __pyx_e_4cuda_7ccudart_cudaDevAttrCooperativeLaunch = 95, - __pyx_e_4cuda_7ccudart_cudaDevAttrCooperativeMultiDeviceLaunch = 96, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxSharedMemoryPerBlockOptin = 97, - __pyx_e_4cuda_7ccudart_cudaDevAttrCanFlushRemoteWrites = 98, - __pyx_e_4cuda_7ccudart_cudaDevAttrHostRegisterSupported = 99, - __pyx_e_4cuda_7ccudart_cudaDevAttrPageableMemoryAccessUsesHostPageTables = 0x64, - __pyx_e_4cuda_7ccudart_cudaDevAttrDirectManagedMemAccessFromHost = 0x65, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxBlocksPerMultiprocessor = 0x6A, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxPersistingL2CacheSize = 0x6C, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxAccessPolicyWindowSize = 0x6D, - __pyx_e_4cuda_7ccudart_cudaDevAttrReservedSharedMemoryPerBlock = 0x6F, - __pyx_e_4cuda_7ccudart_cudaDevAttrSparseCudaArraySupported = 0x70, - __pyx_e_4cuda_7ccudart_cudaDevAttrHostRegisterReadOnlySupported = 0x71, - __pyx_e_4cuda_7ccudart_cudaDevAttrTimelineSemaphoreInteropSupported = 0x72, - __pyx_e_4cuda_7ccudart_cudaDevAttrMaxTimelineSemaphoreInteropSupported = 0x72, - __pyx_e_4cuda_7ccudart_cudaDevAttrMemoryPoolsSupported = 0x73, - __pyx_e_4cuda_7ccudart_cudaDevAttrGPUDirectRDMASupported = 0x74, - __pyx_e_4cuda_7ccudart_cudaDevAttrGPUDirectRDMAFlushWritesOptions = 0x75, - __pyx_e_4cuda_7ccudart_cudaDevAttrGPUDirectRDMAWritesOrdering = 0x76, - __pyx_e_4cuda_7ccudart_cudaDevAttrMemoryPoolSupportedHandleTypes = 0x77, - __pyx_e_4cuda_7ccudart_cudaDevAttrDeferredMappingCudaArraySupported = 0x79, - __pyx_e_4cuda_7ccudart_cudaDevAttrMax = 0x7A -}; - -/* "cuda/ccudart.pxd":649 - * cudaDevAttrMax = 122 - * - * cdef enum cudaMemPoolAttr: # <<<<<<<<<<<<<< - * cudaMemPoolReuseFollowEventDependencies = 1 - * cudaMemPoolReuseAllowOpportunistic = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemPoolAttr { - __pyx_e_4cuda_7ccudart_cudaMemPoolReuseFollowEventDependencies = 1, - __pyx_e_4cuda_7ccudart_cudaMemPoolReuseAllowOpportunistic = 2, - __pyx_e_4cuda_7ccudart_cudaMemPoolReuseAllowInternalDependencies = 3, - __pyx_e_4cuda_7ccudart_cudaMemPoolAttrReleaseThreshold = 4, - __pyx_e_4cuda_7ccudart_cudaMemPoolAttrReservedMemCurrent = 5, - __pyx_e_4cuda_7ccudart_cudaMemPoolAttrReservedMemHigh = 6, - __pyx_e_4cuda_7ccudart_cudaMemPoolAttrUsedMemCurrent = 7, - __pyx_e_4cuda_7ccudart_cudaMemPoolAttrUsedMemHigh = 8 -}; - -/* "cuda/ccudart.pxd":659 - * cudaMemPoolAttrUsedMemHigh = 8 - * - * cdef enum cudaMemLocationType: # <<<<<<<<<<<<<< - * cudaMemLocationTypeInvalid = 0 - * cudaMemLocationTypeDevice = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemLocationType { - __pyx_e_4cuda_7ccudart_cudaMemLocationTypeInvalid = 0, - __pyx_e_4cuda_7ccudart_cudaMemLocationTypeDevice = 1 -}; - -/* "cuda/ccudart.pxd":667 - * int id - * - * cdef enum cudaMemAccessFlags: # <<<<<<<<<<<<<< - * cudaMemAccessFlagsProtNone = 0 - * cudaMemAccessFlagsProtRead = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemAccessFlags { - __pyx_e_4cuda_7ccudart_cudaMemAccessFlagsProtNone = 0, - __pyx_e_4cuda_7ccudart_cudaMemAccessFlagsProtRead = 1, - __pyx_e_4cuda_7ccudart_cudaMemAccessFlagsProtReadWrite = 3 -}; - -/* "cuda/ccudart.pxd":676 - * cudaMemAccessFlags flags - * - * cdef enum cudaMemAllocationType: # <<<<<<<<<<<<<< - * cudaMemAllocationTypeInvalid = 0 - * cudaMemAllocationTypePinned = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemAllocationType { - __pyx_e_4cuda_7ccudart_cudaMemAllocationTypeInvalid = 0, - __pyx_e_4cuda_7ccudart_cudaMemAllocationTypePinned = 1, - __pyx_e_4cuda_7ccudart_cudaMemAllocationTypeMax = 0x7FFFFFFF -}; - -/* "cuda/ccudart.pxd":681 - * cudaMemAllocationTypeMax = 2147483647 - * - * cdef enum cudaMemAllocationHandleType: # <<<<<<<<<<<<<< - * cudaMemHandleTypeNone = 0 - * cudaMemHandleTypePosixFileDescriptor = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaMemAllocationHandleType { - __pyx_e_4cuda_7ccudart_cudaMemHandleTypeNone = 0, - __pyx_e_4cuda_7ccudart_cudaMemHandleTypePosixFileDescriptor = 1, - __pyx_e_4cuda_7ccudart_cudaMemHandleTypeWin32 = 2, - __pyx_e_4cuda_7ccudart_cudaMemHandleTypeWin32Kmt = 4 -}; - -/* "cuda/ccudart.pxd":704 - * void* dptr - * - * cdef enum cudaGraphMemAttributeType: # <<<<<<<<<<<<<< - * cudaGraphMemAttrUsedMemCurrent = 0 - * cudaGraphMemAttrUsedMemHigh = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphMemAttributeType { - __pyx_e_4cuda_7ccudart_cudaGraphMemAttrUsedMemCurrent = 0, - __pyx_e_4cuda_7ccudart_cudaGraphMemAttrUsedMemHigh = 1, - __pyx_e_4cuda_7ccudart_cudaGraphMemAttrReservedMemCurrent = 2, - __pyx_e_4cuda_7ccudart_cudaGraphMemAttrReservedMemHigh = 3 -}; - -/* "cuda/ccudart.pxd":710 - * cudaGraphMemAttrReservedMemHigh = 3 - * - * cdef enum cudaDeviceP2PAttr: # <<<<<<<<<<<<<< - * cudaDevP2PAttrPerformanceRank = 1 - * cudaDevP2PAttrAccessSupported = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaDeviceP2PAttr { - __pyx_e_4cuda_7ccudart_cudaDevP2PAttrPerformanceRank = 1, - __pyx_e_4cuda_7ccudart_cudaDevP2PAttrAccessSupported = 2, - __pyx_e_4cuda_7ccudart_cudaDevP2PAttrNativeAtomicSupported = 3, - __pyx_e_4cuda_7ccudart_cudaDevP2PAttrCudaArrayAccessSupported = 4 -}; - -/* "cuda/ccudart.pxd":815 - * ctypedef cudaIpcMemHandle_st cudaIpcMemHandle_t - * - * cdef enum cudaExternalMemoryHandleType: # <<<<<<<<<<<<<< - * cudaExternalMemoryHandleTypeOpaqueFd = 1 - * cudaExternalMemoryHandleTypeOpaqueWin32 = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleType { - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeOpaqueFd = 1, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeOpaqueWin32 = 2, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeOpaqueWin32Kmt = 3, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D12Heap = 4, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D12Resource = 5, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D11Resource = 6, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeD3D11ResourceKmt = 7, - __pyx_e_4cuda_7ccudart_cudaExternalMemoryHandleTypeNvSciBuf = 8 -}; - -/* "cuda/ccudart.pxd":852 - * unsigned int numLevels - * - * cdef enum cudaExternalSemaphoreHandleType: # <<<<<<<<<<<<<< - * cudaExternalSemaphoreHandleTypeOpaqueFd = 1 - * cudaExternalSemaphoreHandleTypeOpaqueWin32 = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleType { - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeOpaqueFd = 1, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeOpaqueWin32 = 2, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeOpaqueWin32Kmt = 3, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeD3D12Fence = 4, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeD3D11Fence = 5, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeNvSciSync = 6, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeKeyedMutex = 7, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeKeyedMutexKmt = 8, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeTimelineSemaphoreFd = 9, - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10 -}; - -/* "cuda/ccudart.pxd":975 - * ctypedef CUmemPoolHandle_st* cudaMemPool_t - * - * cdef enum cudaCGScope: # <<<<<<<<<<<<<< - * cudaCGScopeInvalid = 0 - * cudaCGScopeGrid = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaCGScope { - __pyx_e_4cuda_7ccudart_cudaCGScopeInvalid = 0, - __pyx_e_4cuda_7ccudart_cudaCGScopeGrid = 1, - __pyx_e_4cuda_7ccudart_cudaCGScopeMultiGrid = 2 -}; - -/* "cuda/ccudart.pxd":998 - * unsigned int numExtSems - * - * cdef enum cudaGraphNodeType: # <<<<<<<<<<<<<< - * cudaGraphNodeTypeKernel = 0 - * cudaGraphNodeTypeMemcpy = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphNodeType { - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeKernel = 0, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemcpy = 1, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemset = 2, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeHost = 3, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeGraph = 4, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeEmpty = 5, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeWaitEvent = 6, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeEventRecord = 7, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeExtSemaphoreSignal = 8, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeExtSemaphoreWait = 9, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemAlloc = 10, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeMemFree = 11, - __pyx_e_4cuda_7ccudart_cudaGraphNodeTypeCount = 12 -}; - -/* "cuda/ccudart.pxd":1018 - * ctypedef CUgraphExec_st* cudaGraphExec_t - * - * cdef enum cudaGraphExecUpdateResult: # <<<<<<<<<<<<<< - * cudaGraphExecUpdateSuccess = 0 - * cudaGraphExecUpdateError = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphExecUpdateResult { - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateSuccess = 0, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateError = 1, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorTopologyChanged = 2, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorNodeTypeChanged = 3, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorFunctionChanged = 4, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorParametersChanged = 5, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorNotSupported = 6, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorUnsupportedFunctionChange = 7, - __pyx_e_4cuda_7ccudart_cudaGraphExecUpdateErrorAttributesChanged = 8 -}; - -/* "cuda/ccudart.pxd":1029 - * cudaGraphExecUpdateErrorAttributesChanged = 8 - * - * cdef enum cudaGetDriverEntryPointFlags: # <<<<<<<<<<<<<< - * cudaEnableDefault = 0 - * cudaEnableLegacyStream = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGetDriverEntryPointFlags { - __pyx_e_4cuda_7ccudart_cudaEnableDefault = 0, - __pyx_e_4cuda_7ccudart_cudaEnableLegacyStream = 1, - __pyx_e_4cuda_7ccudart_cudaEnablePerThreadDefaultStream = 2 -}; - -/* "cuda/ccudart.pxd":1034 - * cudaEnablePerThreadDefaultStream = 2 - * - * cdef enum cudaGraphDebugDotFlags: # <<<<<<<<<<<<<< - * cudaGraphDebugDotFlagsVerbose = 1 - * cudaGraphDebugDotFlagsKernelNodeParams = 4 - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphDebugDotFlags { - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsVerbose = 1, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsKernelNodeParams = 4, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsMemcpyNodeParams = 8, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsMemsetNodeParams = 16, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsHostNodeParams = 32, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsEventNodeParams = 64, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsExtSemasSignalNodeParams = 0x80, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsExtSemasWaitNodeParams = 0x100, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsKernelNodeAttributes = 0x200, - __pyx_e_4cuda_7ccudart_cudaGraphDebugDotFlagsHandles = 0x400 -}; - -/* "cuda/ccudart.pxd":1046 - * cudaGraphDebugDotFlagsHandles = 1024 - * - * cdef enum cudaGraphInstantiateFlags: # <<<<<<<<<<<<<< - * cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 - * - */ -enum __pyx_t_4cuda_7ccudart_cudaGraphInstantiateFlags { - __pyx_e_4cuda_7ccudart_cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 -}; - -/* "cuda/ccudart.pxd":1049 - * cudaGraphInstantiateFlagAutoFreeOnLaunch = 1 - * - * cdef enum cudaSurfaceBoundaryMode: # <<<<<<<<<<<<<< - * cudaBoundaryModeZero = 0 - * cudaBoundaryModeClamp = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaSurfaceBoundaryMode { - __pyx_e_4cuda_7ccudart_cudaBoundaryModeZero = 0, - __pyx_e_4cuda_7ccudart_cudaBoundaryModeClamp = 1, - __pyx_e_4cuda_7ccudart_cudaBoundaryModeTrap = 2 -}; - -/* "cuda/ccudart.pxd":1054 - * cudaBoundaryModeTrap = 2 - * - * cdef enum cudaSurfaceFormatMode: # <<<<<<<<<<<<<< - * cudaFormatModeForced = 0 - * cudaFormatModeAuto = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaSurfaceFormatMode { - __pyx_e_4cuda_7ccudart_cudaFormatModeForced = 0, - __pyx_e_4cuda_7ccudart_cudaFormatModeAuto = 1 -}; - -/* "cuda/ccudart.pxd":1060 - * ctypedef unsigned long long cudaSurfaceObject_t - * - * cdef enum cudaTextureAddressMode: # <<<<<<<<<<<<<< - * cudaAddressModeWrap = 0 - * cudaAddressModeClamp = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaTextureAddressMode { - __pyx_e_4cuda_7ccudart_cudaAddressModeWrap = 0, - __pyx_e_4cuda_7ccudart_cudaAddressModeClamp = 1, - __pyx_e_4cuda_7ccudart_cudaAddressModeMirror = 2, - __pyx_e_4cuda_7ccudart_cudaAddressModeBorder = 3 -}; - -/* "cuda/ccudart.pxd":1066 - * cudaAddressModeBorder = 3 - * - * cdef enum cudaTextureFilterMode: # <<<<<<<<<<<<<< - * cudaFilterModePoint = 0 - * cudaFilterModeLinear = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaTextureFilterMode { - __pyx_e_4cuda_7ccudart_cudaFilterModePoint = 0, - __pyx_e_4cuda_7ccudart_cudaFilterModeLinear = 1 -}; - -/* "cuda/ccudart.pxd":1070 - * cudaFilterModeLinear = 1 - * - * cdef enum cudaTextureReadMode: # <<<<<<<<<<<<<< - * cudaReadModeElementType = 0 - * cudaReadModeNormalizedFloat = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaTextureReadMode { - __pyx_e_4cuda_7ccudart_cudaReadModeElementType = 0, - __pyx_e_4cuda_7ccudart_cudaReadModeNormalizedFloat = 1 -}; - -/* "cuda/ccudart.pxd":1091 - * ctypedef unsigned long long cudaTextureObject_t - * - * cdef enum cudaDataType_t: # <<<<<<<<<<<<<< - * CUDA_R_16F = 2 - * CUDA_C_16F = 6 - */ -enum __pyx_t_4cuda_7ccudart_cudaDataType_t { - __pyx_e_4cuda_7ccudart_CUDA_R_16F = 2, - __pyx_e_4cuda_7ccudart_CUDA_C_16F = 6, - __pyx_e_4cuda_7ccudart_CUDA_R_16BF = 14, - __pyx_e_4cuda_7ccudart_CUDA_C_16BF = 15, - __pyx_e_4cuda_7ccudart_CUDA_R_32F = 0, - __pyx_e_4cuda_7ccudart_CUDA_C_32F = 4, - __pyx_e_4cuda_7ccudart_CUDA_R_64F = 1, - __pyx_e_4cuda_7ccudart_CUDA_C_64F = 5, - __pyx_e_4cuda_7ccudart_CUDA_R_4I = 16, - __pyx_e_4cuda_7ccudart_CUDA_C_4I = 17, - __pyx_e_4cuda_7ccudart_CUDA_R_4U = 18, - __pyx_e_4cuda_7ccudart_CUDA_C_4U = 19, - __pyx_e_4cuda_7ccudart_CUDA_R_8I = 3, - __pyx_e_4cuda_7ccudart_CUDA_C_8I = 7, - __pyx_e_4cuda_7ccudart_CUDA_R_8U = 8, - __pyx_e_4cuda_7ccudart_CUDA_C_8U = 9, - __pyx_e_4cuda_7ccudart_CUDA_R_16I = 20, - __pyx_e_4cuda_7ccudart_CUDA_C_16I = 21, - __pyx_e_4cuda_7ccudart_CUDA_R_16U = 22, - __pyx_e_4cuda_7ccudart_CUDA_C_16U = 23, - __pyx_e_4cuda_7ccudart_CUDA_R_32I = 10, - __pyx_e_4cuda_7ccudart_CUDA_C_32I = 11, - __pyx_e_4cuda_7ccudart_CUDA_R_32U = 12, - __pyx_e_4cuda_7ccudart_CUDA_C_32U = 13, - __pyx_e_4cuda_7ccudart_CUDA_R_64I = 24, - __pyx_e_4cuda_7ccudart_CUDA_C_64I = 25, - __pyx_e_4cuda_7ccudart_CUDA_R_64U = 26, - __pyx_e_4cuda_7ccudart_CUDA_C_64U = 27 -}; - -/* "cuda/ccudart.pxd":1123 - * ctypedef cudaDataType_t cudaDataType - * - * cdef enum libraryPropertyType_t: # <<<<<<<<<<<<<< - * MAJOR_VERSION = 0 - * MINOR_VERSION = 1 - */ -enum __pyx_t_4cuda_7ccudart_libraryPropertyType_t { - __pyx_e_4cuda_7ccudart_MAJOR_VERSION = 0, - __pyx_e_4cuda_7ccudart_MINOR_VERSION = 1, - __pyx_e_4cuda_7ccudart_PATCH_LEVEL = 2 -}; - -/* "cuda/ccudart.pxd":1701 - * cdef cudaError_t cudaGraphicsVDPAURegisterOutputSurface(cudaGraphicsResource** resource, VdpOutputSurface vdpSurface, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver - * - * cdef enum cudaGLDeviceList: # <<<<<<<<<<<<<< - * cudaGLDeviceListAll = 1 - * cudaGLDeviceListCurrentFrame = 2 - */ -enum __pyx_t_4cuda_7ccudart_cudaGLDeviceList { - __pyx_e_4cuda_7ccudart_cudaGLDeviceListAll = 1, - __pyx_e_4cuda_7ccudart_cudaGLDeviceListCurrentFrame = 2, - __pyx_e_4cuda_7ccudart_cudaGLDeviceListNextFrame = 3 -}; - -/* "cuda/ccudart.pxd":1712 - * cdef cudaError_t cudaGraphicsGLRegisterBuffer(cudaGraphicsResource** resource, GLuint buffer, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver - * - * cdef enum cudaGLMapFlags: # <<<<<<<<<<<<<< - * cudaGLMapFlagsNone = 0 - * cudaGLMapFlagsReadOnly = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaGLMapFlags { - __pyx_e_4cuda_7ccudart_cudaGLMapFlagsNone = 0, - __pyx_e_4cuda_7ccudart_cudaGLMapFlagsReadOnly = 1, - __pyx_e_4cuda_7ccudart_cudaGLMapFlagsWriteDiscard = 2 -}; - -/* "cuda/ccudart.pxd":1717 - * cudaGLMapFlagsWriteDiscard = 2 - * - * cdef enum cudaEglFrameType_enum: # <<<<<<<<<<<<<< - * cudaEglFrameTypeArray = 0 - * cudaEglFrameTypePitch = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaEglFrameType_enum { - __pyx_e_4cuda_7ccudart_cudaEglFrameTypeArray = 0, - __pyx_e_4cuda_7ccudart_cudaEglFrameTypePitch = 1 -}; - -/* "cuda/ccudart.pxd":1723 - * ctypedef cudaEglFrameType_enum cudaEglFrameType - * - * cdef enum cudaEglResourceLocationFlags_enum: # <<<<<<<<<<<<<< - * cudaEglResourceLocationSysmem = 0 - * cudaEglResourceLocationVidmem = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaEglResourceLocationFlags_enum { - __pyx_e_4cuda_7ccudart_cudaEglResourceLocationSysmem = 0, - __pyx_e_4cuda_7ccudart_cudaEglResourceLocationVidmem = 1 -}; - -/* "cuda/ccudart.pxd":1729 - * ctypedef cudaEglResourceLocationFlags_enum cudaEglResourceLocationFlags - * - * cdef enum cudaEglColorFormat_enum: # <<<<<<<<<<<<<< - * cudaEglColorFormatYUV420Planar = 0 - * cudaEglColorFormatYUV420SemiPlanar = 1 - */ -enum __pyx_t_4cuda_7ccudart_cudaEglColorFormat_enum { - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar = 0, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar = 1, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422Planar = 2, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422SemiPlanar = 3, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatARGB = 6, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatRGBA = 7, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatL = 8, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatR = 9, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444Planar = 10, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444SemiPlanar = 11, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUYV422 = 12, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatUYVY422 = 13, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatABGR = 14, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBGRA = 15, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatA = 16, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatRG = 17, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatAYUV = 18, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444SemiPlanar = 19, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422SemiPlanar = 20, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar = 21, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_444SemiPlanar = 22, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar = 23, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_444SemiPlanar = 24, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_420SemiPlanar = 25, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatVYUY_ER = 26, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatUYVY_ER = 27, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUYV_ER = 28, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVYU_ER = 29, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUVA_ER = 31, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatAYUV_ER = 32, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444Planar_ER = 33, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422Planar_ER = 34, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar_ER = 35, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV444SemiPlanar_ER = 36, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV422SemiPlanar_ER = 37, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar_ER = 38, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444Planar_ER = 39, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422Planar_ER = 40, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar_ER = 41, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444SemiPlanar_ER = 42, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422SemiPlanar_ER = 43, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar_ER = 44, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerRGGB = 45, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerBGGR = 46, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerGRBG = 47, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerGBRG = 48, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10RGGB = 49, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10BGGR = 50, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10GRBG = 51, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10GBRG = 52, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12RGGB = 53, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12BGGR = 54, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12GRBG = 55, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12GBRG = 56, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14RGGB = 57, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14BGGR = 58, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14GRBG = 59, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer14GBRG = 60, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20RGGB = 61, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20BGGR = 62, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20GRBG = 63, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer20GBRG = 64, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU444Planar = 65, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU422Planar = 66, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar = 67, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspRGGB = 68, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspBGGR = 69, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspGRBG = 70, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerIspGBRG = 71, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerBCCR = 72, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerRCCB = 73, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerCRBC = 74, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayerCBRC = 75, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer10CCCC = 76, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12BCCR = 77, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12RCCB = 78, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12CRBC = 79, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12CBRC = 80, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatBayer12CCCC = 81, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY = 82, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar_2020 = 83, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar_2020 = 84, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar_2020 = 85, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar_2020 = 86, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420SemiPlanar_709 = 87, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420SemiPlanar_709 = 88, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUV420Planar_709 = 89, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVU420Planar_709 = 90, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_709 = 91, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_2020 = 92, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_422SemiPlanar_2020 = 93, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_422SemiPlanar = 94, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_422SemiPlanar_709 = 95, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY_ER = 96, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY_709_ER = 97, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10_ER = 98, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10_709_ER = 99, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12_ER = 0x64, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12_709_ER = 0x65, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYUVA = 0x66, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatYVYU = 0x68, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatVYUY = 0x69, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_ER = 0x6A, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_420SemiPlanar_709_ER = 0x6B, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_444SemiPlanar_ER = 0x6C, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY10V10U10_444SemiPlanar_709_ER = 0x6D, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_420SemiPlanar_ER = 0x6E, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_420SemiPlanar_709_ER = 0x6F, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_444SemiPlanar_ER = 0x70, - __pyx_e_4cuda_7ccudart_cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 0x71 -}; - -/* "cuda/ccudart.pxd":1896 - * cdef cudaError_t cudaEventCreateFromEGLSync(cudaEvent_t* phEvent, EGLSyncKHR eglSync, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver - * - * cdef enum: cudaHostAllocDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostAllocPortable = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostAllocDefault = 0 -}; - -/* "cuda/ccudart.pxd":1898 - * cdef enum: cudaHostAllocDefault = 0 - * - * cdef enum: cudaHostAllocPortable = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostAllocMapped = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostAllocPortable = 1 -}; - -/* "cuda/ccudart.pxd":1900 - * cdef enum: cudaHostAllocPortable = 1 - * - * cdef enum: cudaHostAllocMapped = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostAllocWriteCombined = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostAllocMapped = 2 -}; - -/* "cuda/ccudart.pxd":1902 - * cdef enum: cudaHostAllocMapped = 2 - * - * cdef enum: cudaHostAllocWriteCombined = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostRegisterDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostAllocWriteCombined = 4 -}; - -/* "cuda/ccudart.pxd":1904 - * cdef enum: cudaHostAllocWriteCombined = 4 - * - * cdef enum: cudaHostRegisterDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostRegisterPortable = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostRegisterDefault = 0 -}; - -/* "cuda/ccudart.pxd":1906 - * cdef enum: cudaHostRegisterDefault = 0 - * - * cdef enum: cudaHostRegisterPortable = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostRegisterMapped = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostRegisterPortable = 1 -}; - -/* "cuda/ccudart.pxd":1908 - * cdef enum: cudaHostRegisterPortable = 1 - * - * cdef enum: cudaHostRegisterMapped = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostRegisterIoMemory = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostRegisterMapped = 2 -}; - -/* "cuda/ccudart.pxd":1910 - * cdef enum: cudaHostRegisterMapped = 2 - * - * cdef enum: cudaHostRegisterIoMemory = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaHostRegisterReadOnly = 8 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostRegisterIoMemory = 4 -}; - -/* "cuda/ccudart.pxd":1912 - * cdef enum: cudaHostRegisterIoMemory = 4 - * - * cdef enum: cudaHostRegisterReadOnly = 8 # <<<<<<<<<<<<<< - * - * cdef enum: cudaPeerAccessDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaHostRegisterReadOnly = 8 -}; - -/* "cuda/ccudart.pxd":1914 - * cdef enum: cudaHostRegisterReadOnly = 8 - * - * cdef enum: cudaPeerAccessDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaStreamDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaPeerAccessDefault = 0 -}; - -/* "cuda/ccudart.pxd":1916 - * cdef enum: cudaPeerAccessDefault = 0 - * - * cdef enum: cudaStreamDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaStreamNonBlocking = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaStreamDefault = 0 -}; - -/* "cuda/ccudart.pxd":1918 - * cdef enum: cudaStreamDefault = 0 - * - * cdef enum: cudaStreamNonBlocking = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaStreamLegacy = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaStreamNonBlocking = 1 -}; - -/* "cuda/ccudart.pxd":1920 - * cdef enum: cudaStreamNonBlocking = 1 - * - * cdef enum: cudaStreamLegacy = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaStreamPerThread = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaStreamLegacy = 1 -}; - -/* "cuda/ccudart.pxd":1922 - * cdef enum: cudaStreamLegacy = 1 - * - * cdef enum: cudaStreamPerThread = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaStreamPerThread = 2 -}; - -/* "cuda/ccudart.pxd":1924 - * cdef enum: cudaStreamPerThread = 2 - * - * cdef enum: cudaEventDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventBlockingSync = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventDefault = 0 -}; - -/* "cuda/ccudart.pxd":1926 - * cdef enum: cudaEventDefault = 0 - * - * cdef enum: cudaEventBlockingSync = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventDisableTiming = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventBlockingSync = 1 -}; - -/* "cuda/ccudart.pxd":1928 - * cdef enum: cudaEventBlockingSync = 1 - * - * cdef enum: cudaEventDisableTiming = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventInterprocess = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventDisableTiming = 2 -}; - -/* "cuda/ccudart.pxd":1930 - * cdef enum: cudaEventDisableTiming = 2 - * - * cdef enum: cudaEventInterprocess = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventRecordDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventInterprocess = 4 -}; - -/* "cuda/ccudart.pxd":1932 - * cdef enum: cudaEventInterprocess = 4 - * - * cdef enum: cudaEventRecordDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventRecordExternal = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventRecordDefault = 0 -}; - -/* "cuda/ccudart.pxd":1934 - * cdef enum: cudaEventRecordDefault = 0 - * - * cdef enum: cudaEventRecordExternal = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventWaitDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventRecordExternal = 1 -}; - -/* "cuda/ccudart.pxd":1936 - * cdef enum: cudaEventRecordExternal = 1 - * - * cdef enum: cudaEventWaitDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaEventWaitExternal = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventWaitDefault = 0 -}; - -/* "cuda/ccudart.pxd":1938 - * cdef enum: cudaEventWaitDefault = 0 - * - * cdef enum: cudaEventWaitExternal = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceScheduleAuto = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaEventWaitExternal = 1 -}; - -/* "cuda/ccudart.pxd":1940 - * cdef enum: cudaEventWaitExternal = 1 - * - * cdef enum: cudaDeviceScheduleAuto = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceScheduleSpin = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceScheduleAuto = 0 -}; - -/* "cuda/ccudart.pxd":1942 - * cdef enum: cudaDeviceScheduleAuto = 0 - * - * cdef enum: cudaDeviceScheduleSpin = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceScheduleYield = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceScheduleSpin = 1 -}; - -/* "cuda/ccudart.pxd":1944 - * cdef enum: cudaDeviceScheduleSpin = 1 - * - * cdef enum: cudaDeviceScheduleYield = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceScheduleBlockingSync = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceScheduleYield = 2 -}; - -/* "cuda/ccudart.pxd":1946 - * cdef enum: cudaDeviceScheduleYield = 2 - * - * cdef enum: cudaDeviceScheduleBlockingSync = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceBlockingSync = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceScheduleBlockingSync = 4 -}; - -/* "cuda/ccudart.pxd":1948 - * cdef enum: cudaDeviceScheduleBlockingSync = 4 - * - * cdef enum: cudaDeviceBlockingSync = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceScheduleMask = 7 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceBlockingSync = 4 -}; - -/* "cuda/ccudart.pxd":1950 - * cdef enum: cudaDeviceBlockingSync = 4 - * - * cdef enum: cudaDeviceScheduleMask = 7 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceMapHost = 8 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceScheduleMask = 7 -}; - -/* "cuda/ccudart.pxd":1952 - * cdef enum: cudaDeviceScheduleMask = 7 - * - * cdef enum: cudaDeviceMapHost = 8 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceLmemResizeToMax = 16 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceMapHost = 8 -}; - -/* "cuda/ccudart.pxd":1954 - * cdef enum: cudaDeviceMapHost = 8 - * - * cdef enum: cudaDeviceLmemResizeToMax = 16 # <<<<<<<<<<<<<< - * - * cdef enum: cudaDeviceMask = 31 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceLmemResizeToMax = 16 -}; - -/* "cuda/ccudart.pxd":1956 - * cdef enum: cudaDeviceLmemResizeToMax = 16 - * - * cdef enum: cudaDeviceMask = 31 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArrayDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaDeviceMask = 31 -}; - -/* "cuda/ccudart.pxd":1958 - * cdef enum: cudaDeviceMask = 31 - * - * cdef enum: cudaArrayDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArrayLayered = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArrayDefault = 0 -}; - -/* "cuda/ccudart.pxd":1960 - * cdef enum: cudaArrayDefault = 0 - * - * cdef enum: cudaArrayLayered = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArraySurfaceLoadStore = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArrayLayered = 1 -}; - -/* "cuda/ccudart.pxd":1962 - * cdef enum: cudaArrayLayered = 1 - * - * cdef enum: cudaArraySurfaceLoadStore = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArrayCubemap = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArraySurfaceLoadStore = 2 -}; - -/* "cuda/ccudart.pxd":1964 - * cdef enum: cudaArraySurfaceLoadStore = 2 - * - * cdef enum: cudaArrayCubemap = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArrayTextureGather = 8 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArrayCubemap = 4 -}; - -/* "cuda/ccudart.pxd":1966 - * cdef enum: cudaArrayCubemap = 4 - * - * cdef enum: cudaArrayTextureGather = 8 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArrayColorAttachment = 32 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArrayTextureGather = 8 -}; - -/* "cuda/ccudart.pxd":1968 - * cdef enum: cudaArrayTextureGather = 8 - * - * cdef enum: cudaArrayColorAttachment = 32 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArraySparse = 64 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArrayColorAttachment = 32 -}; - -/* "cuda/ccudart.pxd":1970 - * cdef enum: cudaArrayColorAttachment = 32 - * - * cdef enum: cudaArraySparse = 64 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArrayDeferredMapping = 128 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArraySparse = 64 -}; - -/* "cuda/ccudart.pxd":1972 - * cdef enum: cudaArraySparse = 64 - * - * cdef enum: cudaArrayDeferredMapping = 128 # <<<<<<<<<<<<<< - * - * cdef enum: cudaIpcMemLazyEnablePeerAccess = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArrayDeferredMapping = 0x80 -}; - -/* "cuda/ccudart.pxd":1974 - * cdef enum: cudaArrayDeferredMapping = 128 - * - * cdef enum: cudaIpcMemLazyEnablePeerAccess = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaMemAttachGlobal = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaIpcMemLazyEnablePeerAccess = 1 -}; - -/* "cuda/ccudart.pxd":1976 - * cdef enum: cudaIpcMemLazyEnablePeerAccess = 1 - * - * cdef enum: cudaMemAttachGlobal = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaMemAttachHost = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaMemAttachGlobal = 1 -}; - -/* "cuda/ccudart.pxd":1978 - * cdef enum: cudaMemAttachGlobal = 1 - * - * cdef enum: cudaMemAttachHost = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaMemAttachSingle = 4 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaMemAttachHost = 2 -}; - -/* "cuda/ccudart.pxd":1980 - * cdef enum: cudaMemAttachHost = 2 - * - * cdef enum: cudaMemAttachSingle = 4 # <<<<<<<<<<<<<< - * - * cdef enum: cudaOccupancyDefault = 0 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaMemAttachSingle = 4 -}; - -/* "cuda/ccudart.pxd":1982 - * cdef enum: cudaMemAttachSingle = 4 - * - * cdef enum: cudaOccupancyDefault = 0 # <<<<<<<<<<<<<< - * - * cdef enum: cudaOccupancyDisableCachingOverride = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaOccupancyDefault = 0 -}; - -/* "cuda/ccudart.pxd":1984 - * cdef enum: cudaOccupancyDefault = 0 - * - * cdef enum: cudaOccupancyDisableCachingOverride = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaCpuDeviceId = -1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaOccupancyDisableCachingOverride = 1 -}; - -/* "cuda/ccudart.pxd":1986 - * cdef enum: cudaOccupancyDisableCachingOverride = 1 - * - * cdef enum: cudaCpuDeviceId = -1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaInvalidDeviceId = -2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaCpuDeviceId = -1L -}; - -/* "cuda/ccudart.pxd":1988 - * cdef enum: cudaCpuDeviceId = -1 - * - * cdef enum: cudaInvalidDeviceId = -2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaCooperativeLaunchMultiDeviceNoPreSync = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaInvalidDeviceId = -2L -}; - -/* "cuda/ccudart.pxd":1990 - * cdef enum: cudaInvalidDeviceId = -2 - * - * cdef enum: cudaCooperativeLaunchMultiDeviceNoPreSync = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaCooperativeLaunchMultiDeviceNoPostSync = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaCooperativeLaunchMultiDeviceNoPreSync = 1 -}; - -/* "cuda/ccudart.pxd":1992 - * cdef enum: cudaCooperativeLaunchMultiDeviceNoPreSync = 1 - * - * cdef enum: cudaCooperativeLaunchMultiDeviceNoPostSync = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaArraySparsePropertiesSingleMipTail = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaCooperativeLaunchMultiDeviceNoPostSync = 2 -}; - -/* "cuda/ccudart.pxd":1994 - * cdef enum: cudaCooperativeLaunchMultiDeviceNoPostSync = 2 - * - * cdef enum: cudaArraySparsePropertiesSingleMipTail = 1 # <<<<<<<<<<<<<< - * - * cdef enum: CUDA_IPC_HANDLE_SIZE = 64 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaArraySparsePropertiesSingleMipTail = 1 -}; - -/* "cuda/ccudart.pxd":1996 - * cdef enum: cudaArraySparsePropertiesSingleMipTail = 1 - * - * cdef enum: CUDA_IPC_HANDLE_SIZE = 64 # <<<<<<<<<<<<<< - * - * cdef enum: cudaExternalMemoryDedicated = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_CUDA_IPC_HANDLE_SIZE = 64 -}; - -/* "cuda/ccudart.pxd":1998 - * cdef enum: CUDA_IPC_HANDLE_SIZE = 64 - * - * cdef enum: cudaExternalMemoryDedicated = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaExternalMemoryDedicated = 1 -}; - -/* "cuda/ccudart.pxd":2000 - * cdef enum: cudaExternalMemoryDedicated = 1 - * - * cdef enum: cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 -}; - -/* "cuda/ccudart.pxd":2002 - * cdef enum: cudaExternalSemaphoreSignalSkipNvSciBufMemSync = 1 - * - * cdef enum: cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaNvSciSyncAttrSignal = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 -}; - -/* "cuda/ccudart.pxd":2004 - * cdef enum: cudaExternalSemaphoreWaitSkipNvSciBufMemSync = 2 - * - * cdef enum: cudaNvSciSyncAttrSignal = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaNvSciSyncAttrWait = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaNvSciSyncAttrSignal = 1 -}; - -/* "cuda/ccudart.pxd":2006 - * cdef enum: cudaNvSciSyncAttrSignal = 1 - * - * cdef enum: cudaNvSciSyncAttrWait = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceType1D = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaNvSciSyncAttrWait = 2 -}; - -/* "cuda/ccudart.pxd":2008 - * cdef enum: cudaNvSciSyncAttrWait = 2 - * - * cdef enum: cudaSurfaceType1D = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceType2D = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceType1D = 1 -}; - -/* "cuda/ccudart.pxd":2010 - * cdef enum: cudaSurfaceType1D = 1 - * - * cdef enum: cudaSurfaceType2D = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceType3D = 3 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceType2D = 2 -}; - -/* "cuda/ccudart.pxd":2012 - * cdef enum: cudaSurfaceType2D = 2 - * - * cdef enum: cudaSurfaceType3D = 3 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceTypeCubemap = 12 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceType3D = 3 -}; - -/* "cuda/ccudart.pxd":2014 - * cdef enum: cudaSurfaceType3D = 3 - * - * cdef enum: cudaSurfaceTypeCubemap = 12 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceType1DLayered = 241 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceTypeCubemap = 12 -}; - -/* "cuda/ccudart.pxd":2016 - * cdef enum: cudaSurfaceTypeCubemap = 12 - * - * cdef enum: cudaSurfaceType1DLayered = 241 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceType2DLayered = 242 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceType1DLayered = 0xF1 -}; - -/* "cuda/ccudart.pxd":2018 - * cdef enum: cudaSurfaceType1DLayered = 241 - * - * cdef enum: cudaSurfaceType2DLayered = 242 # <<<<<<<<<<<<<< - * - * cdef enum: cudaSurfaceTypeCubemapLayered = 252 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceType2DLayered = 0xF2 -}; - -/* "cuda/ccudart.pxd":2020 - * cdef enum: cudaSurfaceType2DLayered = 242 - * - * cdef enum: cudaSurfaceTypeCubemapLayered = 252 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureType1D = 1 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaSurfaceTypeCubemapLayered = 0xFC -}; - -/* "cuda/ccudart.pxd":2022 - * cdef enum: cudaSurfaceTypeCubemapLayered = 252 - * - * cdef enum: cudaTextureType1D = 1 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureType2D = 2 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureType1D = 1 -}; - -/* "cuda/ccudart.pxd":2024 - * cdef enum: cudaTextureType1D = 1 - * - * cdef enum: cudaTextureType2D = 2 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureType3D = 3 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureType2D = 2 -}; - -/* "cuda/ccudart.pxd":2026 - * cdef enum: cudaTextureType2D = 2 - * - * cdef enum: cudaTextureType3D = 3 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureTypeCubemap = 12 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureType3D = 3 -}; - -/* "cuda/ccudart.pxd":2028 - * cdef enum: cudaTextureType3D = 3 - * - * cdef enum: cudaTextureTypeCubemap = 12 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureType1DLayered = 241 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureTypeCubemap = 12 -}; - -/* "cuda/ccudart.pxd":2030 - * cdef enum: cudaTextureTypeCubemap = 12 - * - * cdef enum: cudaTextureType1DLayered = 241 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureType2DLayered = 242 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureType1DLayered = 0xF1 -}; - -/* "cuda/ccudart.pxd":2032 - * cdef enum: cudaTextureType1DLayered = 241 - * - * cdef enum: cudaTextureType2DLayered = 242 # <<<<<<<<<<<<<< - * - * cdef enum: cudaTextureTypeCubemapLayered = 252 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureType2DLayered = 0xF2 -}; - -/* "cuda/ccudart.pxd":2034 - * cdef enum: cudaTextureType2DLayered = 242 - * - * cdef enum: cudaTextureTypeCubemapLayered = 252 # <<<<<<<<<<<<<< - * - * cdef enum: CUDART_VERSION = 11060 - */ -enum { - __pyx_e_4cuda_7ccudart_cudaTextureTypeCubemapLayered = 0xFC -}; - -/* "cuda/ccudart.pxd":2036 - * cdef enum: cudaTextureTypeCubemapLayered = 252 - * - * cdef enum: CUDART_VERSION = 11060 # <<<<<<<<<<<<<< - * - * cdef enum: __CUDART_API_VERSION = 11060 - */ -enum { - __pyx_e_4cuda_7ccudart_CUDART_VERSION = 0x2B34 -}; - -/* "cuda/ccudart.pxd":2038 - * cdef enum: CUDART_VERSION = 11060 - * - * cdef enum: __CUDART_API_VERSION = 11060 # <<<<<<<<<<<<<< - * - * cdef enum: CUDA_EGL_MAX_PLANES = 3 - */ -enum { - __pyx_e_4cuda_7ccudart___CUDART_API_VERSION = 0x2B34 -}; - -/* "cuda/ccudart.pxd":2040 - * cdef enum: __CUDART_API_VERSION = 11060 - * - * cdef enum: CUDA_EGL_MAX_PLANES = 3 # <<<<<<<<<<<<<< - */ -enum { - __pyx_e_4cuda_7ccudart_CUDA_EGL_MAX_PLANES = 3 -}; - -/* "cuda/ccudart.pxd":15 - * cudaRoundMinInf = 3 - * - * cdef struct dim3: # <<<<<<<<<<<<<< - * unsigned int x - * unsigned int y - */ -struct __pyx_t_4cuda_7ccudart_dim3 { - unsigned int x; - unsigned int y; - unsigned int z; -}; - -/* "cuda/ccudart.pxd":178 - * cudaChannelFormatKindUnsignedBlockCompressed7SRGB = 30 - * - * cdef struct cudaChannelFormatDesc: # <<<<<<<<<<<<<< - * int x - * int y - */ -struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc { - int x; - int y; - int z; - int w; - enum __pyx_t_4cuda_7ccudart_cudaChannelFormatKind f; -}; - -/* "cuda/ccudart.pxd":188 - * cdef struct cudaArray: - * pass - * ctypedef cudaArray* cudaArray_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct cudaArray *__pyx_t_4cuda_7ccudart_cudaArray_t; - -/* "cuda/ccudart.pxd":193 - * cdef struct cudaArray: - * pass - * ctypedef cudaArray* cudaArray_const_t # <<<<<<<<<<<<<< - * - * - */ -typedef struct cudaArray *__pyx_t_4cuda_7ccudart_cudaArray_const_t; - -/* "cuda/ccudart.pxd":199 - * cdef struct cudaMipmappedArray: - * pass - * ctypedef cudaMipmappedArray* cudaMipmappedArray_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct cudaMipmappedArray *__pyx_t_4cuda_7ccudart_cudaMipmappedArray_t; - -/* "cuda/ccudart.pxd":204 - * cdef struct cudaMipmappedArray: - * pass - * ctypedef cudaMipmappedArray* cudaMipmappedArray_const_t # <<<<<<<<<<<<<< - * - * - */ -typedef struct cudaMipmappedArray *__pyx_t_4cuda_7ccudart_cudaMipmappedArray_const_t; - -/* "cuda/ccudart.pxd":207 - * - * - * cdef struct _cudaArraySparseProperties_tileExtent_s: # <<<<<<<<<<<<<< - * unsigned int width - * unsigned int height - */ -struct __pyx_t_4cuda_7ccudart__cudaArraySparseProperties_tileExtent_s { - unsigned int width; - unsigned int height; - unsigned int depth; -}; - -/* "cuda/ccudart.pxd":212 - * unsigned int depth - * - * cdef struct cudaArraySparseProperties: # <<<<<<<<<<<<<< - * _cudaArraySparseProperties_tileExtent_s tileExtent - * unsigned int miptailFirstLevel - */ -struct __pyx_t_4cuda_7ccudart_cudaArraySparseProperties { - struct __pyx_t_4cuda_7ccudart__cudaArraySparseProperties_tileExtent_s tileExtent; - unsigned int miptailFirstLevel; - unsigned PY_LONG_LONG miptailSize; - unsigned int flags; - unsigned int reserved[4]; -}; - -/* "cuda/ccudart.pxd":219 - * unsigned int reserved[4] - * - * cdef struct cudaArrayMemoryRequirements: # <<<<<<<<<<<<<< - * size_t size - * size_t alignment - */ -struct __pyx_t_4cuda_7ccudart_cudaArrayMemoryRequirements { - size_t size; - size_t alignment; - unsigned int reserved[4]; -}; - -/* "cuda/ccudart.pxd":237 - * cudaMemcpyDefault = 4 - * - * cdef struct cudaPitchedPtr: # <<<<<<<<<<<<<< - * void* ptr - * size_t pitch - */ -struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr { - void *ptr; - size_t pitch; - size_t xsize; - size_t ysize; -}; - -/* "cuda/ccudart.pxd":243 - * size_t ysize - * - * cdef struct cudaExtent: # <<<<<<<<<<<<<< - * size_t width - * size_t height - */ -struct __pyx_t_4cuda_7ccudart_cudaExtent { - size_t width; - size_t height; - size_t depth; -}; - -/* "cuda/ccudart.pxd":248 - * size_t depth - * - * cdef struct cudaPos: # <<<<<<<<<<<<<< - * size_t x - * size_t y - */ -struct __pyx_t_4cuda_7ccudart_cudaPos { - size_t x; - size_t y; - size_t z; -}; - -/* "cuda/ccudart.pxd":253 - * size_t z - * - * cdef struct cudaMemcpy3DParms: # <<<<<<<<<<<<<< - * cudaArray_t srcArray - * cudaPos srcPos - */ -struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DParms { - __pyx_t_4cuda_7ccudart_cudaArray_t srcArray; - struct __pyx_t_4cuda_7ccudart_cudaPos srcPos; - struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr srcPtr; - __pyx_t_4cuda_7ccudart_cudaArray_t dstArray; - struct __pyx_t_4cuda_7ccudart_cudaPos dstPos; - struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr dstPtr; - struct __pyx_t_4cuda_7ccudart_cudaExtent extent; - enum __pyx_t_4cuda_7ccudart_cudaMemcpyKind kind; -}; - -/* "cuda/ccudart.pxd":263 - * cudaMemcpyKind kind - * - * cdef struct cudaMemcpy3DPeerParms: # <<<<<<<<<<<<<< - * cudaArray_t srcArray - * cudaPos srcPos - */ -struct __pyx_t_4cuda_7ccudart_cudaMemcpy3DPeerParms { - __pyx_t_4cuda_7ccudart_cudaArray_t srcArray; - struct __pyx_t_4cuda_7ccudart_cudaPos srcPos; - struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr srcPtr; - int srcDevice; - __pyx_t_4cuda_7ccudart_cudaArray_t dstArray; - struct __pyx_t_4cuda_7ccudart_cudaPos dstPos; - struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr dstPtr; - int dstDevice; - struct __pyx_t_4cuda_7ccudart_cudaExtent extent; -}; - -/* "cuda/ccudart.pxd":274 - * cudaExtent extent - * - * cdef struct cudaMemsetParams: # <<<<<<<<<<<<<< - * void* dst - * size_t pitch - */ -struct __pyx_t_4cuda_7ccudart_cudaMemsetParams { - void *dst; - size_t pitch; - unsigned int value; - unsigned int elementSize; - size_t width; - size_t height; -}; - -/* "cuda/ccudart.pxd":287 - * cudaAccessPropertyPersisting = 2 - * - * cdef struct cudaAccessPolicyWindow: # <<<<<<<<<<<<<< - * void* base_ptr - * size_t num_bytes - */ -struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow { - void *base_ptr; - size_t num_bytes; - float hitRatio; - enum __pyx_t_4cuda_7ccudart_cudaAccessProperty hitProp; - enum __pyx_t_4cuda_7ccudart_cudaAccessProperty missProp; -}; - -/* "cuda/ccudart.pxd":294 - * cudaAccessProperty missProp - * - * ctypedef void (*cudaHostFn_t)(void* userData) # <<<<<<<<<<<<<< - * - * cdef struct cudaHostNodeParams: - */ -typedef void (*__pyx_t_4cuda_7ccudart_cudaHostFn_t)(void *); - -/* "cuda/ccudart.pxd":296 - * ctypedef void (*cudaHostFn_t)(void* userData) - * - * cdef struct cudaHostNodeParams: # <<<<<<<<<<<<<< - * cudaHostFn_t fn - * void* userData - */ -struct __pyx_t_4cuda_7ccudart_cudaHostNodeParams { - __pyx_t_4cuda_7ccudart_cudaHostFn_t fn; - void *userData; -}; - -/* "cuda/ccudart.pxd":320 - * cudaStreamAttributeSynchronizationPolicy = 3 - * - * cdef union cudaStreamAttrValue: # <<<<<<<<<<<<<< - * cudaAccessPolicyWindow accessPolicyWindow - * cudaSynchronizationPolicy syncPolicy - */ -union __pyx_t_4cuda_7ccudart_cudaStreamAttrValue { - struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow accessPolicyWindow; - enum __pyx_t_4cuda_7ccudart_cudaSynchronizationPolicy syncPolicy; -}; - -/* "cuda/ccudart.pxd":359 - * cudaKernelNodeAttributeCooperative = 2 - * - * cdef union cudaKernelNodeAttrValue: # <<<<<<<<<<<<<< - * cudaAccessPolicyWindow accessPolicyWindow - * int cooperative - */ -union __pyx_t_4cuda_7ccudart_cudaKernelNodeAttrValue { - struct __pyx_t_4cuda_7ccudart_cudaAccessPolicyWindow accessPolicyWindow; - int cooperative; -}; - -/* "cuda/ccudart.pxd":406 - * cudaResViewFormatUnsignedBlockCompressed7 = 34 - * - * cdef struct _cudaResourceDesc_res_res_array_s: # <<<<<<<<<<<<<< - * cudaArray_t array - * - */ -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_array_s { - __pyx_t_4cuda_7ccudart_cudaArray_t array; -}; - -/* "cuda/ccudart.pxd":409 - * cudaArray_t array - * - * cdef struct _cudaResourceDesc_res_res_mipmap_s: # <<<<<<<<<<<<<< - * cudaMipmappedArray_t mipmap - * - */ -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_mipmap_s { - __pyx_t_4cuda_7ccudart_cudaMipmappedArray_t mipmap; -}; - -/* "cuda/ccudart.pxd":412 - * cudaMipmappedArray_t mipmap - * - * cdef struct _cudaResourceDesc_res_res_linear_s: # <<<<<<<<<<<<<< - * void* devPtr - * cudaChannelFormatDesc desc - */ -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_linear_s { - void *devPtr; - struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc desc; - size_t sizeInBytes; -}; - -/* "cuda/ccudart.pxd":417 - * size_t sizeInBytes - * - * cdef struct _cudaResourceDesc_res_res_pitch2D_s: # <<<<<<<<<<<<<< - * void* devPtr - * cudaChannelFormatDesc desc - */ -struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_pitch2D_s { - void *devPtr; - struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc desc; - size_t width; - size_t height; - size_t pitchInBytes; -}; - -/* "cuda/ccudart.pxd":424 - * size_t pitchInBytes - * - * cdef union _cudaResourceDesc_res_u: # <<<<<<<<<<<<<< - * _cudaResourceDesc_res_res_array_s array - * _cudaResourceDesc_res_res_mipmap_s mipmap - */ -union __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_u { - struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_array_s array; - struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_mipmap_s mipmap; - struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_linear_s linear; - struct __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_res_pitch2D_s pitch2D; -}; - -/* "cuda/ccudart.pxd":430 - * _cudaResourceDesc_res_res_pitch2D_s pitch2D - * - * cdef struct cudaResourceDesc: # <<<<<<<<<<<<<< - * cudaResourceType resType - * _cudaResourceDesc_res_u res - */ -struct __pyx_t_4cuda_7ccudart_cudaResourceDesc { - enum __pyx_t_4cuda_7ccudart_cudaResourceType resType; - union __pyx_t_4cuda_7ccudart__cudaResourceDesc_res_u res; -}; - -/* "cuda/ccudart.pxd":434 - * _cudaResourceDesc_res_u res - * - * cdef struct cudaResourceViewDesc: # <<<<<<<<<<<<<< - * cudaResourceViewFormat format - * size_t width - */ -struct __pyx_t_4cuda_7ccudart_cudaResourceViewDesc { - enum __pyx_t_4cuda_7ccudart_cudaResourceViewFormat format; - size_t width; - size_t height; - size_t depth; - unsigned int firstMipmapLevel; - unsigned int lastMipmapLevel; - unsigned int firstLayer; - unsigned int lastLayer; -}; - -/* "cuda/ccudart.pxd":444 - * unsigned int lastLayer - * - * cdef struct cudaPointerAttributes: # <<<<<<<<<<<<<< - * cudaMemoryType type - * int device - */ -struct __pyx_t_4cuda_7ccudart_cudaPointerAttributes { - enum __pyx_t_4cuda_7ccudart_cudaMemoryType type; - int device; - void *devicePointer; - void *hostPointer; -}; - -/* "cuda/ccudart.pxd":450 - * void* hostPointer - * - * cdef struct cudaFuncAttributes: # <<<<<<<<<<<<<< - * size_t sharedSizeBytes - * size_t constSizeBytes - */ -struct __pyx_t_4cuda_7ccudart_cudaFuncAttributes { - size_t sharedSizeBytes; - size_t constSizeBytes; - size_t localSizeBytes; - int maxThreadsPerBlock; - int numRegs; - int ptxVersion; - int binaryVersion; - int cacheModeCA; - int maxDynamicSharedSizeBytes; - int preferredShmemCarveout; -}; - -/* "cuda/ccudart.pxd":663 - * cudaMemLocationTypeDevice = 1 - * - * cdef struct cudaMemLocation: # <<<<<<<<<<<<<< - * cudaMemLocationType type - * int id - */ -struct __pyx_t_4cuda_7ccudart_cudaMemLocation { - enum __pyx_t_4cuda_7ccudart_cudaMemLocationType type; - int id; -}; - -/* "cuda/ccudart.pxd":672 - * cudaMemAccessFlagsProtReadWrite = 3 - * - * cdef struct cudaMemAccessDesc: # <<<<<<<<<<<<<< - * cudaMemLocation location - * cudaMemAccessFlags flags - */ -struct __pyx_t_4cuda_7ccudart_cudaMemAccessDesc { - struct __pyx_t_4cuda_7ccudart_cudaMemLocation location; - enum __pyx_t_4cuda_7ccudart_cudaMemAccessFlags flags; -}; - -/* "cuda/ccudart.pxd":687 - * cudaMemHandleTypeWin32Kmt = 4 - * - * cdef struct cudaMemPoolProps: # <<<<<<<<<<<<<< - * cudaMemAllocationType allocType - * cudaMemAllocationHandleType handleTypes - */ -struct __pyx_t_4cuda_7ccudart_cudaMemPoolProps { - enum __pyx_t_4cuda_7ccudart_cudaMemAllocationType allocType; - enum __pyx_t_4cuda_7ccudart_cudaMemAllocationHandleType handleTypes; - struct __pyx_t_4cuda_7ccudart_cudaMemLocation location; - void *win32SecurityAttributes; - unsigned char reserved[64]; -}; - -/* "cuda/ccudart.pxd":694 - * unsigned char reserved[64] - * - * cdef struct cudaMemPoolPtrExportData: # <<<<<<<<<<<<<< - * unsigned char reserved[64] - * - */ -struct __pyx_t_4cuda_7ccudart_cudaMemPoolPtrExportData { - unsigned char reserved[64]; -}; - -/* "cuda/ccudart.pxd":697 - * unsigned char reserved[64] - * - * cdef struct cudaMemAllocNodeParams: # <<<<<<<<<<<<<< - * cudaMemPoolProps poolProps - * const cudaMemAccessDesc* accessDescs - */ -struct __pyx_t_4cuda_7ccudart_cudaMemAllocNodeParams { - struct __pyx_t_4cuda_7ccudart_cudaMemPoolProps poolProps; - struct __pyx_t_4cuda_7ccudart_cudaMemAccessDesc const *accessDescs; - size_t accessDescCount; - size_t bytesize; - void *dptr; -}; - -/* "cuda/ccudart.pxd":716 - * cudaDevP2PAttrCudaArrayAccessSupported = 4 - * - * cdef struct CUuuid_st: # <<<<<<<<<<<<<< - * char bytes[16] - * - */ -struct __pyx_t_4cuda_7ccudart_CUuuid_st { - char bytes[16]; -}; - -/* "cuda/ccudart.pxd":719 - * char bytes[16] - * - * ctypedef CUuuid_st CUuuid # <<<<<<<<<<<<<< - * - * ctypedef CUuuid_st cudaUUID_t - */ -typedef struct __pyx_t_4cuda_7ccudart_CUuuid_st __pyx_t_4cuda_7ccudart_CUuuid; - -/* "cuda/ccudart.pxd":721 - * ctypedef CUuuid_st CUuuid - * - * ctypedef CUuuid_st cudaUUID_t # <<<<<<<<<<<<<< - * - * cdef struct cudaDeviceProp: - */ -typedef struct __pyx_t_4cuda_7ccudart_CUuuid_st __pyx_t_4cuda_7ccudart_cudaUUID_t; - -/* "cuda/ccudart.pxd":723 - * ctypedef CUuuid_st cudaUUID_t - * - * cdef struct cudaDeviceProp: # <<<<<<<<<<<<<< - * char name[256] - * cudaUUID_t uuid - */ -struct __pyx_t_4cuda_7ccudart_cudaDeviceProp { - char name[0x100]; - __pyx_t_4cuda_7ccudart_cudaUUID_t uuid; - char luid[8]; - unsigned int luidDeviceNodeMask; - size_t totalGlobalMem; - size_t sharedMemPerBlock; - int regsPerBlock; - int warpSize; - size_t memPitch; - int maxThreadsPerBlock; - int maxThreadsDim[3]; - int maxGridSize[3]; - int clockRate; - size_t totalConstMem; - int major; - int minor; - size_t textureAlignment; - size_t texturePitchAlignment; - int deviceOverlap; - int multiProcessorCount; - int kernelExecTimeoutEnabled; - int integrated; - int canMapHostMemory; - int computeMode; - int maxTexture1D; - int maxTexture1DMipmap; - int maxTexture1DLinear; - int maxTexture2D[2]; - int maxTexture2DMipmap[2]; - int maxTexture2DLinear[3]; - int maxTexture2DGather[2]; - int maxTexture3D[3]; - int maxTexture3DAlt[3]; - int maxTextureCubemap; - int maxTexture1DLayered[2]; - int maxTexture2DLayered[3]; - int maxTextureCubemapLayered[2]; - int maxSurface1D; - int maxSurface2D[2]; - int maxSurface3D[3]; - int maxSurface1DLayered[2]; - int maxSurface2DLayered[3]; - int maxSurfaceCubemap; - int maxSurfaceCubemapLayered[2]; - size_t surfaceAlignment; - int concurrentKernels; - int ECCEnabled; - int pciBusID; - int pciDeviceID; - int pciDomainID; - int tccDriver; - int asyncEngineCount; - int unifiedAddressing; - int memoryClockRate; - int memoryBusWidth; - int l2CacheSize; - int persistingL2CacheMaxSize; - int maxThreadsPerMultiProcessor; - int streamPrioritiesSupported; - int globalL1CacheSupported; - int localL1CacheSupported; - size_t sharedMemPerMultiprocessor; - int regsPerMultiprocessor; - int managedMemory; - int isMultiGpuBoard; - int multiGpuBoardGroupID; - int hostNativeAtomicSupported; - int singleToDoublePrecisionPerfRatio; - int pageableMemoryAccess; - int concurrentManagedAccess; - int computePreemptionSupported; - int canUseHostPointerForRegisteredMem; - int cooperativeLaunch; - int cooperativeMultiDeviceLaunch; - size_t sharedMemPerBlockOptin; - int pageableMemoryAccessUsesHostPageTables; - int directManagedMemAccessFromHost; - int maxBlocksPerMultiProcessor; - int accessPolicyMaxWindowSize; - size_t reservedSharedMemPerBlock; -}; - -/* "cuda/ccudart.pxd":805 - * size_t reservedSharedMemPerBlock - * - * cdef struct cudaIpcEventHandle_st: # <<<<<<<<<<<<<< - * char reserved[64] - * - */ -struct __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_st { - char reserved[64]; -}; - -/* "cuda/ccudart.pxd":808 - * char reserved[64] - * - * ctypedef cudaIpcEventHandle_st cudaIpcEventHandle_t # <<<<<<<<<<<<<< - * - * cdef struct cudaIpcMemHandle_st: - */ -typedef struct __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_st __pyx_t_4cuda_7ccudart_cudaIpcEventHandle_t; - -/* "cuda/ccudart.pxd":810 - * ctypedef cudaIpcEventHandle_st cudaIpcEventHandle_t - * - * cdef struct cudaIpcMemHandle_st: # <<<<<<<<<<<<<< - * char reserved[64] - * - */ -struct __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_st { - char reserved[64]; -}; - -/* "cuda/ccudart.pxd":813 - * char reserved[64] - * - * ctypedef cudaIpcMemHandle_st cudaIpcMemHandle_t # <<<<<<<<<<<<<< - * - * cdef enum cudaExternalMemoryHandleType: - */ -typedef struct __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_st __pyx_t_4cuda_7ccudart_cudaIpcMemHandle_t; - -/* "cuda/ccudart.pxd":825 - * cudaExternalMemoryHandleTypeNvSciBuf = 8 - * - * cdef struct _cudaExternalMemoryHandleDesc_handle_handle_win32_s: # <<<<<<<<<<<<<< - * void* handle - * void* name - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_handle_win32_s { - void *handle; - void *name; -}; - -/* "cuda/ccudart.pxd":829 - * void* name - * - * cdef union _cudaExternalMemoryHandleDesc_handle_u: # <<<<<<<<<<<<<< - * int fd - * _cudaExternalMemoryHandleDesc_handle_handle_win32_s win32 - */ -union __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_u { - int fd; - struct __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_handle_win32_s win32; - void *nvSciBufObject; -}; - -/* "cuda/ccudart.pxd":834 - * void* nvSciBufObject - * - * cdef struct cudaExternalMemoryHandleDesc: # <<<<<<<<<<<<<< - * cudaExternalMemoryHandleType type - * _cudaExternalMemoryHandleDesc_handle_u handle - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleDesc { - enum __pyx_t_4cuda_7ccudart_cudaExternalMemoryHandleType type; - union __pyx_t_4cuda_7ccudart__cudaExternalMemoryHandleDesc_handle_u handle; - unsigned PY_LONG_LONG size; - unsigned int flags; -}; - -/* "cuda/ccudart.pxd":840 - * unsigned int flags - * - * cdef struct cudaExternalMemoryBufferDesc: # <<<<<<<<<<<<<< - * unsigned long long offset - * unsigned long long size - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryBufferDesc { - unsigned PY_LONG_LONG offset; - unsigned PY_LONG_LONG size; - unsigned int flags; -}; - -/* "cuda/ccudart.pxd":845 - * unsigned int flags - * - * cdef struct cudaExternalMemoryMipmappedArrayDesc: # <<<<<<<<<<<<<< - * unsigned long long offset - * cudaChannelFormatDesc formatDesc - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalMemoryMipmappedArrayDesc { - unsigned PY_LONG_LONG offset; - struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc formatDesc; - struct __pyx_t_4cuda_7ccudart_cudaExtent extent; - unsigned int flags; - unsigned int numLevels; -}; - -/* "cuda/ccudart.pxd":864 - * cudaExternalSemaphoreHandleTypeTimelineSemaphoreWin32 = 10 - * - * cdef struct _cudaExternalSemaphoreHandleDesc_handle_handle_win32_s: # <<<<<<<<<<<<<< - * void* handle - * void* name - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_handle_win32_s { - void *handle; - void *name; -}; - -/* "cuda/ccudart.pxd":868 - * void* name - * - * cdef union _cudaExternalSemaphoreHandleDesc_handle_u: # <<<<<<<<<<<<<< - * int fd - * _cudaExternalSemaphoreHandleDesc_handle_handle_win32_s win32 - */ -union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_u { - int fd; - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_handle_win32_s win32; - void *nvSciSyncObj; -}; - -/* "cuda/ccudart.pxd":873 - * void* nvSciSyncObj - * - * cdef struct cudaExternalSemaphoreHandleDesc: # <<<<<<<<<<<<<< - * cudaExternalSemaphoreHandleType type - * _cudaExternalSemaphoreHandleDesc_handle_u handle - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleDesc { - enum __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreHandleType type; - union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreHandleDesc_handle_u handle; - unsigned int flags; -}; - -/* "cuda/ccudart.pxd":878 - * unsigned int flags - * - * cdef struct _cudaExternalSemaphoreSignalParams_params_params_fence_s: # <<<<<<<<<<<<<< - * unsigned long long value - * - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_fence_s { - unsigned PY_LONG_LONG value; -}; - -/* "cuda/ccudart.pxd":881 - * unsigned long long value - * - * cdef union _cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u: # <<<<<<<<<<<<<< - * void* fence - * unsigned long long reserved - */ -union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u { - void *fence; - unsigned PY_LONG_LONG reserved; -}; - -/* "cuda/ccudart.pxd":885 - * unsigned long long reserved - * - * cdef struct _cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s: # <<<<<<<<<<<<<< - * unsigned long long key - * - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s { - unsigned PY_LONG_LONG key; -}; - -/* "cuda/ccudart.pxd":888 - * unsigned long long key - * - * cdef struct _cudaExternalSemaphoreSignalParams_params_s: # <<<<<<<<<<<<<< - * _cudaExternalSemaphoreSignalParams_params_params_fence_s fence - * _cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u nvSciSync - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_s { - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_fence_s fence; - union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_nvSciSync_u nvSciSync; - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_params_keyedMutex_s keyedMutex; - unsigned int reserved[12]; -}; - -/* "cuda/ccudart.pxd":894 - * unsigned int reserved[12] - * - * cdef struct cudaExternalSemaphoreSignalParams: # <<<<<<<<<<<<<< - * _cudaExternalSemaphoreSignalParams_params_s params - * unsigned int flags - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalParams { - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreSignalParams_params_s params; - unsigned int flags; - unsigned int reserved[16]; -}; - -/* "cuda/ccudart.pxd":899 - * unsigned int reserved[16] - * - * cdef struct _cudaExternalSemaphoreWaitParams_params_params_fence_s: # <<<<<<<<<<<<<< - * unsigned long long value - * - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_fence_s { - unsigned PY_LONG_LONG value; -}; - -/* "cuda/ccudart.pxd":902 - * unsigned long long value - * - * cdef union _cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u: # <<<<<<<<<<<<<< - * void* fence - * unsigned long long reserved - */ -union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u { - void *fence; - unsigned PY_LONG_LONG reserved; -}; - -/* "cuda/ccudart.pxd":906 - * unsigned long long reserved - * - * cdef struct _cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s: # <<<<<<<<<<<<<< - * unsigned long long key - * unsigned int timeoutMs - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s { - unsigned PY_LONG_LONG key; - unsigned int timeoutMs; -}; - -/* "cuda/ccudart.pxd":910 - * unsigned int timeoutMs - * - * cdef struct _cudaExternalSemaphoreWaitParams_params_s: # <<<<<<<<<<<<<< - * _cudaExternalSemaphoreWaitParams_params_params_fence_s fence - * _cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u nvSciSync - */ -struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_s { - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_fence_s fence; - union __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_nvSciSync_u nvSciSync; - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_params_keyedMutex_s keyedMutex; - unsigned int reserved[10]; -}; - -/* "cuda/ccudart.pxd":916 - * unsigned int reserved[10] - * - * cdef struct cudaExternalSemaphoreWaitParams: # <<<<<<<<<<<<<< - * _cudaExternalSemaphoreWaitParams_params_s params - * unsigned int flags - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitParams { - struct __pyx_t_4cuda_7ccudart__cudaExternalSemaphoreWaitParams_params_s params; - unsigned int flags; - unsigned int reserved[16]; -}; - -/* "cuda/ccudart.pxd":921 - * unsigned int reserved[16] - * - * ctypedef cudaError cudaError_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef enum __pyx_t_4cuda_7ccudart_cudaError __pyx_t_4cuda_7ccudart_cudaError_t; - -/* "cuda/ccudart.pxd":926 - * cdef struct CUstream_st: - * pass - * ctypedef CUstream_st* cudaStream_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUstream_st *__pyx_t_4cuda_7ccudart_cudaStream_t; - -/* "cuda/ccudart.pxd":931 - * cdef struct CUevent_st: - * pass - * ctypedef CUevent_st* cudaEvent_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUevent_st *__pyx_t_4cuda_7ccudart_cudaEvent_t; - -/* "cuda/ccudart.pxd":936 - * cdef struct cudaGraphicsResource: - * pass - * ctypedef cudaGraphicsResource* cudaGraphicsResource_t # <<<<<<<<<<<<<< - * - * ctypedef cudaOutputMode cudaOutputMode_t - */ -typedef struct cudaGraphicsResource *__pyx_t_4cuda_7ccudart_cudaGraphicsResource_t; - -/* "cuda/ccudart.pxd":938 - * ctypedef cudaGraphicsResource* cudaGraphicsResource_t - * - * ctypedef cudaOutputMode cudaOutputMode_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef enum __pyx_t_4cuda_7ccudart_cudaOutputMode __pyx_t_4cuda_7ccudart_cudaOutputMode_t; - -/* "cuda/ccudart.pxd":943 - * cdef struct CUexternalMemory_st: - * pass - * ctypedef CUexternalMemory_st* cudaExternalMemory_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUexternalMemory_st *__pyx_t_4cuda_7ccudart_cudaExternalMemory_t; - -/* "cuda/ccudart.pxd":948 - * cdef struct CUexternalSemaphore_st: - * pass - * ctypedef CUexternalSemaphore_st* cudaExternalSemaphore_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUexternalSemaphore_st *__pyx_t_4cuda_7ccudart_cudaExternalSemaphore_t; - -/* "cuda/ccudart.pxd":953 - * cdef struct CUgraph_st: - * pass - * ctypedef CUgraph_st* cudaGraph_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUgraph_st *__pyx_t_4cuda_7ccudart_cudaGraph_t; - -/* "cuda/ccudart.pxd":958 - * cdef struct CUgraphNode_st: - * pass - * ctypedef CUgraphNode_st* cudaGraphNode_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUgraphNode_st *__pyx_t_4cuda_7ccudart_cudaGraphNode_t; - -/* "cuda/ccudart.pxd":963 - * cdef struct CUuserObject_st: - * pass - * ctypedef CUuserObject_st* cudaUserObject_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUuserObject_st *__pyx_t_4cuda_7ccudart_cudaUserObject_t; - -/* "cuda/ccudart.pxd":968 - * cdef struct CUfunc_st: - * pass - * ctypedef CUfunc_st* cudaFunction_t # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct CUfunc_st *__pyx_t_4cuda_7ccudart_cudaFunction_t; - -/* "cuda/ccudart.pxd":973 - * cdef struct CUmemPoolHandle_st: - * pass - * ctypedef CUmemPoolHandle_st* cudaMemPool_t # <<<<<<<<<<<<<< - * - * cdef enum cudaCGScope: - */ -typedef struct CUmemPoolHandle_st *__pyx_t_4cuda_7ccudart_cudaMemPool_t; - -/* "cuda/ccudart.pxd":980 - * cudaCGScopeMultiGrid = 2 - * - * cdef struct cudaKernelNodeParams: # <<<<<<<<<<<<<< - * void* func - * dim3 gridDim - */ -struct __pyx_t_4cuda_7ccudart_cudaKernelNodeParams { - void *func; - struct __pyx_t_4cuda_7ccudart_dim3 gridDim; - struct __pyx_t_4cuda_7ccudart_dim3 blockDim; - unsigned int sharedMemBytes; - void **kernelParams; - void **extra; -}; - -/* "cuda/ccudart.pxd":988 - * void** extra - * - * cdef struct cudaExternalSemaphoreSignalNodeParams: # <<<<<<<<<<<<<< - * cudaExternalSemaphore_t* extSemArray - * const cudaExternalSemaphoreSignalParams* paramsArray - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalNodeParams { - __pyx_t_4cuda_7ccudart_cudaExternalSemaphore_t *extSemArray; - struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreSignalParams const *paramsArray; - unsigned int numExtSems; -}; - -/* "cuda/ccudart.pxd":993 - * unsigned int numExtSems - * - * cdef struct cudaExternalSemaphoreWaitNodeParams: # <<<<<<<<<<<<<< - * cudaExternalSemaphore_t* extSemArray - * const cudaExternalSemaphoreWaitParams* paramsArray - */ -struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitNodeParams { - __pyx_t_4cuda_7ccudart_cudaExternalSemaphore_t *extSemArray; - struct __pyx_t_4cuda_7ccudart_cudaExternalSemaphoreWaitParams const *paramsArray; - unsigned int numExtSems; -}; - -/* "cuda/ccudart.pxd":1016 - * cdef struct CUgraphExec_st: - * pass - * ctypedef CUgraphExec_st* cudaGraphExec_t # <<<<<<<<<<<<<< - * - * cdef enum cudaGraphExecUpdateResult: - */ -typedef struct CUgraphExec_st *__pyx_t_4cuda_7ccudart_cudaGraphExec_t; - -/* "cuda/ccudart.pxd":1074 - * cudaReadModeNormalizedFloat = 1 - * - * cdef struct cudaTextureDesc: # <<<<<<<<<<<<<< - * cudaTextureAddressMode addressMode[3] - * cudaTextureFilterMode filterMode - */ -struct __pyx_t_4cuda_7ccudart_cudaTextureDesc { - enum __pyx_t_4cuda_7ccudart_cudaTextureAddressMode addressMode[3]; - enum __pyx_t_4cuda_7ccudart_cudaTextureFilterMode filterMode; - enum __pyx_t_4cuda_7ccudart_cudaTextureReadMode readMode; - int sRGB; - float borderColor[4]; - int normalizedCoords; - unsigned int maxAnisotropy; - enum __pyx_t_4cuda_7ccudart_cudaTextureFilterMode mipmapFilterMode; - float mipmapLevelBias; - float minMipmapLevelClamp; - float maxMipmapLevelClamp; - int disableTrilinearOptimization; - int seamlessCubemap; -}; - -/* "cuda/ccudart.pxd":1121 - * CUDA_C_64U = 27 - * - * ctypedef cudaDataType_t cudaDataType # <<<<<<<<<<<<<< - * - * cdef enum libraryPropertyType_t: - */ -typedef enum __pyx_t_4cuda_7ccudart_cudaDataType_t __pyx_t_4cuda_7ccudart_cudaDataType; - -/* "cuda/ccudart.pxd":1128 - * PATCH_LEVEL = 2 - * - * ctypedef libraryPropertyType_t libraryPropertyType # <<<<<<<<<<<<<< - * - * cdef cudaError_t cudaDeviceReset() nogil except ?cudaErrorCallRequiresNewerDriver - */ -typedef enum __pyx_t_4cuda_7ccudart_libraryPropertyType_t __pyx_t_4cuda_7ccudart_libraryPropertyType; - -/* "cuda/ccudart.pxd":1234 - * cdef cudaError_t cudaStreamWaitEvent(cudaStream_t stream, cudaEvent_t event, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver - * - * ctypedef void (*cudaStreamCallback_t)(cudaStream_t stream, cudaError_t status, void* userData) # <<<<<<<<<<<<<< - * - * cdef cudaError_t cudaStreamAddCallback(cudaStream_t stream, cudaStreamCallback_t callback, void* userData, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver - */ -typedef void (*__pyx_t_4cuda_7ccudart_cudaStreamCallback_t)(__pyx_t_4cuda_7ccudart_cudaStream_t, __pyx_t_4cuda_7ccudart_cudaError_t, void *); - -/* "cuda/ccudart.pxd":1671 - * cdef struct void: - * pass - * ctypedef void* EGLImageKHR # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef void *__pyx_t_4cuda_7ccudart_EGLImageKHR; - -/* "cuda/ccudart.pxd":1676 - * cdef struct void: - * pass - * ctypedef void* EGLStreamKHR # <<<<<<<<<<<<<< - * - * ctypedef unsigned int EGLint - */ -typedef void *__pyx_t_4cuda_7ccudart_EGLStreamKHR; - -/* "cuda/ccudart.pxd":1683 - * cdef struct void: - * pass - * ctypedef void* EGLSyncKHR # <<<<<<<<<<<<<< - * - * ctypedef uint32_t VdpDevice - */ -typedef void *__pyx_t_4cuda_7ccudart_EGLSyncKHR; - -/* "cuda/ccudart.pxd":1721 - * cudaEglFrameTypePitch = 1 - * - * ctypedef cudaEglFrameType_enum cudaEglFrameType # <<<<<<<<<<<<<< - * - * cdef enum cudaEglResourceLocationFlags_enum: - */ -typedef enum __pyx_t_4cuda_7ccudart_cudaEglFrameType_enum __pyx_t_4cuda_7ccudart_cudaEglFrameType; - -/* "cuda/ccudart.pxd":1727 - * cudaEglResourceLocationVidmem = 1 - * - * ctypedef cudaEglResourceLocationFlags_enum cudaEglResourceLocationFlags # <<<<<<<<<<<<<< - * - * cdef enum cudaEglColorFormat_enum: - */ -typedef enum __pyx_t_4cuda_7ccudart_cudaEglResourceLocationFlags_enum __pyx_t_4cuda_7ccudart_cudaEglResourceLocationFlags; - -/* "cuda/ccudart.pxd":1841 - * cudaEglColorFormatY12V12U12_444SemiPlanar_709_ER = 113 - * - * ctypedef cudaEglColorFormat_enum cudaEglColorFormat # <<<<<<<<<<<<<< - * - * cdef struct cudaEglPlaneDesc_st: - */ -typedef enum __pyx_t_4cuda_7ccudart_cudaEglColorFormat_enum __pyx_t_4cuda_7ccudart_cudaEglColorFormat; - -/* "cuda/ccudart.pxd":1843 - * ctypedef cudaEglColorFormat_enum cudaEglColorFormat - * - * cdef struct cudaEglPlaneDesc_st: # <<<<<<<<<<<<<< - * unsigned int width - * unsigned int height - */ -struct __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc_st { - unsigned int width; - unsigned int height; - unsigned int depth; - unsigned int pitch; - unsigned int numChannels; - struct __pyx_t_4cuda_7ccudart_cudaChannelFormatDesc channelDesc; - unsigned int reserved[4]; -}; - -/* "cuda/ccudart.pxd":1852 - * unsigned int reserved[4] - * - * ctypedef cudaEglPlaneDesc_st cudaEglPlaneDesc # <<<<<<<<<<<<<< - * - * cdef union _cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u: - */ -typedef struct __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc_st __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc; - -/* "cuda/ccudart.pxd":1854 - * ctypedef cudaEglPlaneDesc_st cudaEglPlaneDesc - * - * cdef union _cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u: # <<<<<<<<<<<<<< - * cudaArray_t pArray[3] - * cudaPitchedPtr pPitch[3] - */ -union __pyx_t_4cuda_7ccudart__cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u { - __pyx_t_4cuda_7ccudart_cudaArray_t pArray[3]; - struct __pyx_t_4cuda_7ccudart_cudaPitchedPtr pPitch[3]; -}; - -/* "cuda/ccudart.pxd":1858 - * cudaPitchedPtr pPitch[3] - * - * cdef struct cudaEglFrame_st: # <<<<<<<<<<<<<< - * _cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u frame - * cudaEglPlaneDesc planeDesc[3] - */ -struct __pyx_t_4cuda_7ccudart_cudaEglFrame_st { - union __pyx_t_4cuda_7ccudart__cudaEglFrame_cudaEglFrame_cudaEglFrame_st_frame_u frame; - __pyx_t_4cuda_7ccudart_cudaEglPlaneDesc planeDesc[3]; - unsigned int planeCount; - __pyx_t_4cuda_7ccudart_cudaEglFrameType frameType; - __pyx_t_4cuda_7ccudart_cudaEglColorFormat eglColorFormat; -}; - -/* "cuda/ccudart.pxd":1865 - * cudaEglColorFormat eglColorFormat - * - * ctypedef cudaEglFrame_st cudaEglFrame # <<<<<<<<<<<<<< - * - * cdef extern from "": - */ -typedef struct __pyx_t_4cuda_7ccudart_cudaEglFrame_st __pyx_t_4cuda_7ccudart_cudaEglFrame; - -/* "cuda/ccudart.pxd":1870 - * cdef struct CUeglStreamConnection_st: - * pass - * ctypedef CUeglStreamConnection_st* cudaEglStreamConnection # <<<<<<<<<<<<<< - * - * cdef cudaError_t cudaGraphicsEGLRegisterImage(cudaGraphicsResource_t* pCudaResource, EGLImageKHR image, unsigned int flags) nogil except ?cudaErrorCallRequiresNewerDriver - */ -typedef struct CUeglStreamConnection_st *__pyx_t_4cuda_7ccudart_cudaEglStreamConnection; -struct __pyx_opt_args_3rmm_5_cuda_6stream_6Stream__from_cudaStream_t; - -/* "rmm/_cuda/stream.pxd":27 - * - * @staticmethod - * cdef Stream _from_cudaStream_t(cudaStream_t s, object owner=*) # <<<<<<<<<<<<<< - * - * cdef cuda_stream_view view(self) nogil except * - */ -struct __pyx_opt_args_3rmm_5_cuda_6stream_6Stream__from_cudaStream_t { - int __pyx_n; - PyObject *owner; -}; -struct __pyx_opt_args_3rmm_4_lib_15memory_resource_21BinningMemoryResource_add_bin; - -/* "rmm/_lib/memory_resource.pxd":56 - * - * cpdef add_bin( - * self, # <<<<<<<<<<<<<< - * size_t allocation_size, - * DeviceMemoryResource bin_resource=*) - */ -struct __pyx_opt_args_3rmm_4_lib_15memory_resource_21BinningMemoryResource_add_bin { - int __pyx_n; - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *bin_resource; -}; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_c_to_device; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_to_host; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_host; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_device; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_tobytes; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_resize; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_to_device; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_ptr_to_host; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_host_to_ptr; -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_device_to_ptr; - -/* "rmm/_lib/device_buffer.pxd":52 - * - * @staticmethod - * cdef DeviceBuffer c_to_device(const unsigned char[::1] b, # <<<<<<<<<<<<<< - * Stream stream=*) - * cpdef copy_to_host(self, ary=*, Stream stream=*) - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_c_to_device { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":54 - * cdef DeviceBuffer c_to_device(const unsigned char[::1] b, - * Stream stream=*) - * cpdef copy_to_host(self, ary=*, Stream stream=*) # <<<<<<<<<<<<<< - * cpdef copy_from_host(self, ary, Stream stream=*) - * cpdef copy_from_device(self, cuda_ary, Stream stream=*) - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_to_host { - int __pyx_n; - PyObject *ary; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":55 - * Stream stream=*) - * cpdef copy_to_host(self, ary=*, Stream stream=*) - * cpdef copy_from_host(self, ary, Stream stream=*) # <<<<<<<<<<<<<< - * cpdef copy_from_device(self, cuda_ary, Stream stream=*) - * cpdef bytes tobytes(self, Stream stream=*) - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_host { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":56 - * cpdef copy_to_host(self, ary=*, Stream stream=*) - * cpdef copy_from_host(self, ary, Stream stream=*) - * cpdef copy_from_device(self, cuda_ary, Stream stream=*) # <<<<<<<<<<<<<< - * cpdef bytes tobytes(self, Stream stream=*) - * - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_device { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":57 - * cpdef copy_from_host(self, ary, Stream stream=*) - * cpdef copy_from_device(self, cuda_ary, Stream stream=*) - * cpdef bytes tobytes(self, Stream stream=*) # <<<<<<<<<<<<<< - * - * cdef size_t c_size(self) except * - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_tobytes { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":60 - * - * cdef size_t c_size(self) except * - * cpdef void resize(self, size_t new_size, Stream stream=*) except * # <<<<<<<<<<<<<< - * cpdef size_t capacity(self) except * - * cdef void* c_data(self) except * - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_resize { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":66 - * cdef device_buffer c_release(self) except * - * - * cpdef DeviceBuffer to_device(const unsigned char[::1] b, # <<<<<<<<<<<<<< - * Stream stream=*) - * cpdef void copy_ptr_to_host(uintptr_t db, - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_to_device { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":68 - * cpdef DeviceBuffer to_device(const unsigned char[::1] b, - * Stream stream=*) - * cpdef void copy_ptr_to_host(uintptr_t db, # <<<<<<<<<<<<<< - * unsigned char[::1] hb, - * Stream stream=*) except * - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_ptr_to_host { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":72 - * Stream stream=*) except * - * - * cpdef void copy_host_to_ptr(const unsigned char[::1] hb, # <<<<<<<<<<<<<< - * uintptr_t db, - * Stream stream=*) except * - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_host_to_ptr { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_lib/device_buffer.pxd":76 - * Stream stream=*) except * - * - * cpdef void copy_device_to_ptr(uintptr_t d_src, # <<<<<<<<<<<<<< - * uintptr_t d_dst, - * size_t count, - */ -struct __pyx_opt_args_3rmm_4_lib_13device_buffer_copy_device_to_ptr { - int __pyx_n; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - -/* "rmm/_cuda/stream.pxd":22 - * - * - * cdef class Stream: # <<<<<<<<<<<<<< - * cdef cudaStream_t _cuda_stream - * cdef object _owner - */ -struct __pyx_obj_3rmm_5_cuda_6stream_Stream { - PyObject_HEAD - struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream *__pyx_vtab; - __pyx_t_4cuda_7ccudart_cudaStream_t _cuda_stream; - PyObject *_owner; -}; - - -/* "rmm/_lib/memory_resource.pxd":27 - * void deallocate(void* ptr, size_t bytes) except + - * - * cdef class DeviceMemoryResource: # <<<<<<<<<<<<<< - * cdef shared_ptr[device_memory_resource] c_obj - * cdef device_memory_resource* get_mr(self) - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource { - PyObject_HEAD - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource *__pyx_vtab; - std::shared_ptr c_obj; -}; - - -/* "rmm/_lib/memory_resource.pxd":31 - * cdef device_memory_resource* get_mr(self) - * - * cdef class UpstreamResourceAdaptor(DeviceMemoryResource): # <<<<<<<<<<<<<< - * cdef readonly DeviceMemoryResource upstream_mr - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor { - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *upstream_mr; -}; - - -/* "rmm/_lib/memory_resource.pxd":36 - * cpdef DeviceMemoryResource get_upstream(self) - * - * cdef class CudaMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":39 - * pass - * - * cdef class ManagedMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_ManagedMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":42 - * pass - * - * cdef class CudaAsyncMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":45 - * pass - * - * cdef class PoolMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_PoolMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":48 - * pass - * - * cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":51 - * pass - * - * cdef class BinningMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * - * cdef readonly list bin_mrs - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; - PyObject *bin_mrs; -}; - - -/* "rmm/_lib/memory_resource.pxd":60 - * DeviceMemoryResource bin_resource=*) - * - * cdef class CallbackMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * cdef object _allocate_func - * cdef object _deallocate_func - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_CallbackMemoryResource { - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; - PyObject *_allocate_func; - PyObject *_deallocate_func; -}; - - -/* "rmm/_lib/memory_resource.pxd":64 - * cdef object _deallocate_func - * - * cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * cdef object _log_file_name - * cpdef get_file_name(self) - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; - PyObject *_log_file_name; -}; - - -/* "rmm/_lib/memory_resource.pxd":69 - * cpdef flush(self) - * - * cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":72 - * pass - * - * cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; - - -/* "rmm/_lib/memory_resource.pxd":75 - * pass - * - * cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * cdef object _callback - * - */ -struct __pyx_obj_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor { - struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; - PyObject *_callback; -}; - - -/* "rmm/_lib/device_buffer.pxd":36 - * - * - * cdef class DeviceBuffer: # <<<<<<<<<<<<<< - * cdef unique_ptr[device_buffer] c_obj - * - */ -struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer { - PyObject_HEAD - struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_vtab; - std::unique_ptr c_obj; - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *mr; - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *stream; -}; - - -/* "cudf/_lib/column.pxd":13 - * - * - * cdef class Column: # <<<<<<<<<<<<<< - * cdef public: - * cdef int _offset - */ -struct __pyx_obj_4cudf_4_lib_6column_Column { - PyObject_HEAD - struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *__pyx_vtab; - int _offset; - int _size; - PyObject *_dtype; - PyObject *_base_children; - PyObject *_base_data; - PyObject *_base_mask; - PyObject *_children; - PyObject *_data; - PyObject *_mask; - PyObject *_null_count; -}; - - -/* "View.MemoryView":105 - * - * @cname("__pyx_array") - * cdef class array: # <<<<<<<<<<<<<< - * - * cdef: - */ -struct __pyx_array_obj { - PyObject_HEAD - struct __pyx_vtabstruct_array *__pyx_vtab; - char *data; - Py_ssize_t len; - char *format; - int ndim; - Py_ssize_t *_shape; - Py_ssize_t *_strides; - Py_ssize_t itemsize; - PyObject *mode; - PyObject *_format; - void (*callback_free_data)(void *); - int free_data; - int dtype_is_object; -}; - - -/* "View.MemoryView":279 - * - * @cname('__pyx_MemviewEnum') - * cdef class Enum(object): # <<<<<<<<<<<<<< - * cdef object name - * def __init__(self, name): - */ -struct __pyx_MemviewEnum_obj { - PyObject_HEAD - PyObject *name; -}; - - -/* "View.MemoryView":330 - * - * @cname('__pyx_memoryview') - * cdef class memoryview(object): # <<<<<<<<<<<<<< - * - * cdef object obj - */ -struct __pyx_memoryview_obj { - PyObject_HEAD - struct __pyx_vtabstruct_memoryview *__pyx_vtab; - PyObject *obj; - PyObject *_size; - PyObject *_array_interface; - PyThread_type_lock lock; - __pyx_atomic_int acquisition_count[2]; - __pyx_atomic_int *acquisition_count_aligned_p; - Py_buffer view; - int flags; - int dtype_is_object; - __Pyx_TypeInfo *typeinfo; -}; - - -/* "View.MemoryView":965 - * - * @cname('__pyx_memoryviewslice') - * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< - * "Internal class for passing memoryview slices to Python" - * - */ -struct __pyx_memoryviewslice_obj { - struct __pyx_memoryview_obj __pyx_base; - __Pyx_memviewslice from_slice; - PyObject *from_object; - PyObject *(*to_object_func)(char *); - int (*to_dtype_func)(char *, PyObject *); -}; - - - -/* "rmm/_cuda/stream.pxd":22 - * - * - * cdef class Stream: # <<<<<<<<<<<<<< - * cdef cudaStream_t _cuda_stream - * cdef object _owner - */ - -struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream { - struct __pyx_obj_3rmm_5_cuda_6stream_Stream *(*_from_cudaStream_t)(__pyx_t_4cuda_7ccudart_cudaStream_t, struct __pyx_opt_args_3rmm_5_cuda_6stream_6Stream__from_cudaStream_t *__pyx_optional_args); - rmm::cuda_stream_view (*view)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); - void (*c_synchronize)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); - bool (*c_is_default)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); - void (*_init_with_new_cuda_stream)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); - void (*_init_from_stream)(struct __pyx_obj_3rmm_5_cuda_6stream_Stream *, struct __pyx_obj_3rmm_5_cuda_6stream_Stream *); -}; -static struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream *__pyx_vtabptr_3rmm_5_cuda_6stream_Stream; - - -/* "rmm/_lib/memory_resource.pxd":27 - * void deallocate(void* ptr, size_t bytes) except + - * - * cdef class DeviceMemoryResource: # <<<<<<<<<<<<<< - * cdef shared_ptr[device_memory_resource] c_obj - * cdef device_memory_resource* get_mr(self) - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource { - rmm::mr::device_memory_resource *(*get_mr)(struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *); -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_DeviceMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":31 - * cdef device_memory_resource* get_mr(self) - * - * cdef class UpstreamResourceAdaptor(DeviceMemoryResource): # <<<<<<<<<<<<<< - * cdef readonly DeviceMemoryResource upstream_mr - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; - struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource *(*get_upstream)(struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor; - - -/* "rmm/_lib/memory_resource.pxd":36 - * cpdef DeviceMemoryResource get_upstream(self) - * - * cdef class CudaMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":39 - * pass - * - * cdef class ManagedMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_ManagedMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_ManagedMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_ManagedMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":42 - * pass - * - * cdef class CudaAsyncMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":45 - * pass - * - * cdef class PoolMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_PoolMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_PoolMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_PoolMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":48 - * pass - * - * cdef class FixedSizeMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":51 - * pass - * - * cdef class BinningMemoryResource(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * - * cdef readonly list bin_mrs - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_BinningMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; - PyObject *(*add_bin)(struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_15memory_resource_21BinningMemoryResource_add_bin *__pyx_optional_args); -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_BinningMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_BinningMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":60 - * DeviceMemoryResource bin_resource=*) - * - * cdef class CallbackMemoryResource(DeviceMemoryResource): # <<<<<<<<<<<<<< - * cdef object _allocate_func - * cdef object _deallocate_func - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CallbackMemoryResource { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CallbackMemoryResource *__pyx_vtabptr_3rmm_4_lib_15memory_resource_CallbackMemoryResource; - - -/* "rmm/_lib/memory_resource.pxd":64 - * cdef object _deallocate_func - * - * cdef class LoggingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * cdef object _log_file_name - * cpdef get_file_name(self) - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; - PyObject *(*get_file_name)(struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor *, int __pyx_skip_dispatch); - PyObject *(*flush)(struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor; - - -/* "rmm/_lib/memory_resource.pxd":69 - * cpdef flush(self) - * - * cdef class StatisticsResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor; - - -/* "rmm/_lib/memory_resource.pxd":72 - * pass - * - * cdef class TrackingResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * pass - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor; - - -/* "rmm/_lib/memory_resource.pxd":75 - * pass - * - * cdef class FailureCallbackResourceAdaptor(UpstreamResourceAdaptor): # <<<<<<<<<<<<<< - * cdef object _callback - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor { - struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor __pyx_base; -}; -static struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor *__pyx_vtabptr_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor; - - -/* "rmm/_lib/device_buffer.pxd":36 - * - * - * cdef class DeviceBuffer: # <<<<<<<<<<<<<< - * cdef unique_ptr[device_buffer] c_obj - * - */ - -struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer { - struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *(*c_from_unique_ptr)(std::unique_ptr ); - struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *(*c_to_device)(__Pyx_memviewslice, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_c_to_device *__pyx_optional_args); - PyObject *(*copy_to_host)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_to_host *__pyx_optional_args); - PyObject *(*copy_from_host)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_host *__pyx_optional_args); - PyObject *(*copy_from_device)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_copy_from_device *__pyx_optional_args); - PyObject *(*tobytes)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_tobytes *__pyx_optional_args); - size_t (*c_size)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *); - void (*resize)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, size_t, int __pyx_skip_dispatch, struct __pyx_opt_args_3rmm_4_lib_13device_buffer_12DeviceBuffer_resize *__pyx_optional_args); - size_t (*capacity)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *, int __pyx_skip_dispatch); - void *(*c_data)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *); - rmm::device_buffer (*c_release)(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *); -}; -static struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer; - - -/* "cudf/_lib/column.pxd":13 - * - * - * cdef class Column: # <<<<<<<<<<<<<< - * cdef public: - * cdef int _offset - */ - -struct __pyx_vtabstruct_4cudf_4_lib_6column_Column { - cudf::column_view (*_view)(struct __pyx_obj_4cudf_4_lib_6column_Column *, cudf::size_type); - cudf::column_view (*view)(struct __pyx_obj_4cudf_4_lib_6column_Column *); - cudf::mutable_column_view (*mutable_view)(struct __pyx_obj_4cudf_4_lib_6column_Column *); - struct __pyx_obj_4cudf_4_lib_6column_Column *(*from_unique_ptr)(std::unique_ptr ); - struct __pyx_obj_4cudf_4_lib_6column_Column *(*from_column_view)(cudf::column_view, PyObject *); - cudf::size_type (*compute_null_count)(struct __pyx_obj_4cudf_4_lib_6column_Column *); -}; -static struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *__pyx_vtabptr_4cudf_4_lib_6column_Column; - - -/* "View.MemoryView":105 - * - * @cname("__pyx_array") - * cdef class array: # <<<<<<<<<<<<<< - * - * cdef: - */ - -struct __pyx_vtabstruct_array { - PyObject *(*get_memview)(struct __pyx_array_obj *); -}; -static struct __pyx_vtabstruct_array *__pyx_vtabptr_array; - - -/* "View.MemoryView":330 - * - * @cname('__pyx_memoryview') - * cdef class memoryview(object): # <<<<<<<<<<<<<< - * - * cdef object obj - */ - -struct __pyx_vtabstruct_memoryview { - char *(*get_item_pointer)(struct __pyx_memoryview_obj *, PyObject *); - PyObject *(*is_slice)(struct __pyx_memoryview_obj *, PyObject *); - PyObject *(*setitem_slice_assignment)(struct __pyx_memoryview_obj *, PyObject *, PyObject *); - PyObject *(*setitem_slice_assign_scalar)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *); - PyObject *(*setitem_indexed)(struct __pyx_memoryview_obj *, PyObject *, PyObject *); - PyObject *(*convert_item_to_object)(struct __pyx_memoryview_obj *, char *); - PyObject *(*assign_item_from_object)(struct __pyx_memoryview_obj *, char *, PyObject *); -}; -static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview; - - -/* "View.MemoryView":965 - * - * @cname('__pyx_memoryviewslice') - * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< - * "Internal class for passing memoryview slices to Python" - * - */ - -struct __pyx_vtabstruct__memoryviewslice { - struct __pyx_vtabstruct_memoryview __pyx_base; -}; -static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, const char*); - void (*FinishContext)(void**); - } __Pyx_RefNannyAPIStruct; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; - static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); - #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; -#ifdef WITH_THREAD - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - if (acquire_gil) {\ - PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - PyGILState_Release(__pyx_gilstate_save);\ - } else {\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #define __Pyx_RefNannyFinishContext()\ - __Pyx_RefNanny->FinishContext(&__pyx_refnanny) - #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) - #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #define __Pyx_RefNannyFinishContext() - #define __Pyx_INCREF(r) Py_INCREF(r) - #define __Pyx_DECREF(r) Py_DECREF(r) - #define __Pyx_GOTREF(r) - #define __Pyx_GIVEREF(r) - #define __Pyx_XINCREF(r) Py_XINCREF(r) - #define __Pyx_XDECREF(r) Py_XDECREF(r) - #define __Pyx_XGOTREF(r) - #define __Pyx_XGIVEREF(r) -#endif -#define __Pyx_XDECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_XDECREF(tmp);\ - } while (0) -#define __Pyx_DECREF_SET(r, v) do {\ - PyObject *tmp = (PyObject *) r;\ - r = v; __Pyx_DECREF(tmp);\ - } while (0) -#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) -#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) - -/* RaiseArgTupleInvalid.proto */ -static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, - Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* PyObjectGetAttrStr.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#define __Pyx_BUILD_ASSERT_EXPR(cond)\ - (sizeof(char [1 - 2*!(cond)]) - 1) -#ifndef Py_MEMBER_SIZE -#define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) -#endif -#if CYTHON_FAST_PYCALL - static size_t __pyx_pyframe_localsplus_offset = 0; - #include "frameobject.h" -#if PY_VERSION_HEX >= 0x030b00a6 - #ifndef Py_BUILD_CORE - #define Py_BUILD_CORE 1 - #endif - #include "internal/pycore_frame.h" -#endif - #define __Pxy_PyFrame_Initialize_Offsets()\ - ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\ - (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus))) - #define __Pyx_PyFrame_GetLocalsplus(frame)\ - (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset)) -#endif // CYTHON_FAST_PYCALL -#endif - -/* PyObjectCall.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); -#else -#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) -#endif - -/* PyObjectCall2Args.proto */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2); - -/* PyObjectCallMethO.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); -#endif - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\ - __Pyx_GetItemInt_Generic(o, to_py_func(i)))) -#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - int wraparound, int boundscheck); -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, - int is_list, int wraparound, int boundscheck); - -/* ExtTypeTest.proto */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* PyDictVersioning.proto */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -#define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1) -#define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\ - (version_var) = __PYX_GET_DICT_VERSION(dict);\ - (cache_var) = (value); -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\ - (VAR) = __pyx_dict_cached_value;\ - } else {\ - (VAR) = __pyx_dict_cached_value = (LOOKUP);\ - __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\ - }\ -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj); -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj); -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version); -#else -#define __PYX_GET_DICT_VERSION(dict) (0) -#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var) -#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP); -#endif - -/* GetModuleGlobalName.proto */ -#if CYTHON_USE_DICT_VERSIONS -#define __Pyx_GetModuleGlobalName(var, name) {\ - static PY_UINT64_T __pyx_dict_version = 0;\ - static PyObject *__pyx_dict_cached_value = NULL;\ - (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\ - (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\ - __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -#define __Pyx_GetModuleGlobalNameUncached(var, name) {\ - PY_UINT64_T __pyx_dict_version;\ - PyObject *__pyx_dict_cached_value;\ - (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\ -} -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value); -#else -#define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name) -#define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name) -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name); -#endif - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() PyErr_Occurred() -#endif - -/* PyErrFetchRestore.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) -#define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) -#else -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#endif -#else -#define __Pyx_PyErr_Clear() PyErr_Clear() -#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) -#define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) -#define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) -#define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) -#endif - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* IncludeStringH.proto */ -#include - -/* BytesEquals.proto */ -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); - -/* UnicodeEquals.proto */ -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); - -/* StrEquals.proto */ -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals -#else -#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals -#endif - -/* DivInt[Py_ssize_t].proto */ -static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t, Py_ssize_t); - -/* UnaryNegOverflows.proto */ -#define UNARY_NEG_WOULD_OVERFLOW(x)\ - (((x) < 0) & ((unsigned long)(x) == 0-(unsigned long)(x))) - -static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *); /*proto*/ -/* GetAttr.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *); - -/* ObjectGetItem.proto */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key); -#else -#define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key) -#endif - -/* decode_c_string_utf16.proto */ -static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { - int byteorder = 0; - return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); -} -static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { - int byteorder = -1; - return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); -} -static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { - int byteorder = 1; - return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); -} - -/* decode_c_string.proto */ -static CYTHON_INLINE PyObject* __Pyx_decode_c_string( - const char* cstring, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); - -/* PyErrExceptionMatches.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err) -static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err); -#else -#define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err) -#endif - -/* GetAttr3.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *); - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* RaiseNoneIterError.proto */ -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); - -/* GetTopmostException.proto */ -#if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate); -#endif - -/* SaveResetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); -#else -#define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb) -#define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb) -#endif - -/* GetException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb) -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* SwapException.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb) -static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); -#else -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); -#endif - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); -#else -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) -#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) - -static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -/* ListCompAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len)) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - __Pyx_SET_SIZE(list, len + 1); - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) -#endif - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check); -#else -#define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\ - (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2)) -#endif - -/* ListExtend.proto */ -static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) { -#if CYTHON_COMPILING_IN_CPYTHON - PyObject* none = _PyList_Extend((PyListObject*)L, v); - if (unlikely(!none)) - return -1; - Py_DECREF(none); - return 0; -#else - return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v); -#endif -} - -/* ListAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - __Pyx_SET_SIZE(list, len + 1); - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) -#endif - -/* None.proto */ -static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname); - -/* DivInt[long].proto */ -static CYTHON_INLINE long __Pyx_div_long(long, long); - -/* PySequenceContains.proto */ -static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) { - int result = PySequence_Contains(seq, item); - return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); -} - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* HasAttr.proto */ -static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *); - -/* PyObject_GenericGetAttrNoDict.proto */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr -#endif - -/* PyObject_GenericGetAttr.proto */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name); -#else -#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr -#endif - -/* SetVTable.proto */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); - -/* PyObjectGetAttrStrNoError.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name); - -/* SetupReduce.proto */ -static int __Pyx_setup_reduce(PyObject* type_obj); - -/* TypeImport.proto */ -#ifndef __PYX_HAVE_RT_ImportType_proto -#define __PYX_HAVE_RT_ImportType_proto -enum __Pyx_ImportType_CheckSize { - __Pyx_ImportType_CheckSize_Error = 0, - __Pyx_ImportType_CheckSize_Warn = 1, - __Pyx_ImportType_CheckSize_Ignore = 2 -}; -static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size); -#endif - -/* GetVTable.proto */ -static void* __Pyx_GetVtable(PyObject *dict); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* GCCDiagnostics.proto */ -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) -#define __Pyx_HAS_GCC_DIAGNOSTIC -#endif - -/* CppExceptionConversion.proto */ -#ifndef __Pyx_CppExn2PyErr -#include -#include -#include -#include -static void __Pyx_CppExn2PyErr() { - try { - if (PyErr_Occurred()) - ; // let the latest Python exn pass through and ignore the current one - else - throw; - } catch (const std::bad_alloc& exn) { - PyErr_SetString(PyExc_MemoryError, exn.what()); - } catch (const std::bad_cast& exn) { - PyErr_SetString(PyExc_TypeError, exn.what()); - } catch (const std::bad_typeid& exn) { - PyErr_SetString(PyExc_TypeError, exn.what()); - } catch (const std::domain_error& exn) { - PyErr_SetString(PyExc_ValueError, exn.what()); - } catch (const std::invalid_argument& exn) { - PyErr_SetString(PyExc_ValueError, exn.what()); - } catch (const std::ios_base::failure& exn) { - PyErr_SetString(PyExc_IOError, exn.what()); - } catch (const std::out_of_range& exn) { - PyErr_SetString(PyExc_IndexError, exn.what()); - } catch (const std::overflow_error& exn) { - PyErr_SetString(PyExc_OverflowError, exn.what()); - } catch (const std::range_error& exn) { - PyErr_SetString(PyExc_ArithmeticError, exn.what()); - } catch (const std::underflow_error& exn) { - PyErr_SetString(PyExc_ArithmeticError, exn.what()); - } catch (const std::exception& exn) { - PyErr_SetString(PyExc_RuntimeError, exn.what()); - } - catch (...) - { - PyErr_SetString(PyExc_RuntimeError, "Unknown exception"); - } -} -#endif - -/* None.proto */ -#include - -#if PY_MAJOR_VERSION < 3 - static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); - static void __Pyx_ReleaseBuffer(Py_buffer *view); -#else - #define __Pyx_GetBuffer PyObject_GetBuffer - #define __Pyx_ReleaseBuffer PyBuffer_Release -#endif - - -/* BufferStructDeclare.proto */ -typedef struct { - Py_ssize_t shape, strides, suboffsets; -} __Pyx_Buf_DimInfo; -typedef struct { - size_t refcount; - Py_buffer pybuffer; -} __Pyx_Buffer; -typedef struct { - __Pyx_Buffer *rcbuffer; - char *data; - __Pyx_Buf_DimInfo diminfo[8]; -} __Pyx_LocalBuf_ND; - -/* MemviewSliceIsContig.proto */ -static int __pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim); - -/* OverlappingSlices.proto */ -static int __pyx_slices_overlap(__Pyx_memviewslice *slice1, - __Pyx_memviewslice *slice2, - int ndim, size_t itemsize); - -/* Capsule.proto */ -static CYTHON_INLINE PyObject *__pyx_capsule_create(void *p, const char *sig); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *); - -/* MemviewSliceCopyTemplate.proto */ -static __Pyx_memviewslice -__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, - const char *mode, int ndim, - size_t sizeof_dtype, int contig_flag, - int dtype_is_object); - -/* MemviewSliceInit.proto */ -#define __Pyx_BUF_MAX_NDIMS %(BUF_MAX_NDIMS)d -#define __Pyx_MEMVIEW_DIRECT 1 -#define __Pyx_MEMVIEW_PTR 2 -#define __Pyx_MEMVIEW_FULL 4 -#define __Pyx_MEMVIEW_CONTIG 8 -#define __Pyx_MEMVIEW_STRIDED 16 -#define __Pyx_MEMVIEW_FOLLOW 32 -#define __Pyx_IS_C_CONTIG 1 -#define __Pyx_IS_F_CONTIG 2 -static int __Pyx_init_memviewslice( - struct __pyx_memoryview_obj *memview, - int ndim, - __Pyx_memviewslice *memviewslice, - int memview_is_new_reference); -static CYTHON_INLINE int __pyx_add_acquisition_count_locked( - __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); -static CYTHON_INLINE int __pyx_sub_acquisition_count_locked( - __pyx_atomic_int *acquisition_count, PyThread_type_lock lock); -#define __pyx_get_slice_count_pointer(memview) (memview->acquisition_count_aligned_p) -#define __pyx_get_slice_count(memview) (*__pyx_get_slice_count_pointer(memview)) -#define __PYX_INC_MEMVIEW(slice, have_gil) __Pyx_INC_MEMVIEW(slice, have_gil, __LINE__) -#define __PYX_XDEC_MEMVIEW(slice, have_gil) __Pyx_XDEC_MEMVIEW(slice, have_gil, __LINE__) -static CYTHON_INLINE void __Pyx_INC_MEMVIEW(__Pyx_memviewslice *, int, int); -static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *, int, int); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *); - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - -static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self); /* proto*/ -static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto*/ -static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj); /* proto*/ -static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src); /* proto*/ -static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value); /* proto*/ -static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto*/ -static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/ -static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/ -static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp); /* proto*/ -static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value); /* proto*/ - -/* Module declarations from 'libc.string' */ - -/* Module declarations from 'libcpp.string' */ - -/* Module declarations from 'libcpp.vector' */ - -/* Module declarations from 'libcpp' */ - -/* Module declarations from 'libcpp.memory' */ - -/* Module declarations from 'libcpp.utility' */ - -/* Module declarations from 'libc.stdint' */ - -/* Module declarations from 'cuda.ccudart' */ - -/* Module declarations from 'rmm._lib.cuda_stream_view' */ - -/* Module declarations from 'rmm._cuda.stream' */ -static PyTypeObject *__pyx_ptype_3rmm_5_cuda_6stream_Stream = 0; - -/* Module declarations from 'rmm._lib.memory_resource' */ -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor = 0; -static PyTypeObject *__pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor = 0; - -/* Module declarations from 'rmm._lib.device_buffer' */ -static PyTypeObject *__pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer = 0; - -/* Module declarations from 'cudf._lib.cpp.types' */ - -/* Module declarations from 'cudf._lib.cpp.column.column_view' */ - -/* Module declarations from 'cudf._lib.cpp.column.column' */ - -/* Module declarations from 'cudf._lib.column' */ -static PyTypeObject *__pyx_ptype_4cudf_4_lib_6column_Column = 0; - -/* Module declarations from 'strings_udf._lib.cpp.strings_udf' */ - -/* Module declarations from 'strings_udf._lib.cudf_jit_udf' */ -static PyTypeObject *__pyx_array_type = 0; -static PyTypeObject *__pyx_MemviewEnum_type = 0; -static PyTypeObject *__pyx_memoryview_type = 0; -static PyTypeObject *__pyx_memoryviewslice_type = 0; -static PyObject *generic = 0; -static PyObject *strided = 0; -static PyObject *indirect = 0; -static PyObject *contiguous = 0; -static PyObject *indirect_contiguous = 0; -static int __pyx_memoryview_thread_locks_used; -static PyThread_type_lock __pyx_memoryview_thread_locks[8]; -static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ -static struct __pyx_array_obj *__pyx_array_new(PyObject *, Py_ssize_t, char *, char *, char *); /*proto*/ -static void *__pyx_align_pointer(void *, size_t); /*proto*/ -static PyObject *__pyx_memoryview_new(PyObject *, int, int, __Pyx_TypeInfo *); /*proto*/ -static CYTHON_INLINE int __pyx_memoryview_check(PyObject *); /*proto*/ -static PyObject *_unellipsify(PyObject *, int); /*proto*/ -static PyObject *assert_direct_dimensions(Py_ssize_t *, int); /*proto*/ -static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *, PyObject *); /*proto*/ -static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int *, Py_ssize_t, Py_ssize_t, Py_ssize_t, int, int, int, int); /*proto*/ -static char *__pyx_pybuffer_index(Py_buffer *, char *, Py_ssize_t, Py_ssize_t); /*proto*/ -static int __pyx_memslice_transpose(__Pyx_memviewslice *); /*proto*/ -static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice, int, PyObject *(*)(char *), int (*)(char *, PyObject *), int); /*proto*/ -static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ -static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ -static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *); /*proto*/ -static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *, __Pyx_memviewslice *); /*proto*/ -static Py_ssize_t abs_py_ssize_t(Py_ssize_t); /*proto*/ -static char __pyx_get_best_slice_order(__Pyx_memviewslice *, int); /*proto*/ -static void _copy_strided_to_strided(char *, Py_ssize_t *, char *, Py_ssize_t *, Py_ssize_t *, Py_ssize_t *, int, size_t); /*proto*/ -static void copy_strided_to_strided(__Pyx_memviewslice *, __Pyx_memviewslice *, int, size_t); /*proto*/ -static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *, int); /*proto*/ -static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *, Py_ssize_t *, Py_ssize_t, int, char); /*proto*/ -static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *, __Pyx_memviewslice *, char, int); /*proto*/ -static int __pyx_memoryview_err_extents(int, Py_ssize_t, Py_ssize_t); /*proto*/ -static int __pyx_memoryview_err_dim(PyObject *, char *, int); /*proto*/ -static int __pyx_memoryview_err(PyObject *, char *); /*proto*/ -static int __pyx_memoryview_copy_contents(__Pyx_memviewslice, __Pyx_memviewslice, int, int, int); /*proto*/ -static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *, int, int); /*proto*/ -static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *, int, int, int); /*proto*/ -static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ -static void __pyx_memoryview_refcount_objects_in_slice(char *, Py_ssize_t *, Py_ssize_t *, int, int); /*proto*/ -static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *, int, size_t, void *, int); /*proto*/ -static void __pyx_memoryview__slice_assign_scalar(char *, Py_ssize_t *, Py_ssize_t *, int, size_t, void *); /*proto*/ -static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *, PyObject *); /*proto*/ -#define __Pyx_MODULE_NAME "strings_udf._lib.cudf_jit_udf" -extern int __pyx_module_is_main_strings_udf___lib__cudf_jit_udf; -int __pyx_module_is_main_strings_udf___lib__cudf_jit_udf = 0; - -/* Implementation of 'strings_udf._lib.cudf_jit_udf' */ -static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_builtin_MemoryError; -static PyObject *__pyx_builtin_enumerate; -static PyObject *__pyx_builtin_range; -static PyObject *__pyx_builtin_TypeError; -static PyObject *__pyx_builtin_Ellipsis; -static PyObject *__pyx_builtin_id; -static PyObject *__pyx_builtin_IndexError; -static const char __pyx_k_I[] = "-I"; -static const char __pyx_k_O[] = "O"; -static const char __pyx_k_c[] = "c"; -static const char __pyx_k_id[] = "id"; -static const char __pyx_k_np[] = "np"; -static const char __pyx_k_os[] = "os"; -static const char __pyx_k_col[] = "col"; -static const char __pyx_k_get[] = "get"; -static const char __pyx_k_new[] = "__new__"; -static const char __pyx_k_obj[] = "obj"; -static const char __pyx_k_udf[] = "udf"; -static const char __pyx_k_base[] = "base"; -static const char __pyx_k_cols[] = "cols"; -static const char __pyx_k_data[] = "data"; -static const char __pyx_k_dict[] = "__dict__"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_mode[] = "mode"; -static const char __pyx_k_name[] = "name"; -static const char __pyx_k_ndim[] = "ndim"; -static const char __pyx_k_pack[] = "pack"; -static const char __pyx_k_size[] = "size"; -static const char __pyx_k_step[] = "step"; -static const char __pyx_k_stop[] = "stop"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_ASCII[] = "ASCII"; -static const char __pyx_k_UTF_8[] = "UTF-8"; -static const char __pyx_k_c_udf[] = "c_udf"; -static const char __pyx_k_class[] = "__class__"; -static const char __pyx_k_error[] = "error"; -static const char __pyx_k_flags[] = "flags"; -static const char __pyx_k_int64[] = "int64"; -static const char __pyx_k_numpy[] = "numpy"; -static const char __pyx_k_range[] = "range"; -static const char __pyx_k_shape[] = "shape"; -static const char __pyx_k_start[] = "start"; -static const char __pyx_k_Buffer[] = "Buffer"; -static const char __pyx_k_buffer[] = "buffer"; -static const char __pyx_k_c_name[] = "c_name"; -static const char __pyx_k_c_size[] = "c_size"; -static const char __pyx_k_column[] = "_column"; -static const char __pyx_k_encode[] = "encode"; -static const char __pyx_k_format[] = "format"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_name_2[] = "__name__"; -static const char __pyx_k_pickle[] = "pickle"; -static const char __pyx_k_reduce[] = "__reduce__"; -static const char __pyx_k_struct[] = "struct"; -static const char __pyx_k_unpack[] = "unpack"; -static const char __pyx_k_update[] = "update"; -static const char __pyx_k_environ[] = "environ"; -static const char __pyx_k_fortran[] = "fortran"; -static const char __pyx_k_include[] = "/include"; -static const char __pyx_k_memview[] = "memview"; -static const char __pyx_k_tbl_ptr[] = "tbl_ptr"; -static const char __pyx_k_Ellipsis[] = "Ellipsis"; -static const char __pyx_k_c_buffer[] = "c_buffer"; -static const char __pyx_k_c_module[] = "c_module"; -static const char __pyx_k_c_result[] = "c_result"; -static const char __pyx_k_d_buffer[] = "d_buffer"; -static const char __pyx_k_getstate[] = "__getstate__"; -static const char __pyx_k_itemsize[] = "itemsize"; -static const char __pyx_k_pyx_type[] = "__pyx_type"; -static const char __pyx_k_setstate[] = "__setstate__"; -static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_c_columns[] = "c_columns"; -static const char __pyx_k_c_options[] = "c_options"; -static const char __pyx_k_enumerate[] = "enumerate"; -static const char __pyx_k_pyx_state[] = "__pyx_state"; -static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; -static const char __pyx_k_IndexError[] = "IndexError"; -static const char __pyx_k_ValueError[] = "ValueError"; -static const char __pyx_k_pyx_result[] = "__pyx_result"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; -static const char __pyx_k_MemoryError[] = "MemoryError"; -static const char __pyx_k_PickleError[] = "PickleError"; -static const char __pyx_k_process_udf[] = "process_udf"; -static const char __pyx_k_strings_col[] = "strings_col"; -static const char __pyx_k_CONDA_PREFIX[] = "CONDA_PREFIX"; -static const char __pyx_k_include_path[] = "include_path"; -static const char __pyx_k_pyx_checksum[] = "__pyx_checksum"; -static const char __pyx_k_stringsource[] = "stringsource"; -static const char __pyx_k_pyx_getbuffer[] = "__pyx_getbuffer"; -static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; -static const char __pyx_k_View_MemoryView[] = "View.MemoryView"; -static const char __pyx_k_allocate_buffer[] = "allocate_buffer"; -static const char __pyx_k_dtype_is_object[] = "dtype_is_object"; -static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError"; -static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; -static const char __pyx_k_cudf_core_buffer[] = "cudf.core.buffer"; -static const char __pyx_k_pyx_unpickle_Enum[] = "__pyx_unpickle_Enum"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_from_dstring_array[] = "from_dstring_array"; -static const char __pyx_k_strided_and_direct[] = ""; -static const char __pyx_k_strided_and_indirect[] = ""; -static const char __pyx_k_to_string_view_array[] = "to_string_view_array"; -static const char __pyx_k_contiguous_and_direct[] = ""; -static const char __pyx_k_MemoryView_of_r_object[] = ""; -static const char __pyx_k_MemoryView_of_r_at_0x_x[] = ""; -static const char __pyx_k_contiguous_and_indirect[] = ""; -static const char __pyx_k_Cannot_index_with_type_s[] = "Cannot index with type '%s'"; -static const char __pyx_k_Invalid_shape_in_axis_d_d[] = "Invalid shape in axis %d: %d."; -static const char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; -static const char __pyx_k_get_character_flags_table_ptr[] = "get_character_flags_table_ptr"; -static const char __pyx_k_strings_udf__lib_cudf_jit_udf[] = "strings_udf._lib.cudf_jit_udf"; -static const char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; -static const char __pyx_k_strided_and_direct_or_indirect[] = ""; -static const char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; -static const char __pyx_k_Can_only_create_a_buffer_that_is[] = "Can only create a buffer that is contiguous in memory."; -static const char __pyx_k_Cannot_assign_to_read_only_memor[] = "Cannot assign to read-only memoryview"; -static const char __pyx_k_Cannot_create_writable_memory_vi[] = "Cannot create writable memory view from read-only memoryview"; -static const char __pyx_k_Empty_shape_tuple_for_cython_arr[] = "Empty shape tuple for cython.array"; -static const char __pyx_k_Incompatible_checksums_0x_x_vs_0[] = "Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))"; -static const char __pyx_k_Indirect_dimensions_not_supporte[] = "Indirect dimensions not supported"; -static const char __pyx_k_Invalid_mode_expected_c_or_fortr[] = "Invalid mode, expected 'c' or 'fortran', got %s"; -static const char __pyx_k_Out_of_bounds_on_buffer_access_a[] = "Out of bounds on buffer access (axis %d)"; -static const char __pyx_k_Unable_to_convert_item_to_object[] = "Unable to convert item to object"; -static const char __pyx_k_got_differing_extents_in_dimensi[] = "got differing extents in dimension %d (got %d and %d)"; -static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; -static const char __pyx_k_strings_udf__lib_cudf_jit_udf_py[] = "strings_udf/_lib/cudf_jit_udf.pyx"; -static const char __pyx_k_unable_to_allocate_shape_and_str[] = "unable to allocate shape and strides."; -static PyObject *__pyx_n_s_ASCII; -static PyObject *__pyx_n_s_Buffer; -static PyObject *__pyx_kp_s_Buffer_view_does_not_expose_stri; -static PyObject *__pyx_n_u_CONDA_PREFIX; -static PyObject *__pyx_kp_s_Can_only_create_a_buffer_that_is; -static PyObject *__pyx_kp_s_Cannot_assign_to_read_only_memor; -static PyObject *__pyx_kp_s_Cannot_create_writable_memory_vi; -static PyObject *__pyx_kp_s_Cannot_index_with_type_s; -static PyObject *__pyx_n_s_Ellipsis; -static PyObject *__pyx_kp_s_Empty_shape_tuple_for_cython_arr; -static PyObject *__pyx_kp_u_I; -static PyObject *__pyx_kp_s_Incompatible_checksums_0x_x_vs_0; -static PyObject *__pyx_n_s_IndexError; -static PyObject *__pyx_kp_s_Indirect_dimensions_not_supporte; -static PyObject *__pyx_kp_s_Invalid_mode_expected_c_or_fortr; -static PyObject *__pyx_kp_s_Invalid_shape_in_axis_d_d; -static PyObject *__pyx_n_s_MemoryError; -static PyObject *__pyx_kp_s_MemoryView_of_r_at_0x_x; -static PyObject *__pyx_kp_s_MemoryView_of_r_object; -static PyObject *__pyx_n_b_O; -static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a; -static PyObject *__pyx_n_s_PickleError; -static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_kp_u_UTF_8; -static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; -static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_n_s_View_MemoryView; -static PyObject *__pyx_n_s_allocate_buffer; -static PyObject *__pyx_n_s_base; -static PyObject *__pyx_n_s_buffer; -static PyObject *__pyx_n_s_c; -static PyObject *__pyx_n_u_c; -static PyObject *__pyx_n_s_c_buffer; -static PyObject *__pyx_n_s_c_columns; -static PyObject *__pyx_n_s_c_module; -static PyObject *__pyx_n_s_c_name; -static PyObject *__pyx_n_s_c_options; -static PyObject *__pyx_n_s_c_result; -static PyObject *__pyx_n_s_c_size; -static PyObject *__pyx_n_s_c_udf; -static PyObject *__pyx_n_s_class; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_col; -static PyObject *__pyx_n_s_cols; -static PyObject *__pyx_n_s_column; -static PyObject *__pyx_kp_s_contiguous_and_direct; -static PyObject *__pyx_kp_s_contiguous_and_indirect; -static PyObject *__pyx_n_s_cudf_core_buffer; -static PyObject *__pyx_n_s_d_buffer; -static PyObject *__pyx_n_s_data; -static PyObject *__pyx_n_s_dict; -static PyObject *__pyx_n_s_dtype_is_object; -static PyObject *__pyx_n_s_encode; -static PyObject *__pyx_n_s_enumerate; -static PyObject *__pyx_n_s_environ; -static PyObject *__pyx_n_s_error; -static PyObject *__pyx_n_s_flags; -static PyObject *__pyx_n_s_format; -static PyObject *__pyx_n_s_fortran; -static PyObject *__pyx_n_u_fortran; -static PyObject *__pyx_n_s_from_dstring_array; -static PyObject *__pyx_n_s_get; -static PyObject *__pyx_n_s_get_character_flags_table_ptr; -static PyObject *__pyx_n_s_getstate; -static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; -static PyObject *__pyx_n_s_id; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_kp_u_include; -static PyObject *__pyx_n_s_include_path; -static PyObject *__pyx_n_s_int64; -static PyObject *__pyx_n_s_itemsize; -static PyObject *__pyx_kp_s_itemsize_0_for_cython_array; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_memview; -static PyObject *__pyx_n_s_mode; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_name_2; -static PyObject *__pyx_n_s_ndim; -static PyObject *__pyx_n_s_new; -static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_np; -static PyObject *__pyx_n_s_numpy; -static PyObject *__pyx_n_s_obj; -static PyObject *__pyx_n_s_os; -static PyObject *__pyx_n_s_pack; -static PyObject *__pyx_n_s_pickle; -static PyObject *__pyx_n_s_process_udf; -static PyObject *__pyx_n_s_pyx_PickleError; -static PyObject *__pyx_n_s_pyx_checksum; -static PyObject *__pyx_n_s_pyx_getbuffer; -static PyObject *__pyx_n_s_pyx_result; -static PyObject *__pyx_n_s_pyx_state; -static PyObject *__pyx_n_s_pyx_type; -static PyObject *__pyx_n_s_pyx_unpickle_Enum; -static PyObject *__pyx_n_s_pyx_vtable; -static PyObject *__pyx_n_s_range; -static PyObject *__pyx_n_s_reduce; -static PyObject *__pyx_n_s_reduce_cython; -static PyObject *__pyx_n_s_reduce_ex; -static PyObject *__pyx_n_s_setstate; -static PyObject *__pyx_n_s_setstate_cython; -static PyObject *__pyx_n_s_shape; -static PyObject *__pyx_n_s_size; -static PyObject *__pyx_n_s_start; -static PyObject *__pyx_n_s_step; -static PyObject *__pyx_n_s_stop; -static PyObject *__pyx_kp_s_strided_and_direct; -static PyObject *__pyx_kp_s_strided_and_direct_or_indirect; -static PyObject *__pyx_kp_s_strided_and_indirect; -static PyObject *__pyx_n_s_strings_col; -static PyObject *__pyx_n_s_strings_udf__lib_cudf_jit_udf; -static PyObject *__pyx_kp_s_strings_udf__lib_cudf_jit_udf_py; -static PyObject *__pyx_kp_s_stringsource; -static PyObject *__pyx_n_s_struct; -static PyObject *__pyx_n_s_tbl_ptr; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_to_string_view_array; -static PyObject *__pyx_n_s_udf; -static PyObject *__pyx_kp_s_unable_to_allocate_array_data; -static PyObject *__pyx_kp_s_unable_to_allocate_shape_and_str; -static PyObject *__pyx_n_s_unpack; -static PyObject *__pyx_n_s_update; -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_process_udf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_udf, PyObject *__pyx_v_name, PyObject *__pyx_v_cols); /* proto */ -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cudf_4_lib_6column_Column *__pyx_v_strings_col); /* proto */ -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_v_d_buffer); /* proto */ -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */ -static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */ -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */ -static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ -static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */ -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */ -static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */ -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_int_0; -static PyObject *__pyx_int_1; -static PyObject *__pyx_int_112105877; -static PyObject *__pyx_int_136983863; -static PyObject *__pyx_int_184977713; -static PyObject *__pyx_int_neg_1; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__5; -static PyObject *__pyx_tuple__6; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__9; -static PyObject *__pyx_slice__15; -static PyObject *__pyx_tuple__10; -static PyObject *__pyx_tuple__11; -static PyObject *__pyx_tuple__12; -static PyObject *__pyx_tuple__13; -static PyObject *__pyx_tuple__14; -static PyObject *__pyx_tuple__16; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__18; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_tuple__20; -static PyObject *__pyx_tuple__22; -static PyObject *__pyx_tuple__24; -static PyObject *__pyx_tuple__26; -static PyObject *__pyx_tuple__28; -static PyObject *__pyx_tuple__29; -static PyObject *__pyx_tuple__30; -static PyObject *__pyx_tuple__31; -static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__33; -static PyObject *__pyx_codeobj__21; -static PyObject *__pyx_codeobj__23; -static PyObject *__pyx_codeobj__25; -static PyObject *__pyx_codeobj__27; -static PyObject *__pyx_codeobj__34; -/* Late includes */ - -/* "strings_udf/_lib/cudf_jit_udf.pyx":35 - * import numpy as np - * - * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< - * cdef string c_udf - * cdef string c_name - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_1process_udf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_process_udf[] = "process_udf(udf, name, cols)"; -static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_1process_udf = {"process_udf", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_1process_udf, METH_VARARGS|METH_KEYWORDS, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_process_udf}; -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_1process_udf(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_udf = 0; - PyObject *__pyx_v_name = 0; - PyObject *__pyx_v_cols = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("process_udf (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_udf,&__pyx_n_s_name,&__pyx_n_s_cols,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_udf)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process_udf", 1, 3, 3, 1); __PYX_ERR(0, 35, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cols)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("process_udf", 1, 3, 3, 2); __PYX_ERR(0, 35, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "process_udf") < 0)) __PYX_ERR(0, 35, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_udf = values[0]; - __pyx_v_name = values[1]; - __pyx_v_cols = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("process_udf", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 35, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.process_udf", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_process_udf(__pyx_self, __pyx_v_udf, __pyx_v_name, __pyx_v_cols); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_process_udf(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_udf, PyObject *__pyx_v_name, PyObject *__pyx_v_cols) { - std::string __pyx_v_c_udf; - std::string __pyx_v_c_name; - cudf::size_type __pyx_v_c_size; - std::vector __pyx_v_c_columns; - std::unique_ptr __pyx_v_c_module; - std::vector __pyx_v_c_options; - std::unique_ptr __pyx_v_c_result; - struct __pyx_obj_4cudf_4_lib_6column_Column *__pyx_v_col = 0; - PyObject *__pyx_v_c = NULL; - PyObject *__pyx_v_include_path = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - std::string __pyx_t_4; - cudf::size_type __pyx_t_5; - Py_ssize_t __pyx_t_6; - PyObject *(*__pyx_t_7)(PyObject *); - cudf::column_view __pyx_t_8; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("process_udf", 0); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":46 - * cdef unique_ptr[column] c_result - * - * c_udf = udf.encode('UTF-8') # <<<<<<<<<<<<<< - * c_name = name.encode('UTF-8') - * - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_udf, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_UTF_8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_UTF_8); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 46, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_c_udf = __pyx_t_4; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":47 - * - * c_udf = udf.encode('UTF-8') - * c_name = name.encode('UTF-8') # <<<<<<<<<<<<<< - * - * cdef Column col = cols[0]._column - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_kp_u_UTF_8) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u_UTF_8); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_c_name = __pyx_t_4; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":49 - * c_name = name.encode('UTF-8') - * - * cdef Column col = cols[0]._column # <<<<<<<<<<<<<< - * c_size = col.size - * for c in cols: - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cols, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_column); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_4cudf_4_lib_6column_Column))))) __PYX_ERR(0, 49, __pyx_L1_error) - __pyx_v_col = ((struct __pyx_obj_4cudf_4_lib_6column_Column *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":50 - * - * cdef Column col = cols[0]._column - * c_size = col.size # <<<<<<<<<<<<<< - * for c in cols: - * col = c._column - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_col), __pyx_n_s_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = __Pyx_PyInt_As_int32_t(__pyx_t_2); if (unlikely((__pyx_t_5 == ((cudf::size_type)-1)) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_c_size = __pyx_t_5; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":51 - * cdef Column col = cols[0]._column - * c_size = col.size - * for c in cols: # <<<<<<<<<<<<<< - * col = c._column - * c_columns.push_back(col.view()) - */ - if (likely(PyList_CheckExact(__pyx_v_cols)) || PyTuple_CheckExact(__pyx_v_cols)) { - __pyx_t_2 = __pyx_v_cols; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; - __pyx_t_7 = NULL; - } else { - __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_cols); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 51, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_7)) { - if (likely(PyList_CheckExact(__pyx_t_2))) { - if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 51, __pyx_L1_error) - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - #endif - } else { - if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) __PYX_ERR(0, 51, __pyx_L1_error) - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - #endif - } - } else { - __pyx_t_1 = __pyx_t_7(__pyx_t_2); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 51, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_1); - __pyx_t_1 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":52 - * c_size = col.size - * for c in cols: - * col = c._column # <<<<<<<<<<<<<< - * c_columns.push_back(col.view()) - * - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_column); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_4cudf_4_lib_6column_Column))))) __PYX_ERR(0, 52, __pyx_L1_error) - __Pyx_DECREF_SET(__pyx_v_col, ((struct __pyx_obj_4cudf_4_lib_6column_Column *)__pyx_t_1)); - __pyx_t_1 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":53 - * for c in cols: - * col = c._column - * c_columns.push_back(col.view()) # <<<<<<<<<<<<<< - * - * include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" - */ - __pyx_t_8 = ((struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *)__pyx_v_col->__pyx_vtab)->view(__pyx_v_col); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 53, __pyx_L1_error) - try { - __pyx_v_c_columns.push_back(__pyx_t_8); - } catch(...) { - __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 53, __pyx_L1_error) - } - - /* "strings_udf/_lib/cudf_jit_udf.pyx":51 - * cdef Column col = cols[0]._column - * c_size = col.size - * for c in cols: # <<<<<<<<<<<<<< - * col = c._column - * c_columns.push_back(col.view()) - */ - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":55 - * c_columns.push_back(col.view()) - * - * include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" # <<<<<<<<<<<<<< - * c_options.push_back(str(include_path).encode('UTF-8')) - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_environ); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_n_u_CONDA_PREFIX) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_n_u_CONDA_PREFIX); - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(__pyx_kp_u_I, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_kp_u_include); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_include_path = __pyx_t_2; - __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":56 - * - * include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" - * c_options.push_back(str(include_path).encode('UTF-8')) # <<<<<<<<<<<<<< - * - * #with nogil: - */ - __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_include_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyUnicode_AsUTF8String(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 56, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - try { - __pyx_v_c_options.push_back(__pyx_t_4); - } catch(...) { - __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 56, __pyx_L1_error) - } - - /* "strings_udf/_lib/cudf_jit_udf.pyx":59 - * - * #with nogil: - * c_module = move(cpp_create_udf_module(c_udf, c_options)) # <<<<<<<<<<<<<< - * # c_module will be nullptr if there is a compile error - * - */ - __pyx_v_c_module = cython_std::move >(create_udf_module(__pyx_v_c_udf, __pyx_v_c_options)); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":63 - * - * #with nogil: - * c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) # <<<<<<<<<<<<<< - * - * return Column.from_unique_ptr(move(c_result)) - */ - __pyx_v_c_result = cython_std::move >(call_udf((__pyx_v_c_module.get()[0]), __pyx_v_c_name, __pyx_v_c_size, __pyx_v_c_columns)); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":65 - * c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) - * - * return Column.from_unique_ptr(move(c_result)) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((PyObject *)__pyx_vtabptr_4cudf_4_lib_6column_Column->from_unique_ptr(cython_std::move >(__pyx_v_c_result))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":35 - * import numpy as np - * - * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< - * cdef string c_udf - * cdef string c_name - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.process_udf", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_col); - __Pyx_XDECREF(__pyx_v_c); - __Pyx_XDECREF(__pyx_v_include_path); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "strings_udf/_lib/cudf_jit_udf.pyx":68 - * - * - * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< - * cdef unique_ptr[device_buffer] c_buffer - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array(PyObject *__pyx_self, PyObject *__pyx_v_strings_col); /*proto*/ -static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array[] = "to_string_view_array(Column strings_col)"; -static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array = {"to_string_view_array", (PyCFunction)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array, METH_O, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array}; -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array(PyObject *__pyx_self, PyObject *__pyx_v_strings_col) { - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("to_string_view_array (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_strings_col), __pyx_ptype_4cudf_4_lib_6column_Column, 1, "strings_col", 0))) __PYX_ERR(0, 68, __pyx_L1_error) - __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array(__pyx_self, ((struct __pyx_obj_4cudf_4_lib_6column_Column *)__pyx_v_strings_col)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_2to_string_view_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_4cudf_4_lib_6column_Column *__pyx_v_strings_col) { - std::unique_ptr __pyx_v_c_buffer; - PyObject *__pyx_v_buffer = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - cudf::column_view __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("to_string_view_array", 0); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":72 - * - * #with nogil: - * c_buffer = move(cpp_to_string_view_array(strings_col.view())) # <<<<<<<<<<<<<< - * - * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_4cudf_4_lib_6column_Column *)__pyx_v_strings_col->__pyx_vtab)->view(__pyx_v_strings_col); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 72, __pyx_L1_error) - __pyx_v_c_buffer = cython_std::move >(to_string_view_array(__pyx_t_1)); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":74 - * c_buffer = move(cpp_to_string_view_array(strings_col.view())) - * - * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) # <<<<<<<<<<<<<< - * buffer = Buffer(buffer) - * return buffer - */ - __pyx_t_2 = ((PyObject *)__pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer->c_from_unique_ptr(cython_std::move >(__pyx_v_c_buffer))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_buffer = __pyx_t_2; - __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":75 - * - * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) - * buffer = Buffer(buffer) # <<<<<<<<<<<<<< - * return buffer - * - */ - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_buffer) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_buffer); - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF_SET(__pyx_v_buffer, __pyx_t_2); - __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":76 - * buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) - * buffer = Buffer(buffer) - * return buffer # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_buffer); - __pyx_r = __pyx_v_buffer; - goto __pyx_L0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":68 - * - * - * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< - * cdef unique_ptr[device_buffer] c_buffer - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.to_string_view_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_buffer); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "strings_udf/_lib/cudf_jit_udf.pyx":79 - * - * - * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< - * cdef size_t size = d_buffer.c_size() - * cdef void* data = d_buffer.c_data() - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array(PyObject *__pyx_self, PyObject *__pyx_v_d_buffer); /*proto*/ -static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array[] = "from_dstring_array(DeviceBuffer d_buffer)"; -static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array = {"from_dstring_array", (PyCFunction)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array, METH_O, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array}; -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array(PyObject *__pyx_self, PyObject *__pyx_v_d_buffer) { - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("from_dstring_array (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_d_buffer), __pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer, 1, "d_buffer", 0))) __PYX_ERR(0, 79, __pyx_L1_error) - __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array(__pyx_self, ((struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *)__pyx_v_d_buffer)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_4from_dstring_array(CYTHON_UNUSED PyObject *__pyx_self, struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer *__pyx_v_d_buffer) { - size_t __pyx_v_size; - void *__pyx_v_data; - std::unique_ptr __pyx_v_c_result; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - size_t __pyx_t_1; - void *__pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("from_dstring_array", 0); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":80 - * - * def from_dstring_array(DeviceBuffer d_buffer): - * cdef size_t size = d_buffer.c_size() # <<<<<<<<<<<<<< - * cdef void* data = d_buffer.c_data() - * cdef unique_ptr[column] c_result - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *)__pyx_v_d_buffer->__pyx_vtab)->c_size(__pyx_v_d_buffer); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 80, __pyx_L1_error) - __pyx_v_size = __pyx_t_1; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":81 - * def from_dstring_array(DeviceBuffer d_buffer): - * cdef size_t size = d_buffer.c_size() - * cdef void* data = d_buffer.c_data() # <<<<<<<<<<<<<< - * cdef unique_ptr[column] c_result - * # data = - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer *)__pyx_v_d_buffer->__pyx_vtab)->c_data(__pyx_v_d_buffer); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 81, __pyx_L1_error) - __pyx_v_data = __pyx_t_2; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":86 - * - * #with nogil: - * c_result = move(cpp_from_dstring_array(data, size)) # <<<<<<<<<<<<<< - * - * return Column.from_unique_ptr(move(c_result)) - */ - __pyx_v_c_result = cython_std::move >(from_dstring_array(__pyx_v_data, __pyx_v_size)); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":88 - * c_result = move(cpp_from_dstring_array(data, size)) - * - * return Column.from_unique_ptr(move(c_result)) # <<<<<<<<<<<<<< - * - * def get_character_flags_table_ptr(): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = ((PyObject *)__pyx_vtabptr_4cudf_4_lib_6column_Column->from_unique_ptr(cython_std::move >(__pyx_v_c_result))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":79 - * - * - * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< - * cdef size_t size = d_buffer.c_size() - * cdef void* data = d_buffer.c_data() - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.from_dstring_array", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "strings_udf/_lib/cudf_jit_udf.pyx":90 - * return Column.from_unique_ptr(move(c_result)) - * - * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< - * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() - * return np.int64(tbl_ptr) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr[] = "get_character_flags_table_ptr()"; -static PyMethodDef __pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr = {"get_character_flags_table_ptr", (PyCFunction)__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr, METH_NOARGS, __pyx_doc_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr}; -static PyObject *__pyx_pw_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_character_flags_table_ptr (wrapper)", 0); - __pyx_r = __pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr(__pyx_self); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_11strings_udf_4_lib_12cudf_jit_udf_6get_character_flags_table_ptr(CYTHON_UNUSED PyObject *__pyx_self) { - uint8_t const *__pyx_v_tbl_ptr; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - uint8_t const *__pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_character_flags_table_ptr", 0); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":91 - * - * def get_character_flags_table_ptr(): - * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() # <<<<<<<<<<<<<< - * return np.int64(tbl_ptr) - */ - try { - __pyx_t_1 = cudf::strings::detail::get_character_flags_table(); - } catch(...) { - __Pyx_CppExn2PyErr(); - __PYX_ERR(0, 91, __pyx_L1_error) - } - __pyx_v_tbl_ptr = __pyx_t_1; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":92 - * def get_character_flags_table_ptr(): - * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() - * return np.int64(tbl_ptr) # <<<<<<<<<<<<<< - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_int64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyInt_FromSize_t(((uintptr_t)__pyx_v_tbl_ptr)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":90 - * return Column.from_unique_ptr(move(c_result)) - * - * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< - * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() - * return np.int64(tbl_ptr) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("strings_udf._lib.cudf_jit_udf.get_character_flags_table_ptr", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "string.from_py":13 - * - * @cname("__pyx_convert_string_from_py_std__in_string") - * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< - * cdef Py_ssize_t length = 0 - * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) - */ - -static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) { - Py_ssize_t __pyx_v_length; - char const *__pyx_v_data; - std::string __pyx_r; - __Pyx_RefNannyDeclarations - char const *__pyx_t_1; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0); - - /* "string.from_py":14 - * @cname("__pyx_convert_string_from_py_std__in_string") - * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: - * cdef Py_ssize_t length = 0 # <<<<<<<<<<<<<< - * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) - * return string(data, length) - */ - __pyx_v_length = 0; - - /* "string.from_py":15 - * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: - * cdef Py_ssize_t length = 0 - * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) # <<<<<<<<<<<<<< - * return string(data, length) - * - */ - __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(1, 15, __pyx_L1_error) - __pyx_v_data = __pyx_t_1; - - /* "string.from_py":16 - * cdef Py_ssize_t length = 0 - * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) - * return string(data, length) # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = std::string(__pyx_v_data, __pyx_v_length); - goto __pyx_L0; - - /* "string.from_py":13 - * - * @cname("__pyx_convert_string_from_py_std__in_string") - * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< - * cdef Py_ssize_t length = 0 - * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_pretend_to_initialize(&__pyx_r); - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":122 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * - */ - -/* Python wrapper */ -static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_shape = 0; - Py_ssize_t __pyx_v_itemsize; - PyObject *__pyx_v_format = 0; - PyObject *__pyx_v_mode = 0; - int __pyx_v_allocate_buffer; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_shape,&__pyx_n_s_itemsize,&__pyx_n_s_format,&__pyx_n_s_mode,&__pyx_n_s_allocate_buffer,0}; - PyObject* values[5] = {0,0,0,0,0}; - values[3] = ((PyObject *)__pyx_n_s_c); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_shape)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_itemsize)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 1); __PYX_ERR(1, 122, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_format)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, 2); __PYX_ERR(1, 122, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 3: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mode); - if (value) { values[3] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 4: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allocate_buffer); - if (value) { values[4] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 122, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - CYTHON_FALLTHROUGH; - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - CYTHON_FALLTHROUGH; - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_shape = ((PyObject*)values[0]); - __pyx_v_itemsize = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_itemsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 122, __pyx_L3_error) - __pyx_v_format = values[2]; - __pyx_v_mode = values[3]; - if (values[4]) { - __pyx_v_allocate_buffer = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_allocate_buffer == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 123, __pyx_L3_error) - } else { - - /* "View.MemoryView":123 - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, - * mode="c", bint allocate_buffer=True): # <<<<<<<<<<<<<< - * - * cdef int idx - */ - __pyx_v_allocate_buffer = ((int)1); - } - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 122, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_shape), (&PyTuple_Type), 1, "shape", 1))) __PYX_ERR(1, 122, __pyx_L1_error) - if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); __PYX_ERR(1, 122, __pyx_L1_error) - } - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); - - /* "View.MemoryView":122 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * - */ - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { - int __pyx_v_idx; - Py_ssize_t __pyx_v_i; - Py_ssize_t __pyx_v_dim; - PyObject **__pyx_v_p; - char __pyx_v_order; - int __pyx_r; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - char *__pyx_t_7; - int __pyx_t_8; - Py_ssize_t __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - Py_ssize_t __pyx_t_11; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - __Pyx_INCREF(__pyx_v_format); - - /* "View.MemoryView":129 - * cdef PyObject **p - * - * self.ndim = len(shape) # <<<<<<<<<<<<<< - * self.itemsize = itemsize - * - */ - if (unlikely(__pyx_v_shape == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(1, 129, __pyx_L1_error) - } - __pyx_t_1 = PyTuple_GET_SIZE(__pyx_v_shape); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(1, 129, __pyx_L1_error) - __pyx_v_self->ndim = ((int)__pyx_t_1); - - /* "View.MemoryView":130 - * - * self.ndim = len(shape) - * self.itemsize = itemsize # <<<<<<<<<<<<<< - * - * if not self.ndim: - */ - __pyx_v_self->itemsize = __pyx_v_itemsize; - - /* "View.MemoryView":132 - * self.itemsize = itemsize - * - * if not self.ndim: # <<<<<<<<<<<<<< - * raise ValueError("Empty shape tuple for cython.array") - * - */ - __pyx_t_2 = ((!(__pyx_v_self->ndim != 0)) != 0); - if (unlikely(__pyx_t_2)) { - - /* "View.MemoryView":133 - * - * if not self.ndim: - * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< - * - * if itemsize <= 0: - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 133, __pyx_L1_error) - - /* "View.MemoryView":132 - * self.itemsize = itemsize - * - * if not self.ndim: # <<<<<<<<<<<<<< - * raise ValueError("Empty shape tuple for cython.array") - * - */ - } - - /* "View.MemoryView":135 - * raise ValueError("Empty shape tuple for cython.array") - * - * if itemsize <= 0: # <<<<<<<<<<<<<< - * raise ValueError("itemsize <= 0 for cython.array") - * - */ - __pyx_t_2 = ((__pyx_v_itemsize <= 0) != 0); - if (unlikely(__pyx_t_2)) { - - /* "View.MemoryView":136 - * - * if itemsize <= 0: - * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< - * - * if not isinstance(format, bytes): - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 136, __pyx_L1_error) - - /* "View.MemoryView":135 - * raise ValueError("Empty shape tuple for cython.array") - * - * if itemsize <= 0: # <<<<<<<<<<<<<< - * raise ValueError("itemsize <= 0 for cython.array") - * - */ - } - - /* "View.MemoryView":138 - * raise ValueError("itemsize <= 0 for cython.array") - * - * if not isinstance(format, bytes): # <<<<<<<<<<<<<< - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string - */ - __pyx_t_2 = PyBytes_Check(__pyx_v_format); - __pyx_t_4 = ((!(__pyx_t_2 != 0)) != 0); - if (__pyx_t_4) { - - /* "View.MemoryView":139 - * - * if not isinstance(format, bytes): - * format = format.encode('ASCII') # <<<<<<<<<<<<<< - * self._format = format # keep a reference to the byte string - * self.format = self._format - */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_format, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ASCII) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ASCII); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF_SET(__pyx_v_format, __pyx_t_3); - __pyx_t_3 = 0; - - /* "View.MemoryView":138 - * raise ValueError("itemsize <= 0 for cython.array") - * - * if not isinstance(format, bytes): # <<<<<<<<<<<<<< - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string - */ - } - - /* "View.MemoryView":140 - * if not isinstance(format, bytes): - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string # <<<<<<<<<<<<<< - * self.format = self._format - * - */ - if (!(likely(PyBytes_CheckExact(__pyx_v_format))||((__pyx_v_format) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_format)->tp_name), 0))) __PYX_ERR(1, 140, __pyx_L1_error) - __pyx_t_3 = __pyx_v_format; - __Pyx_INCREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(__pyx_v_self->_format); - __Pyx_DECREF(__pyx_v_self->_format); - __pyx_v_self->_format = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - - /* "View.MemoryView":141 - * format = format.encode('ASCII') - * self._format = format # keep a reference to the byte string - * self.format = self._format # <<<<<<<<<<<<<< - * - * - */ - if (unlikely(__pyx_v_self->_format == Py_None)) { - PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(1, 141, __pyx_L1_error) - } - __pyx_t_7 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->_format); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(1, 141, __pyx_L1_error) - __pyx_v_self->format = __pyx_t_7; - - /* "View.MemoryView":144 - * - * - * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) # <<<<<<<<<<<<<< - * self._strides = self._shape + self.ndim - * - */ - __pyx_v_self->_shape = ((Py_ssize_t *)PyObject_Malloc((((sizeof(Py_ssize_t)) * __pyx_v_self->ndim) * 2))); - - /* "View.MemoryView":145 - * - * self._shape = PyObject_Malloc(sizeof(Py_ssize_t)*self.ndim*2) - * self._strides = self._shape + self.ndim # <<<<<<<<<<<<<< - * - * if not self._shape: - */ - __pyx_v_self->_strides = (__pyx_v_self->_shape + __pyx_v_self->ndim); - - /* "View.MemoryView":147 - * self._strides = self._shape + self.ndim - * - * if not self._shape: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate shape and strides.") - * - */ - __pyx_t_4 = ((!(__pyx_v_self->_shape != 0)) != 0); - if (unlikely(__pyx_t_4)) { - - /* "View.MemoryView":148 - * - * if not self._shape: - * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 148, __pyx_L1_error) - - /* "View.MemoryView":147 - * self._strides = self._shape + self.ndim - * - * if not self._shape: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate shape and strides.") - * - */ - } - - /* "View.MemoryView":151 - * - * - * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - */ - __pyx_t_8 = 0; - __pyx_t_3 = __pyx_v_shape; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0; - for (;;) { - if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(1, 151, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 151, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_dim = __pyx_t_9; - __pyx_v_idx = __pyx_t_8; - __pyx_t_8 = (__pyx_t_8 + 1); - - /* "View.MemoryView":152 - * - * for idx, dim in enumerate(shape): - * if dim <= 0: # <<<<<<<<<<<<<< - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - * self._shape[idx] = dim - */ - __pyx_t_4 = ((__pyx_v_dim <= 0) != 0); - if (unlikely(__pyx_t_4)) { - - /* "View.MemoryView":153 - * for idx, dim in enumerate(shape): - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) # <<<<<<<<<<<<<< - * self._shape[idx] = dim - * - */ - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_idx); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); - __pyx_t_5 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_Raise(__pyx_t_10, 0, 0, 0); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __PYX_ERR(1, 153, __pyx_L1_error) - - /* "View.MemoryView":152 - * - * for idx, dim in enumerate(shape): - * if dim <= 0: # <<<<<<<<<<<<<< - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - * self._shape[idx] = dim - */ - } - - /* "View.MemoryView":154 - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - * self._shape[idx] = dim # <<<<<<<<<<<<<< - * - * cdef char order - */ - (__pyx_v_self->_shape[__pyx_v_idx]) = __pyx_v_dim; - - /* "View.MemoryView":151 - * - * - * for idx, dim in enumerate(shape): # <<<<<<<<<<<<<< - * if dim <= 0: - * raise ValueError("Invalid shape in axis %d: %d." % (idx, dim)) - */ - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":157 - * - * cdef char order - * if mode == 'fortran': # <<<<<<<<<<<<<< - * order = b'F' - * self.mode = u'fortran' - */ - __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_fortran, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 157, __pyx_L1_error) - if (__pyx_t_4) { - - /* "View.MemoryView":158 - * cdef char order - * if mode == 'fortran': - * order = b'F' # <<<<<<<<<<<<<< - * self.mode = u'fortran' - * elif mode == 'c': - */ - __pyx_v_order = 'F'; - - /* "View.MemoryView":159 - * if mode == 'fortran': - * order = b'F' - * self.mode = u'fortran' # <<<<<<<<<<<<<< - * elif mode == 'c': - * order = b'C' - */ - __Pyx_INCREF(__pyx_n_u_fortran); - __Pyx_GIVEREF(__pyx_n_u_fortran); - __Pyx_GOTREF(__pyx_v_self->mode); - __Pyx_DECREF(__pyx_v_self->mode); - __pyx_v_self->mode = __pyx_n_u_fortran; - - /* "View.MemoryView":157 - * - * cdef char order - * if mode == 'fortran': # <<<<<<<<<<<<<< - * order = b'F' - * self.mode = u'fortran' - */ - goto __pyx_L10; - } - - /* "View.MemoryView":160 - * order = b'F' - * self.mode = u'fortran' - * elif mode == 'c': # <<<<<<<<<<<<<< - * order = b'C' - * self.mode = u'c' - */ - __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_v_mode, __pyx_n_s_c, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(1, 160, __pyx_L1_error) - if (likely(__pyx_t_4)) { - - /* "View.MemoryView":161 - * self.mode = u'fortran' - * elif mode == 'c': - * order = b'C' # <<<<<<<<<<<<<< - * self.mode = u'c' - * else: - */ - __pyx_v_order = 'C'; - - /* "View.MemoryView":162 - * elif mode == 'c': - * order = b'C' - * self.mode = u'c' # <<<<<<<<<<<<<< - * else: - * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) - */ - __Pyx_INCREF(__pyx_n_u_c); - __Pyx_GIVEREF(__pyx_n_u_c); - __Pyx_GOTREF(__pyx_v_self->mode); - __Pyx_DECREF(__pyx_v_self->mode); - __pyx_v_self->mode = __pyx_n_u_c; - - /* "View.MemoryView":160 - * order = b'F' - * self.mode = u'fortran' - * elif mode == 'c': # <<<<<<<<<<<<<< - * order = b'C' - * self.mode = u'c' - */ - goto __pyx_L10; - } - - /* "View.MemoryView":164 - * self.mode = u'c' - * else: - * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) # <<<<<<<<<<<<<< - * - * self.len = fill_contig_strides_array(self._shape, self._strides, - */ - /*else*/ { - __pyx_t_3 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_v_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_10, 0, 0, 0); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __PYX_ERR(1, 164, __pyx_L1_error) - } - __pyx_L10:; - - /* "View.MemoryView":166 - * raise ValueError("Invalid mode, expected 'c' or 'fortran', got %s" % mode) - * - * self.len = fill_contig_strides_array(self._shape, self._strides, # <<<<<<<<<<<<<< - * itemsize, self.ndim, order) - * - */ - __pyx_v_self->len = __pyx_fill_contig_strides_array(__pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_itemsize, __pyx_v_self->ndim, __pyx_v_order); - - /* "View.MemoryView":169 - * itemsize, self.ndim, order) - * - * self.free_data = allocate_buffer # <<<<<<<<<<<<<< - * self.dtype_is_object = format == b'O' - * if allocate_buffer: - */ - __pyx_v_self->free_data = __pyx_v_allocate_buffer; - - /* "View.MemoryView":170 - * - * self.free_data = allocate_buffer - * self.dtype_is_object = format == b'O' # <<<<<<<<<<<<<< - * if allocate_buffer: - * - */ - __pyx_t_10 = PyObject_RichCompare(__pyx_v_format, __pyx_n_b_O, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 170, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 170, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_v_self->dtype_is_object = __pyx_t_4; - - /* "View.MemoryView":171 - * self.free_data = allocate_buffer - * self.dtype_is_object = format == b'O' - * if allocate_buffer: # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_4 = (__pyx_v_allocate_buffer != 0); - if (__pyx_t_4) { - - /* "View.MemoryView":174 - * - * - * self.data = malloc(self.len) # <<<<<<<<<<<<<< - * if not self.data: - * raise MemoryError("unable to allocate array data.") - */ - __pyx_v_self->data = ((char *)malloc(__pyx_v_self->len)); - - /* "View.MemoryView":175 - * - * self.data = malloc(self.len) - * if not self.data: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate array data.") - * - */ - __pyx_t_4 = ((!(__pyx_v_self->data != 0)) != 0); - if (unlikely(__pyx_t_4)) { - - /* "View.MemoryView":176 - * self.data = malloc(self.len) - * if not self.data: - * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< - * - * if self.dtype_is_object: - */ - __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(1, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_Raise(__pyx_t_10, 0, 0, 0); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __PYX_ERR(1, 176, __pyx_L1_error) - - /* "View.MemoryView":175 - * - * self.data = malloc(self.len) - * if not self.data: # <<<<<<<<<<<<<< - * raise MemoryError("unable to allocate array data.") - * - */ - } - - /* "View.MemoryView":178 - * raise MemoryError("unable to allocate array data.") - * - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * p = self.data - * for i in range(self.len / itemsize): - */ - __pyx_t_4 = (__pyx_v_self->dtype_is_object != 0); - if (__pyx_t_4) { - - /* "View.MemoryView":179 - * - * if self.dtype_is_object: - * p = self.data # <<<<<<<<<<<<<< - * for i in range(self.len / itemsize): - * p[i] = Py_None - */ - __pyx_v_p = ((PyObject **)__pyx_v_self->data); - - /* "View.MemoryView":180 - * if self.dtype_is_object: - * p = self.data - * for i in range(self.len / itemsize): # <<<<<<<<<<<<<< - * p[i] = Py_None - * Py_INCREF(Py_None) - */ - if (unlikely(__pyx_v_itemsize == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - __PYX_ERR(1, 180, __pyx_L1_error) - } - else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_self->len))) { - PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); - __PYX_ERR(1, 180, __pyx_L1_error) - } - __pyx_t_1 = __Pyx_div_Py_ssize_t(__pyx_v_self->len, __pyx_v_itemsize); - __pyx_t_9 = __pyx_t_1; - for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_9; __pyx_t_11+=1) { - __pyx_v_i = __pyx_t_11; - - /* "View.MemoryView":181 - * p = self.data - * for i in range(self.len / itemsize): - * p[i] = Py_None # <<<<<<<<<<<<<< - * Py_INCREF(Py_None) - * - */ - (__pyx_v_p[__pyx_v_i]) = Py_None; - - /* "View.MemoryView":182 - * for i in range(self.len / itemsize): - * p[i] = Py_None - * Py_INCREF(Py_None) # <<<<<<<<<<<<<< - * - * @cname('getbuffer') - */ - Py_INCREF(Py_None); - } - - /* "View.MemoryView":178 - * raise MemoryError("unable to allocate array data.") - * - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * p = self.data - * for i in range(self.len / itemsize): - */ - } - - /* "View.MemoryView":171 - * self.free_data = allocate_buffer - * self.dtype_is_object = format == b'O' - * if allocate_buffer: # <<<<<<<<<<<<<< - * - * - */ - } - - /* "View.MemoryView":122 - * cdef bint dtype_is_object - * - * def __cinit__(array self, tuple shape, Py_ssize_t itemsize, format not None, # <<<<<<<<<<<<<< - * mode="c", bint allocate_buffer=True): - * - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_AddTraceback("View.MemoryView.array.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_format); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":185 - * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * cdef int bufmode = -1 - * if self.mode == u"c": - */ - -/* Python wrapper */ -static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_v_bufmode; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - char *__pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - Py_ssize_t *__pyx_t_7; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - if (__pyx_v_info == NULL) { - PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); - return -1; - } - __Pyx_RefNannySetupContext("__getbuffer__", 0); - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - - /* "View.MemoryView":186 - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): - * cdef int bufmode = -1 # <<<<<<<<<<<<<< - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - */ - __pyx_v_bufmode = -1; - - /* "View.MemoryView":187 - * def __getbuffer__(self, Py_buffer *info, int flags): - * cdef int bufmode = -1 - * if self.mode == u"c": # <<<<<<<<<<<<<< - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": - */ - __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_c, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 187, __pyx_L1_error) - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":188 - * cdef int bufmode = -1 - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - */ - __pyx_v_bufmode = (PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); - - /* "View.MemoryView":187 - * def __getbuffer__(self, Py_buffer *info, int flags): - * cdef int bufmode = -1 - * if self.mode == u"c": # <<<<<<<<<<<<<< - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": - */ - goto __pyx_L3; - } - - /* "View.MemoryView":189 - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": # <<<<<<<<<<<<<< - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): - */ - __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_self->mode, __pyx_n_u_fortran, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 189, __pyx_L1_error) - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":190 - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS # <<<<<<<<<<<<<< - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") - */ - __pyx_v_bufmode = (PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS); - - /* "View.MemoryView":189 - * if self.mode == u"c": - * bufmode = PyBUF_C_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * elif self.mode == u"fortran": # <<<<<<<<<<<<<< - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): - */ - } - __pyx_L3:; - - /* "View.MemoryView":191 - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): # <<<<<<<<<<<<<< - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data - */ - __pyx_t_1 = ((!((__pyx_v_flags & __pyx_v_bufmode) != 0)) != 0); - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":192 - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< - * info.buf = self.data - * info.len = self.len - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 192, __pyx_L1_error) - - /* "View.MemoryView":191 - * elif self.mode == u"fortran": - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): # <<<<<<<<<<<<<< - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data - */ - } - - /* "View.MemoryView":193 - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data # <<<<<<<<<<<<<< - * info.len = self.len - * info.ndim = self.ndim - */ - __pyx_t_4 = __pyx_v_self->data; - __pyx_v_info->buf = __pyx_t_4; - - /* "View.MemoryView":194 - * raise ValueError("Can only create a buffer that is contiguous in memory.") - * info.buf = self.data - * info.len = self.len # <<<<<<<<<<<<<< - * info.ndim = self.ndim - * info.shape = self._shape - */ - __pyx_t_5 = __pyx_v_self->len; - __pyx_v_info->len = __pyx_t_5; - - /* "View.MemoryView":195 - * info.buf = self.data - * info.len = self.len - * info.ndim = self.ndim # <<<<<<<<<<<<<< - * info.shape = self._shape - * info.strides = self._strides - */ - __pyx_t_6 = __pyx_v_self->ndim; - __pyx_v_info->ndim = __pyx_t_6; - - /* "View.MemoryView":196 - * info.len = self.len - * info.ndim = self.ndim - * info.shape = self._shape # <<<<<<<<<<<<<< - * info.strides = self._strides - * info.suboffsets = NULL - */ - __pyx_t_7 = __pyx_v_self->_shape; - __pyx_v_info->shape = __pyx_t_7; - - /* "View.MemoryView":197 - * info.ndim = self.ndim - * info.shape = self._shape - * info.strides = self._strides # <<<<<<<<<<<<<< - * info.suboffsets = NULL - * info.itemsize = self.itemsize - */ - __pyx_t_7 = __pyx_v_self->_strides; - __pyx_v_info->strides = __pyx_t_7; - - /* "View.MemoryView":198 - * info.shape = self._shape - * info.strides = self._strides - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * info.itemsize = self.itemsize - * info.readonly = 0 - */ - __pyx_v_info->suboffsets = NULL; - - /* "View.MemoryView":199 - * info.strides = self._strides - * info.suboffsets = NULL - * info.itemsize = self.itemsize # <<<<<<<<<<<<<< - * info.readonly = 0 - * - */ - __pyx_t_5 = __pyx_v_self->itemsize; - __pyx_v_info->itemsize = __pyx_t_5; - - /* "View.MemoryView":200 - * info.suboffsets = NULL - * info.itemsize = self.itemsize - * info.readonly = 0 # <<<<<<<<<<<<<< - * - * if flags & PyBUF_FORMAT: - */ - __pyx_v_info->readonly = 0; - - /* "View.MemoryView":202 - * info.readonly = 0 - * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.format - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":203 - * - * if flags & PyBUF_FORMAT: - * info.format = self.format # <<<<<<<<<<<<<< - * else: - * info.format = NULL - */ - __pyx_t_4 = __pyx_v_self->format; - __pyx_v_info->format = __pyx_t_4; - - /* "View.MemoryView":202 - * info.readonly = 0 - * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.format - * else: - */ - goto __pyx_L5; - } - - /* "View.MemoryView":205 - * info.format = self.format - * else: - * info.format = NULL # <<<<<<<<<<<<<< - * - * info.obj = self - */ - /*else*/ { - __pyx_v_info->format = NULL; - } - __pyx_L5:; - - /* "View.MemoryView":207 - * info.format = NULL - * - * info.obj = self # <<<<<<<<<<<<<< - * - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") - */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - - /* "View.MemoryView":185 - * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * cdef int bufmode = -1 - * if self.mode == u"c": - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.array.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; - } - goto __pyx_L2; - __pyx_L0:; - if (__pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; - } - __pyx_L2:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":211 - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") - * - * def __dealloc__(array self): # <<<<<<<<<<<<<< - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) - */ - -/* Python wrapper */ -static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_array___dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "View.MemoryView":212 - * - * def __dealloc__(array self): - * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< - * self.callback_free_data(self.data) - * elif self.free_data: - */ - __pyx_t_1 = ((__pyx_v_self->callback_free_data != NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":213 - * def __dealloc__(array self): - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) # <<<<<<<<<<<<<< - * elif self.free_data: - * if self.dtype_is_object: - */ - __pyx_v_self->callback_free_data(__pyx_v_self->data); - - /* "View.MemoryView":212 - * - * def __dealloc__(array self): - * if self.callback_free_data != NULL: # <<<<<<<<<<<<<< - * self.callback_free_data(self.data) - * elif self.free_data: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":214 - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) - * elif self.free_data: # <<<<<<<<<<<<<< - * if self.dtype_is_object: - * refcount_objects_in_slice(self.data, self._shape, - */ - __pyx_t_1 = (__pyx_v_self->free_data != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":215 - * self.callback_free_data(self.data) - * elif self.free_data: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice(self.data, self._shape, - * self._strides, self.ndim, False) - */ - __pyx_t_1 = (__pyx_v_self->dtype_is_object != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":216 - * elif self.free_data: - * if self.dtype_is_object: - * refcount_objects_in_slice(self.data, self._shape, # <<<<<<<<<<<<<< - * self._strides, self.ndim, False) - * free(self.data) - */ - __pyx_memoryview_refcount_objects_in_slice(__pyx_v_self->data, __pyx_v_self->_shape, __pyx_v_self->_strides, __pyx_v_self->ndim, 0); - - /* "View.MemoryView":215 - * self.callback_free_data(self.data) - * elif self.free_data: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice(self.data, self._shape, - * self._strides, self.ndim, False) - */ - } - - /* "View.MemoryView":218 - * refcount_objects_in_slice(self.data, self._shape, - * self._strides, self.ndim, False) - * free(self.data) # <<<<<<<<<<<<<< - * PyObject_Free(self._shape) - * - */ - free(__pyx_v_self->data); - - /* "View.MemoryView":214 - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) - * elif self.free_data: # <<<<<<<<<<<<<< - * if self.dtype_is_object: - * refcount_objects_in_slice(self.data, self._shape, - */ - } - __pyx_L3:; - - /* "View.MemoryView":219 - * self._strides, self.ndim, False) - * free(self.data) - * PyObject_Free(self._shape) # <<<<<<<<<<<<<< - * - * @property - */ - PyObject_Free(__pyx_v_self->_shape); - - /* "View.MemoryView":211 - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") - * - * def __dealloc__(array self): # <<<<<<<<<<<<<< - * if self.callback_free_data != NULL: - * self.callback_free_data(self.data) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":222 - * - * @property - * def memview(self): # <<<<<<<<<<<<<< - * return self.get_memview() - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":223 - * @property - * def memview(self): - * return self.get_memview() # <<<<<<<<<<<<<< - * - * @cname('get_memview') - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_array *)__pyx_v_self->__pyx_vtab)->get_memview(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "View.MemoryView":222 - * - * @property - * def memview(self): # <<<<<<<<<<<<<< - * return self.get_memview() - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.array.memview.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":226 - * - * @cname('get_memview') - * cdef get_memview(self): # <<<<<<<<<<<<<< - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE - * return memoryview(self, flags, self.dtype_is_object) - */ - -static PyObject *__pyx_array_get_memview(struct __pyx_array_obj *__pyx_v_self) { - int __pyx_v_flags; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_memview", 0); - - /* "View.MemoryView":227 - * @cname('get_memview') - * cdef get_memview(self): - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE # <<<<<<<<<<<<<< - * return memoryview(self, flags, self.dtype_is_object) - * - */ - __pyx_v_flags = ((PyBUF_ANY_CONTIGUOUS | PyBUF_FORMAT) | PyBUF_WRITABLE); - - /* "View.MemoryView":228 - * cdef get_memview(self): - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE - * return memoryview(self, flags, self.dtype_is_object) # <<<<<<<<<<<<<< - * - * def __len__(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":226 - * - * @cname('get_memview') - * cdef get_memview(self): # <<<<<<<<<<<<<< - * flags = PyBUF_ANY_CONTIGUOUS|PyBUF_FORMAT|PyBUF_WRITABLE - * return memoryview(self, flags, self.dtype_is_object) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.array.get_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":230 - * return memoryview(self, flags, self.dtype_is_object) - * - * def __len__(self): # <<<<<<<<<<<<<< - * return self._shape[0] - * - */ - -/* Python wrapper */ -static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self); /*proto*/ -static Py_ssize_t __pyx_array___len__(PyObject *__pyx_v_self) { - Py_ssize_t __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(((struct __pyx_array_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static Py_ssize_t __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__len__(struct __pyx_array_obj *__pyx_v_self) { - Py_ssize_t __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__len__", 0); - - /* "View.MemoryView":231 - * - * def __len__(self): - * return self._shape[0] # <<<<<<<<<<<<<< - * - * def __getattr__(self, attr): - */ - __pyx_r = (__pyx_v_self->_shape[0]); - goto __pyx_L0; - - /* "View.MemoryView":230 - * return memoryview(self, flags, self.dtype_is_object) - * - * def __len__(self): # <<<<<<<<<<<<<< - * return self._shape[0] - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":233 - * return self._shape[0] - * - * def __getattr__(self, attr): # <<<<<<<<<<<<<< - * return getattr(self.memview, attr) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr); /*proto*/ -static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx_v_attr) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__getattr__", 0); - - /* "View.MemoryView":234 - * - * def __getattr__(self, attr): - * return getattr(self.memview, attr) # <<<<<<<<<<<<<< - * - * def __getitem__(self, item): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetAttr(__pyx_t_1, __pyx_v_attr); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":233 - * return self._shape[0] - * - * def __getattr__(self, attr): # <<<<<<<<<<<<<< - * return getattr(self.memview, attr) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.array.__getattr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":236 - * return getattr(self.memview, attr) - * - * def __getitem__(self, item): # <<<<<<<<<<<<<< - * return self.memview[item] - * - */ - -/* Python wrapper */ -static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item); /*proto*/ -static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__getitem__", 0); - - /* "View.MemoryView":237 - * - * def __getitem__(self, item): - * return self.memview[item] # <<<<<<<<<<<<<< - * - * def __setitem__(self, item, value): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_item); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":236 - * return getattr(self.memview, attr) - * - * def __getitem__(self, item): # <<<<<<<<<<<<<< - * return self.memview[item] - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.array.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":239 - * return self.memview[item] - * - * def __setitem__(self, item, value): # <<<<<<<<<<<<<< - * self.memview[item] = value - * - */ - -/* Python wrapper */ -static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_12__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__setitem__", 0); - - /* "View.MemoryView":240 - * - * def __setitem__(self, item, value): - * self.memview[item] = value # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_memview); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 240, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (unlikely(PyObject_SetItem(__pyx_t_1, __pyx_v_item, __pyx_v_value) < 0)) __PYX_ERR(1, 240, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "View.MemoryView":239 - * return self.memview[item] - * - * def __setitem__(self, item, value): # <<<<<<<<<<<<<< - * self.memview[item] = value - * - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.array.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw___pyx_array_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_array___reduce_cython__(((struct __pyx_array_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_array___reduce_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.array.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw___pyx_array_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_array_2__setstate_cython__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_array_2__setstate_cython__(CYTHON_UNUSED struct __pyx_array_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.array.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":244 - * - * @cname("__pyx_array_new") - * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< - * char *mode, char *buf): - * cdef array result - */ - -static struct __pyx_array_obj *__pyx_array_new(PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, char *__pyx_v_format, char *__pyx_v_mode, char *__pyx_v_buf) { - struct __pyx_array_obj *__pyx_v_result = 0; - struct __pyx_array_obj *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("array_cwrapper", 0); - - /* "View.MemoryView":248 - * cdef array result - * - * if buf == NULL: # <<<<<<<<<<<<<< - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - */ - __pyx_t_1 = ((__pyx_v_buf == NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":249 - * - * if buf == NULL: - * result = array(shape, itemsize, format, mode.decode('ASCII')) # <<<<<<<<<<<<<< - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), - */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_shape); - __Pyx_GIVEREF(__pyx_v_shape); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_shape); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); - __pyx_t_2 = 0; - __pyx_t_3 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_4); - __pyx_t_4 = 0; - - /* "View.MemoryView":248 - * cdef array result - * - * if buf == NULL: # <<<<<<<<<<<<<< - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":251 - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< - * allocate_buffer=False) - * result.data = buf - */ - /*else*/ { - __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_itemsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyBytes_FromString(__pyx_v_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_mode, 0, strlen(__pyx_v_mode), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_shape); - __Pyx_GIVEREF(__pyx_v_shape); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); - __pyx_t_4 = 0; - __pyx_t_5 = 0; - __pyx_t_3 = 0; - - /* "View.MemoryView":252 - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), - * allocate_buffer=False) # <<<<<<<<<<<<<< - * result.data = buf - * - */ - __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_allocate_buffer, Py_False) < 0) __PYX_ERR(1, 252, __pyx_L1_error) - - /* "View.MemoryView":251 - * result = array(shape, itemsize, format, mode.decode('ASCII')) - * else: - * result = array(shape, itemsize, format, mode.decode('ASCII'), # <<<<<<<<<<<<<< - * allocate_buffer=False) - * result.data = buf - */ - __pyx_t_5 = __Pyx_PyObject_Call(((PyObject *)__pyx_array_type), __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result = ((struct __pyx_array_obj *)__pyx_t_5); - __pyx_t_5 = 0; - - /* "View.MemoryView":253 - * result = array(shape, itemsize, format, mode.decode('ASCII'), - * allocate_buffer=False) - * result.data = buf # <<<<<<<<<<<<<< - * - * return result - */ - __pyx_v_result->data = __pyx_v_buf; - } - __pyx_L3:; - - /* "View.MemoryView":255 - * result.data = buf - * - * return result # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = __pyx_v_result; - goto __pyx_L0; - - /* "View.MemoryView":244 - * - * @cname("__pyx_array_new") - * cdef array array_cwrapper(tuple shape, Py_ssize_t itemsize, char *format, # <<<<<<<<<<<<<< - * char *mode, char *buf): - * cdef array result - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.array_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":281 - * cdef class Enum(object): - * cdef object name - * def __init__(self, name): # <<<<<<<<<<<<<< - * self.name = name - * def __repr__(self): - */ - -/* Python wrapper */ -static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_name = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(1, 281, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_name = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 281, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.Enum.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__init__", 0); - - /* "View.MemoryView":282 - * cdef object name - * def __init__(self, name): - * self.name = name # <<<<<<<<<<<<<< - * def __repr__(self): - * return self.name - */ - __Pyx_INCREF(__pyx_v_name); - __Pyx_GIVEREF(__pyx_v_name); - __Pyx_GOTREF(__pyx_v_self->name); - __Pyx_DECREF(__pyx_v_self->name); - __pyx_v_self->name = __pyx_v_name; - - /* "View.MemoryView":281 - * cdef class Enum(object): - * cdef object name - * def __init__(self, name): # <<<<<<<<<<<<<< - * self.name = name - * def __repr__(self): - */ - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":283 - * def __init__(self, name): - * self.name = name - * def __repr__(self): # <<<<<<<<<<<<<< - * return self.name - * - */ - -/* Python wrapper */ -static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "View.MemoryView":284 - * self.name = name - * def __repr__(self): - * return self.name # <<<<<<<<<<<<<< - * - * cdef generic = Enum("") - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->name); - __pyx_r = __pyx_v_self->name; - goto __pyx_L0; - - /* "View.MemoryView":283 - * def __init__(self, name): - * self.name = name - * def __repr__(self): # <<<<<<<<<<<<<< - * return self.name - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * cdef tuple state - * cdef object _dict - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw___pyx_MemviewEnum_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_MemviewEnum___reduce_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_MemviewEnum___reduce_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { - PyObject *__pyx_v_state = 0; - PyObject *__pyx_v__dict = 0; - int __pyx_v_use_setstate; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":5 - * cdef object _dict - * cdef bint use_setstate - * state = (self.name,) # <<<<<<<<<<<<<< - * _dict = getattr(self, '__dict__', None) - * if _dict is not None: - */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_self->name); - __Pyx_GIVEREF(__pyx_v_self->name); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->name); - __pyx_v_state = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "(tree fragment)":6 - * cdef bint use_setstate - * state = (self.name,) - * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<< - * if _dict is not None: - * state += (_dict,) - */ - __pyx_t_1 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v__dict = __pyx_t_1; - __pyx_t_1 = 0; - - /* "(tree fragment)":7 - * state = (self.name,) - * _dict = getattr(self, '__dict__', None) - * if _dict is not None: # <<<<<<<<<<<<<< - * state += (_dict,) - * use_setstate = True - */ - __pyx_t_2 = (__pyx_v__dict != Py_None); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "(tree fragment)":8 - * _dict = getattr(self, '__dict__', None) - * if _dict is not None: - * state += (_dict,) # <<<<<<<<<<<<<< - * use_setstate = True - * else: - */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v__dict); - __Pyx_GIVEREF(__pyx_v__dict); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v__dict); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 8, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_4)); - __pyx_t_4 = 0; - - /* "(tree fragment)":9 - * if _dict is not None: - * state += (_dict,) - * use_setstate = True # <<<<<<<<<<<<<< - * else: - * use_setstate = self.name is not None - */ - __pyx_v_use_setstate = 1; - - /* "(tree fragment)":7 - * state = (self.name,) - * _dict = getattr(self, '__dict__', None) - * if _dict is not None: # <<<<<<<<<<<<<< - * state += (_dict,) - * use_setstate = True - */ - goto __pyx_L3; - } - - /* "(tree fragment)":11 - * use_setstate = True - * else: - * use_setstate = self.name is not None # <<<<<<<<<<<<<< - * if use_setstate: - * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state - */ - /*else*/ { - __pyx_t_3 = (__pyx_v_self->name != Py_None); - __pyx_v_use_setstate = __pyx_t_3; - } - __pyx_L3:; - - /* "(tree fragment)":12 - * else: - * use_setstate = self.name is not None - * if use_setstate: # <<<<<<<<<<<<<< - * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state - * else: - */ - __pyx_t_3 = (__pyx_v_use_setstate != 0); - if (__pyx_t_3) { - - /* "(tree fragment)":13 - * use_setstate = self.name is not None - * if use_setstate: - * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state # <<<<<<<<<<<<<< - * else: - * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); - __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); - __Pyx_INCREF(__pyx_int_184977713); - __Pyx_GIVEREF(__pyx_int_184977713); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); - __Pyx_INCREF(__pyx_v_state); - __Pyx_GIVEREF(__pyx_v_state); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_state); - __pyx_t_4 = 0; - __pyx_t_1 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "(tree fragment)":12 - * else: - * use_setstate = self.name is not None - * if use_setstate: # <<<<<<<<<<<<<< - * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state - * else: - */ - } - - /* "(tree fragment)":15 - * return __pyx_unpickle_Enum, (type(self), 0xb068931, None), state - * else: - * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * __pyx_unpickle_Enum__set_state(self, __pyx_state) - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pyx_unpickle_Enum); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 15, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); - __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self)))); - __Pyx_INCREF(__pyx_int_184977713); - __Pyx_GIVEREF(__pyx_int_184977713); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_184977713); - __Pyx_INCREF(__pyx_v_state); - __Pyx_GIVEREF(__pyx_v_state); - PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 15, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1); - __pyx_t_5 = 0; - __pyx_t_1 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - } - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * cdef tuple state - * cdef object _dict - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.Enum.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_state); - __Pyx_XDECREF(__pyx_v__dict); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":16 - * else: - * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * __pyx_unpickle_Enum__set_state(self, __pyx_state) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw___pyx_MemviewEnum_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_MemviewEnum_2__setstate_cython__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_MemviewEnum_2__setstate_cython__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":17 - * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) - * def __setstate_cython__(self, __pyx_state): - * __pyx_unpickle_Enum__set_state(self, __pyx_state) # <<<<<<<<<<<<<< - */ - if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error) - __pyx_t_1 = __pyx_unpickle_Enum__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "(tree fragment)":16 - * else: - * return __pyx_unpickle_Enum, (type(self), 0xb068931, state) - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * __pyx_unpickle_Enum__set_state(self, __pyx_state) - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.Enum.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":298 - * - * @cname('__pyx_align_pointer') - * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< - * "Align pointer memory on a given boundary" - * cdef Py_intptr_t aligned_p = memory - */ - -static void *__pyx_align_pointer(void *__pyx_v_memory, size_t __pyx_v_alignment) { - Py_intptr_t __pyx_v_aligned_p; - size_t __pyx_v_offset; - void *__pyx_r; - int __pyx_t_1; - - /* "View.MemoryView":300 - * cdef void *align_pointer(void *memory, size_t alignment) nogil: - * "Align pointer memory on a given boundary" - * cdef Py_intptr_t aligned_p = memory # <<<<<<<<<<<<<< - * cdef size_t offset - * - */ - __pyx_v_aligned_p = ((Py_intptr_t)__pyx_v_memory); - - /* "View.MemoryView":304 - * - * with cython.cdivision(True): - * offset = aligned_p % alignment # <<<<<<<<<<<<<< - * - * if offset > 0: - */ - __pyx_v_offset = (__pyx_v_aligned_p % __pyx_v_alignment); - - /* "View.MemoryView":306 - * offset = aligned_p % alignment - * - * if offset > 0: # <<<<<<<<<<<<<< - * aligned_p += alignment - offset - * - */ - __pyx_t_1 = ((__pyx_v_offset > 0) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":307 - * - * if offset > 0: - * aligned_p += alignment - offset # <<<<<<<<<<<<<< - * - * return aligned_p - */ - __pyx_v_aligned_p = (__pyx_v_aligned_p + (__pyx_v_alignment - __pyx_v_offset)); - - /* "View.MemoryView":306 - * offset = aligned_p % alignment - * - * if offset > 0: # <<<<<<<<<<<<<< - * aligned_p += alignment - offset - * - */ - } - - /* "View.MemoryView":309 - * aligned_p += alignment - offset - * - * return aligned_p # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = ((void *)__pyx_v_aligned_p); - goto __pyx_L0; - - /* "View.MemoryView":298 - * - * @cname('__pyx_align_pointer') - * cdef void *align_pointer(void *memory, size_t alignment) nogil: # <<<<<<<<<<<<<< - * "Align pointer memory on a given boundary" - * cdef Py_intptr_t aligned_p = memory - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":345 - * cdef __Pyx_TypeInfo *typeinfo - * - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< - * self.obj = obj - * self.flags = flags - */ - -/* Python wrapper */ -static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_obj = 0; - int __pyx_v_flags; - int __pyx_v_dtype_is_object; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_flags,&__pyx_n_s_dtype_is_object,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_obj)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_flags)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); __PYX_ERR(1, 345, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (kw_args > 0) { - PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_dtype_is_object); - if (value) { values[2] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(1, 345, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_obj = values[0]; - __pyx_v_flags = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error) - if (values[2]) { - __pyx_v_dtype_is_object = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_dtype_is_object == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 345, __pyx_L3_error) - } else { - __pyx_v_dtype_is_object = ((int)0); - } - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 345, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "View.MemoryView":346 - * - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): - * self.obj = obj # <<<<<<<<<<<<<< - * self.flags = flags - * if type(self) is memoryview or obj is not None: - */ - __Pyx_INCREF(__pyx_v_obj); - __Pyx_GIVEREF(__pyx_v_obj); - __Pyx_GOTREF(__pyx_v_self->obj); - __Pyx_DECREF(__pyx_v_self->obj); - __pyx_v_self->obj = __pyx_v_obj; - - /* "View.MemoryView":347 - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): - * self.obj = obj - * self.flags = flags # <<<<<<<<<<<<<< - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) - */ - __pyx_v_self->flags = __pyx_v_flags; - - /* "View.MemoryView":348 - * self.obj = obj - * self.flags = flags - * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: - */ - __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)__pyx_memoryview_type)); - __pyx_t_3 = (__pyx_t_2 != 0); - if (!__pyx_t_3) { - } else { - __pyx_t_1 = __pyx_t_3; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_3 = (__pyx_v_obj != Py_None); - __pyx_t_2 = (__pyx_t_3 != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L4_bool_binop_done:; - if (__pyx_t_1) { - - /* "View.MemoryView":349 - * self.flags = flags - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) # <<<<<<<<<<<<<< - * if self.view.obj == NULL: - * (<__pyx_buffer *> &self.view).obj = Py_None - */ - __pyx_t_4 = __Pyx_GetBuffer(__pyx_v_obj, (&__pyx_v_self->view), __pyx_v_flags); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 349, __pyx_L1_error) - - /* "View.MemoryView":350 - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: # <<<<<<<<<<<<<< - * (<__pyx_buffer *> &self.view).obj = Py_None - * Py_INCREF(Py_None) - */ - __pyx_t_1 = ((((PyObject *)__pyx_v_self->view.obj) == NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":351 - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: - * (<__pyx_buffer *> &self.view).obj = Py_None # <<<<<<<<<<<<<< - * Py_INCREF(Py_None) - * - */ - ((Py_buffer *)(&__pyx_v_self->view))->obj = Py_None; - - /* "View.MemoryView":352 - * if self.view.obj == NULL: - * (<__pyx_buffer *> &self.view).obj = Py_None - * Py_INCREF(Py_None) # <<<<<<<<<<<<<< - * - * global __pyx_memoryview_thread_locks_used - */ - Py_INCREF(Py_None); - - /* "View.MemoryView":350 - * if type(self) is memoryview or obj is not None: - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: # <<<<<<<<<<<<<< - * (<__pyx_buffer *> &self.view).obj = Py_None - * Py_INCREF(Py_None) - */ - } - - /* "View.MemoryView":348 - * self.obj = obj - * self.flags = flags - * if type(self) is memoryview or obj is not None: # <<<<<<<<<<<<<< - * __Pyx_GetBuffer(obj, &self.view, flags) - * if self.view.obj == NULL: - */ - } - - /* "View.MemoryView":355 - * - * global __pyx_memoryview_thread_locks_used - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - */ - __pyx_t_1 = ((__pyx_memoryview_thread_locks_used < 8) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":356 - * global __pyx_memoryview_thread_locks_used - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: - */ - __pyx_v_self->lock = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); - - /* "View.MemoryView":357 - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 # <<<<<<<<<<<<<< - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() - */ - __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used + 1); - - /* "View.MemoryView":355 - * - * global __pyx_memoryview_thread_locks_used - * if __pyx_memoryview_thread_locks_used < THREAD_LOCKS_PREALLOCATED: # <<<<<<<<<<<<<< - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - */ - } - - /* "View.MemoryView":358 - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: # <<<<<<<<<<<<<< - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: - */ - __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":359 - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() # <<<<<<<<<<<<<< - * if self.lock is NULL: - * raise MemoryError - */ - __pyx_v_self->lock = PyThread_allocate_lock(); - - /* "View.MemoryView":360 - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: # <<<<<<<<<<<<<< - * raise MemoryError - * - */ - __pyx_t_1 = ((__pyx_v_self->lock == NULL) != 0); - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":361 - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: - * raise MemoryError # <<<<<<<<<<<<<< - * - * if flags & PyBUF_FORMAT: - */ - PyErr_NoMemory(); __PYX_ERR(1, 361, __pyx_L1_error) - - /* "View.MemoryView":360 - * if self.lock is NULL: - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: # <<<<<<<<<<<<<< - * raise MemoryError - * - */ - } - - /* "View.MemoryView":358 - * self.lock = __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] - * __pyx_memoryview_thread_locks_used += 1 - * if self.lock is NULL: # <<<<<<<<<<<<<< - * self.lock = PyThread_allocate_lock() - * if self.lock is NULL: - */ - } - - /* "View.MemoryView":363 - * raise MemoryError - * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":364 - * - * if flags & PyBUF_FORMAT: - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') # <<<<<<<<<<<<<< - * else: - * self.dtype_is_object = dtype_is_object - */ - __pyx_t_2 = (((__pyx_v_self->view.format[0]) == 'O') != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_2 = (((__pyx_v_self->view.format[1]) == '\x00') != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L11_bool_binop_done:; - __pyx_v_self->dtype_is_object = __pyx_t_1; - - /* "View.MemoryView":363 - * raise MemoryError - * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') - * else: - */ - goto __pyx_L10; - } - - /* "View.MemoryView":366 - * self.dtype_is_object = (self.view.format[0] == b'O' and self.view.format[1] == b'\0') - * else: - * self.dtype_is_object = dtype_is_object # <<<<<<<<<<<<<< - * - * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( - */ - /*else*/ { - __pyx_v_self->dtype_is_object = __pyx_v_dtype_is_object; - } - __pyx_L10:; - - /* "View.MemoryView":368 - * self.dtype_is_object = dtype_is_object - * - * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( # <<<<<<<<<<<<<< - * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) - * self.typeinfo = NULL - */ - __pyx_v_self->acquisition_count_aligned_p = ((__pyx_atomic_int *)__pyx_align_pointer(((void *)(&(__pyx_v_self->acquisition_count[0]))), (sizeof(__pyx_atomic_int)))); - - /* "View.MemoryView":370 - * self.acquisition_count_aligned_p = <__pyx_atomic_int *> align_pointer( - * &self.acquisition_count[0], sizeof(__pyx_atomic_int)) - * self.typeinfo = NULL # <<<<<<<<<<<<<< - * - * def __dealloc__(memoryview self): - */ - __pyx_v_self->typeinfo = NULL; - - /* "View.MemoryView":345 - * cdef __Pyx_TypeInfo *typeinfo - * - * def __cinit__(memoryview self, object obj, int flags, bint dtype_is_object=False): # <<<<<<<<<<<<<< - * self.obj = obj - * self.flags = flags - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("View.MemoryView.memoryview.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":372 - * self.typeinfo = NULL - * - * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) - */ - -/* Python wrapper */ -static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { - int __pyx_v_i; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - PyThread_type_lock __pyx_t_6; - PyThread_type_lock __pyx_t_7; - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "View.MemoryView":373 - * - * def __dealloc__(memoryview self): - * if self.obj is not None: # <<<<<<<<<<<<<< - * __Pyx_ReleaseBuffer(&self.view) - * elif (<__pyx_buffer *> &self.view).obj == Py_None: - */ - __pyx_t_1 = (__pyx_v_self->obj != Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":374 - * def __dealloc__(memoryview self): - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) # <<<<<<<<<<<<<< - * elif (<__pyx_buffer *> &self.view).obj == Py_None: - * - */ - __Pyx_ReleaseBuffer((&__pyx_v_self->view)); - - /* "View.MemoryView":373 - * - * def __dealloc__(memoryview self): - * if self.obj is not None: # <<<<<<<<<<<<<< - * __Pyx_ReleaseBuffer(&self.view) - * elif (<__pyx_buffer *> &self.view).obj == Py_None: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":375 - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) - * elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<< - * - * (<__pyx_buffer *> &self.view).obj = NULL - */ - __pyx_t_2 = ((((Py_buffer *)(&__pyx_v_self->view))->obj == Py_None) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":377 - * elif (<__pyx_buffer *> &self.view).obj == Py_None: - * - * (<__pyx_buffer *> &self.view).obj = NULL # <<<<<<<<<<<<<< - * Py_DECREF(Py_None) - * - */ - ((Py_buffer *)(&__pyx_v_self->view))->obj = NULL; - - /* "View.MemoryView":378 - * - * (<__pyx_buffer *> &self.view).obj = NULL - * Py_DECREF(Py_None) # <<<<<<<<<<<<<< - * - * cdef int i - */ - Py_DECREF(Py_None); - - /* "View.MemoryView":375 - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) - * elif (<__pyx_buffer *> &self.view).obj == Py_None: # <<<<<<<<<<<<<< - * - * (<__pyx_buffer *> &self.view).obj = NULL - */ - } - __pyx_L3:; - - /* "View.MemoryView":382 - * cdef int i - * global __pyx_memoryview_thread_locks_used - * if self.lock != NULL: # <<<<<<<<<<<<<< - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: - */ - __pyx_t_2 = ((__pyx_v_self->lock != NULL) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":383 - * global __pyx_memoryview_thread_locks_used - * if self.lock != NULL: - * for i in range(__pyx_memoryview_thread_locks_used): # <<<<<<<<<<<<<< - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 - */ - __pyx_t_3 = __pyx_memoryview_thread_locks_used; - __pyx_t_4 = __pyx_t_3; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v_i = __pyx_t_5; - - /* "View.MemoryView":384 - * if self.lock != NULL: - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: - */ - __pyx_t_2 = (((__pyx_memoryview_thread_locks[__pyx_v_i]) == __pyx_v_self->lock) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":385 - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 # <<<<<<<<<<<<<< - * if i != __pyx_memoryview_thread_locks_used: - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - */ - __pyx_memoryview_thread_locks_used = (__pyx_memoryview_thread_locks_used - 1); - - /* "View.MemoryView":386 - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) - */ - __pyx_t_2 = ((__pyx_v_i != __pyx_memoryview_thread_locks_used) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":388 - * if i != __pyx_memoryview_thread_locks_used: - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) # <<<<<<<<<<<<<< - * break - * else: - */ - __pyx_t_6 = (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]); - __pyx_t_7 = (__pyx_memoryview_thread_locks[__pyx_v_i]); - - /* "View.MemoryView":387 - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) - * break - */ - (__pyx_memoryview_thread_locks[__pyx_v_i]) = __pyx_t_6; - (__pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used]) = __pyx_t_7; - - /* "View.MemoryView":386 - * if __pyx_memoryview_thread_locks[i] is self.lock: - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) - */ - } - - /* "View.MemoryView":389 - * __pyx_memoryview_thread_locks[i], __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used] = ( - * __pyx_memoryview_thread_locks[__pyx_memoryview_thread_locks_used], __pyx_memoryview_thread_locks[i]) - * break # <<<<<<<<<<<<<< - * else: - * PyThread_free_lock(self.lock) - */ - goto __pyx_L6_break; - - /* "View.MemoryView":384 - * if self.lock != NULL: - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: # <<<<<<<<<<<<<< - * __pyx_memoryview_thread_locks_used -= 1 - * if i != __pyx_memoryview_thread_locks_used: - */ - } - } - /*else*/ { - - /* "View.MemoryView":391 - * break - * else: - * PyThread_free_lock(self.lock) # <<<<<<<<<<<<<< - * - * cdef char *get_item_pointer(memoryview self, object index) except NULL: - */ - PyThread_free_lock(__pyx_v_self->lock); - } - __pyx_L6_break:; - - /* "View.MemoryView":382 - * cdef int i - * global __pyx_memoryview_thread_locks_used - * if self.lock != NULL: # <<<<<<<<<<<<<< - * for i in range(__pyx_memoryview_thread_locks_used): - * if __pyx_memoryview_thread_locks[i] is self.lock: - */ - } - - /* "View.MemoryView":372 - * self.typeinfo = NULL - * - * def __dealloc__(memoryview self): # <<<<<<<<<<<<<< - * if self.obj is not None: - * __Pyx_ReleaseBuffer(&self.view) - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":393 - * PyThread_free_lock(self.lock) - * - * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< - * cdef Py_ssize_t dim - * cdef char *itemp = self.view.buf - */ - -static char *__pyx_memoryview_get_item_pointer(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { - Py_ssize_t __pyx_v_dim; - char *__pyx_v_itemp; - PyObject *__pyx_v_idx = NULL; - char *__pyx_r; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; - PyObject *(*__pyx_t_4)(PyObject *); - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - char *__pyx_t_7; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_item_pointer", 0); - - /* "View.MemoryView":395 - * cdef char *get_item_pointer(memoryview self, object index) except NULL: - * cdef Py_ssize_t dim - * cdef char *itemp = self.view.buf # <<<<<<<<<<<<<< - * - * for dim, idx in enumerate(index): - */ - __pyx_v_itemp = ((char *)__pyx_v_self->view.buf); - - /* "View.MemoryView":397 - * cdef char *itemp = self.view.buf - * - * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< - * itemp = pybuffer_index(&self.view, itemp, idx, dim) - * - */ - __pyx_t_1 = 0; - if (likely(PyList_CheckExact(__pyx_v_index)) || PyTuple_CheckExact(__pyx_v_index)) { - __pyx_t_2 = __pyx_v_index; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; - __pyx_t_4 = NULL; - } else { - __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 397, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 397, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_4)) { - if (likely(PyList_CheckExact(__pyx_t_2))) { - if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } else { - if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(1, 397, __pyx_L1_error) - #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 397, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - } - } else { - __pyx_t_5 = __pyx_t_4(__pyx_t_2); - if (unlikely(!__pyx_t_5)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(1, 397, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_5); - } - __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_v_dim = __pyx_t_1; - __pyx_t_1 = (__pyx_t_1 + 1); - - /* "View.MemoryView":398 - * - * for dim, idx in enumerate(index): - * itemp = pybuffer_index(&self.view, itemp, idx, dim) # <<<<<<<<<<<<<< - * - * return itemp - */ - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 398, __pyx_L1_error) - __pyx_t_7 = __pyx_pybuffer_index((&__pyx_v_self->view), __pyx_v_itemp, __pyx_t_6, __pyx_v_dim); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(1, 398, __pyx_L1_error) - __pyx_v_itemp = __pyx_t_7; - - /* "View.MemoryView":397 - * cdef char *itemp = self.view.buf - * - * for dim, idx in enumerate(index): # <<<<<<<<<<<<<< - * itemp = pybuffer_index(&self.view, itemp, idx, dim) - * - */ - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "View.MemoryView":400 - * itemp = pybuffer_index(&self.view, itemp, idx, dim) - * - * return itemp # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_itemp; - goto __pyx_L0; - - /* "View.MemoryView":393 - * PyThread_free_lock(self.lock) - * - * cdef char *get_item_pointer(memoryview self, object index) except NULL: # <<<<<<<<<<<<<< - * cdef Py_ssize_t dim - * cdef char *itemp = self.view.buf - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview.get_item_pointer", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_idx); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":403 - * - * - * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< - * if index is Ellipsis: - * return self - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ -static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { - PyObject *__pyx_v_have_slices = NULL; - PyObject *__pyx_v_indices = NULL; - char *__pyx_v_itemp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - char *__pyx_t_6; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__getitem__", 0); - - /* "View.MemoryView":404 - * - * def __getitem__(memoryview self, object index): - * if index is Ellipsis: # <<<<<<<<<<<<<< - * return self - * - */ - __pyx_t_1 = (__pyx_v_index == __pyx_builtin_Ellipsis); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":405 - * def __getitem__(memoryview self, object index): - * if index is Ellipsis: - * return self # <<<<<<<<<<<<<< - * - * have_slices, indices = _unellipsify(index, self.view.ndim) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __pyx_r = ((PyObject *)__pyx_v_self); - goto __pyx_L0; - - /* "View.MemoryView":404 - * - * def __getitem__(memoryview self, object index): - * if index is Ellipsis: # <<<<<<<<<<<<<< - * return self - * - */ - } - - /* "View.MemoryView":407 - * return self - * - * have_slices, indices = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< - * - * cdef char *itemp - */ - __pyx_t_3 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 407, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (likely(__pyx_t_3 != Py_None)) { - PyObject* sequence = __pyx_t_3; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(1, 407, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 407, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 407, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 407, __pyx_L1_error) - } - __pyx_v_have_slices = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_v_indices = __pyx_t_5; - __pyx_t_5 = 0; - - /* "View.MemoryView":410 - * - * cdef char *itemp - * if have_slices: # <<<<<<<<<<<<<< - * return memview_slice(self, indices) - * else: - */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 410, __pyx_L1_error) - if (__pyx_t_2) { - - /* "View.MemoryView":411 - * cdef char *itemp - * if have_slices: - * return memview_slice(self, indices) # <<<<<<<<<<<<<< - * else: - * itemp = self.get_item_pointer(indices) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = ((PyObject *)__pyx_memview_slice(__pyx_v_self, __pyx_v_indices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 411, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "View.MemoryView":410 - * - * cdef char *itemp - * if have_slices: # <<<<<<<<<<<<<< - * return memview_slice(self, indices) - * else: - */ - } - - /* "View.MemoryView":413 - * return memview_slice(self, indices) - * else: - * itemp = self.get_item_pointer(indices) # <<<<<<<<<<<<<< - * return self.convert_item_to_object(itemp) - * - */ - /*else*/ { - __pyx_t_6 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_indices); if (unlikely(__pyx_t_6 == ((char *)NULL))) __PYX_ERR(1, 413, __pyx_L1_error) - __pyx_v_itemp = __pyx_t_6; - - /* "View.MemoryView":414 - * else: - * itemp = self.get_item_pointer(indices) - * return self.convert_item_to_object(itemp) # <<<<<<<<<<<<<< - * - * def __setitem__(memoryview self, object index, object value): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->convert_item_to_object(__pyx_v_self, __pyx_v_itemp); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 414, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - } - - /* "View.MemoryView":403 - * - * - * def __getitem__(memoryview self, object index): # <<<<<<<<<<<<<< - * if index is Ellipsis: - * return self - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_have_slices); - __Pyx_XDECREF(__pyx_v_indices); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":416 - * return self.convert_item_to_object(itemp) - * - * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< - * if self.view.readonly: - * raise TypeError("Cannot assign to read-only memoryview") - */ - -/* Python wrapper */ -static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { - PyObject *__pyx_v_have_slices = NULL; - PyObject *__pyx_v_obj = NULL; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__setitem__", 0); - __Pyx_INCREF(__pyx_v_index); - - /* "View.MemoryView":417 - * - * def __setitem__(memoryview self, object index, object value): - * if self.view.readonly: # <<<<<<<<<<<<<< - * raise TypeError("Cannot assign to read-only memoryview") - * - */ - __pyx_t_1 = (__pyx_v_self->view.readonly != 0); - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":418 - * def __setitem__(memoryview self, object index, object value): - * if self.view.readonly: - * raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<< - * - * have_slices, index = _unellipsify(index, self.view.ndim) - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 418, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(1, 418, __pyx_L1_error) - - /* "View.MemoryView":417 - * - * def __setitem__(memoryview self, object index, object value): - * if self.view.readonly: # <<<<<<<<<<<<<< - * raise TypeError("Cannot assign to read-only memoryview") - * - */ - } - - /* "View.MemoryView":420 - * raise TypeError("Cannot assign to read-only memoryview") - * - * have_slices, index = _unellipsify(index, self.view.ndim) # <<<<<<<<<<<<<< - * - * if have_slices: - */ - __pyx_t_2 = _unellipsify(__pyx_v_index, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 420, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (likely(__pyx_t_2 != Py_None)) { - PyObject* sequence = __pyx_t_2; - Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(1, 420, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 420, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 420, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(1, 420, __pyx_L1_error) - } - __pyx_v_have_slices = __pyx_t_3; - __pyx_t_3 = 0; - __Pyx_DECREF_SET(__pyx_v_index, __pyx_t_4); - __pyx_t_4 = 0; - - /* "View.MemoryView":422 - * have_slices, index = _unellipsify(index, self.view.ndim) - * - * if have_slices: # <<<<<<<<<<<<<< - * obj = self.is_slice(value) - * if obj: - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_have_slices); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 422, __pyx_L1_error) - if (__pyx_t_1) { - - /* "View.MemoryView":423 - * - * if have_slices: - * obj = self.is_slice(value) # <<<<<<<<<<<<<< - * if obj: - * self.setitem_slice_assignment(self[index], obj) - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->is_slice(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 423, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_obj = __pyx_t_2; - __pyx_t_2 = 0; - - /* "View.MemoryView":424 - * if have_slices: - * obj = self.is_slice(value) - * if obj: # <<<<<<<<<<<<<< - * self.setitem_slice_assignment(self[index], obj) - * else: - */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_obj); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 424, __pyx_L1_error) - if (__pyx_t_1) { - - /* "View.MemoryView":425 - * obj = self.is_slice(value) - * if obj: - * self.setitem_slice_assignment(self[index], obj) # <<<<<<<<<<<<<< - * else: - * self.setitem_slice_assign_scalar(self[index], value) - */ - __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 425, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assignment(__pyx_v_self, __pyx_t_2, __pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 425, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "View.MemoryView":424 - * if have_slices: - * obj = self.is_slice(value) - * if obj: # <<<<<<<<<<<<<< - * self.setitem_slice_assignment(self[index], obj) - * else: - */ - goto __pyx_L5; - } - - /* "View.MemoryView":427 - * self.setitem_slice_assignment(self[index], obj) - * else: - * self.setitem_slice_assign_scalar(self[index], value) # <<<<<<<<<<<<<< - * else: - * self.setitem_indexed(index, value) - */ - /*else*/ { - __pyx_t_4 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_self), __pyx_v_index); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 427, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_memoryview_type))))) __PYX_ERR(1, 427, __pyx_L1_error) - __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_slice_assign_scalar(__pyx_v_self, ((struct __pyx_memoryview_obj *)__pyx_t_4), __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 427, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_L5:; - - /* "View.MemoryView":422 - * have_slices, index = _unellipsify(index, self.view.ndim) - * - * if have_slices: # <<<<<<<<<<<<<< - * obj = self.is_slice(value) - * if obj: - */ - goto __pyx_L4; - } - - /* "View.MemoryView":429 - * self.setitem_slice_assign_scalar(self[index], value) - * else: - * self.setitem_indexed(index, value) # <<<<<<<<<<<<<< - * - * cdef is_slice(self, obj): - */ - /*else*/ { - __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->setitem_indexed(__pyx_v_self, __pyx_v_index, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 429, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_L4:; - - /* "View.MemoryView":416 - * return self.convert_item_to_object(itemp) - * - * def __setitem__(memoryview self, object index, object value): # <<<<<<<<<<<<<< - * if self.view.readonly: - * raise TypeError("Cannot assign to read-only memoryview") - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("View.MemoryView.memoryview.__setitem__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_have_slices); - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XDECREF(__pyx_v_index); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":431 - * self.setitem_indexed(index, value) - * - * cdef is_slice(self, obj): # <<<<<<<<<<<<<< - * if not isinstance(obj, memoryview): - * try: - */ - -static PyObject *__pyx_memoryview_is_slice(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("is_slice", 0); - __Pyx_INCREF(__pyx_v_obj); - - /* "View.MemoryView":432 - * - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< - * try: - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - */ - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_obj, __pyx_memoryview_type); - __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":433 - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): - * try: # <<<<<<<<<<<<<< - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5); - __Pyx_XGOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_4); - __Pyx_XGOTREF(__pyx_t_5); - /*try:*/ { - - /* "View.MemoryView":434 - * if not isinstance(obj, memoryview): - * try: - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< - * self.dtype_is_object) - * except TypeError: - */ - __pyx_t_6 = __Pyx_PyInt_From_int(((__pyx_v_self->flags & (~PyBUF_WRITABLE)) | PyBUF_ANY_CONTIGUOUS)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 434, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_6); - - /* "View.MemoryView":435 - * try: - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) # <<<<<<<<<<<<<< - * except TypeError: - * return None - */ - __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_self->dtype_is_object); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 435, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_7); - - /* "View.MemoryView":434 - * if not isinstance(obj, memoryview): - * try: - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, # <<<<<<<<<<<<<< - * self.dtype_is_object) - * except TypeError: - */ - __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 434, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_v_obj); - __Pyx_GIVEREF(__pyx_v_obj); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_obj); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7); - __pyx_t_6 = 0; - __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 434, __pyx_L4_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF_SET(__pyx_v_obj, __pyx_t_7); - __pyx_t_7 = 0; - - /* "View.MemoryView":433 - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): - * try: # <<<<<<<<<<<<<< - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) - */ - } - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L9_try_end; - __pyx_L4_error:; - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - - /* "View.MemoryView":436 - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) - * except TypeError: # <<<<<<<<<<<<<< - * return None - * - */ - __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); - if (__pyx_t_9) { - __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_6) < 0) __PYX_ERR(1, 436, __pyx_L6_except_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GOTREF(__pyx_t_6); - - /* "View.MemoryView":437 - * self.dtype_is_object) - * except TypeError: - * return None # <<<<<<<<<<<<<< - * - * return obj - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L7_except_return; - } - goto __pyx_L6_except_error; - __pyx_L6_except_error:; - - /* "View.MemoryView":433 - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): - * try: # <<<<<<<<<<<<<< - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - * self.dtype_is_object) - */ - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_XGIVEREF(__pyx_t_5); - __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); - goto __pyx_L1_error; - __pyx_L7_except_return:; - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_XGIVEREF(__pyx_t_5); - __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); - goto __pyx_L0; - __pyx_L9_try_end:; - } - - /* "View.MemoryView":432 - * - * cdef is_slice(self, obj): - * if not isinstance(obj, memoryview): # <<<<<<<<<<<<<< - * try: - * obj = memoryview(obj, self.flags & ~PyBUF_WRITABLE | PyBUF_ANY_CONTIGUOUS, - */ - } - - /* "View.MemoryView":439 - * return None - * - * return obj # <<<<<<<<<<<<<< - * - * cdef setitem_slice_assignment(self, dst, src): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_obj); - __pyx_r = __pyx_v_obj; - goto __pyx_L0; - - /* "View.MemoryView":431 - * self.setitem_indexed(index, value) - * - * cdef is_slice(self, obj): # <<<<<<<<<<<<<< - * if not isinstance(obj, memoryview): - * try: - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("View.MemoryView.memoryview.is_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_obj); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":441 - * return obj - * - * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice dst_slice - * cdef __Pyx_memviewslice src_slice - */ - -static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_dst, PyObject *__pyx_v_src) { - __Pyx_memviewslice __pyx_v_dst_slice; - __Pyx_memviewslice __pyx_v_src_slice; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice *__pyx_t_1; - __Pyx_memviewslice *__pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("setitem_slice_assignment", 0); - - /* "View.MemoryView":445 - * cdef __Pyx_memviewslice src_slice - * - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< - * get_slice_from_memview(dst, &dst_slice)[0], - * src.ndim, dst.ndim, self.dtype_is_object) - */ - if (!(likely(((__pyx_v_src) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_src, __pyx_memoryview_type))))) __PYX_ERR(1, 445, __pyx_L1_error) - __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_src), (&__pyx_v_src_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 445, __pyx_L1_error) - - /* "View.MemoryView":446 - * - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], - * get_slice_from_memview(dst, &dst_slice)[0], # <<<<<<<<<<<<<< - * src.ndim, dst.ndim, self.dtype_is_object) - * - */ - if (!(likely(((__pyx_v_dst) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_dst, __pyx_memoryview_type))))) __PYX_ERR(1, 446, __pyx_L1_error) - __pyx_t_2 = __pyx_memoryview_get_slice_from_memoryview(((struct __pyx_memoryview_obj *)__pyx_v_dst), (&__pyx_v_dst_slice)); if (unlikely(__pyx_t_2 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 446, __pyx_L1_error) - - /* "View.MemoryView":447 - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], - * get_slice_from_memview(dst, &dst_slice)[0], - * src.ndim, dst.ndim, self.dtype_is_object) # <<<<<<<<<<<<<< - * - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): - */ - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_src, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_dst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 447, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(1, 447, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":445 - * cdef __Pyx_memviewslice src_slice - * - * memoryview_copy_contents(get_slice_from_memview(src, &src_slice)[0], # <<<<<<<<<<<<<< - * get_slice_from_memview(dst, &dst_slice)[0], - * src.ndim, dst.ndim, self.dtype_is_object) - */ - __pyx_t_6 = __pyx_memoryview_copy_contents((__pyx_t_1[0]), (__pyx_t_2[0]), __pyx_t_4, __pyx_t_5, __pyx_v_self->dtype_is_object); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 445, __pyx_L1_error) - - /* "View.MemoryView":441 - * return obj - * - * cdef setitem_slice_assignment(self, dst, src): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice dst_slice - * cdef __Pyx_memviewslice src_slice - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assignment", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":449 - * src.ndim, dst.ndim, self.dtype_is_object) - * - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< - * cdef int array[128] - * cdef void *tmp = NULL - */ - -static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) { - int __pyx_v_array[0x80]; - void *__pyx_v_tmp; - void *__pyx_v_item; - __Pyx_memviewslice *__pyx_v_dst_slice; - __Pyx_memviewslice __pyx_v_tmp_slice; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice *__pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_t_5; - char const *__pyx_t_6; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - PyObject *__pyx_t_12 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("setitem_slice_assign_scalar", 0); - - /* "View.MemoryView":451 - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): - * cdef int array[128] - * cdef void *tmp = NULL # <<<<<<<<<<<<<< - * cdef void *item - * - */ - __pyx_v_tmp = NULL; - - /* "View.MemoryView":456 - * cdef __Pyx_memviewslice *dst_slice - * cdef __Pyx_memviewslice tmp_slice - * dst_slice = get_slice_from_memview(dst, &tmp_slice) # <<<<<<<<<<<<<< - * - * if self.view.itemsize > sizeof(array): - */ - __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_dst, (&__pyx_v_tmp_slice)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 456, __pyx_L1_error) - __pyx_v_dst_slice = __pyx_t_1; - - /* "View.MemoryView":458 - * dst_slice = get_slice_from_memview(dst, &tmp_slice) - * - * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: - */ - __pyx_t_2 = ((((size_t)__pyx_v_self->view.itemsize) > (sizeof(__pyx_v_array))) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":459 - * - * if self.view.itemsize > sizeof(array): - * tmp = PyMem_Malloc(self.view.itemsize) # <<<<<<<<<<<<<< - * if tmp == NULL: - * raise MemoryError - */ - __pyx_v_tmp = PyMem_Malloc(__pyx_v_self->view.itemsize); - - /* "View.MemoryView":460 - * if self.view.itemsize > sizeof(array): - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: # <<<<<<<<<<<<<< - * raise MemoryError - * item = tmp - */ - __pyx_t_2 = ((__pyx_v_tmp == NULL) != 0); - if (unlikely(__pyx_t_2)) { - - /* "View.MemoryView":461 - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: - * raise MemoryError # <<<<<<<<<<<<<< - * item = tmp - * else: - */ - PyErr_NoMemory(); __PYX_ERR(1, 461, __pyx_L1_error) - - /* "View.MemoryView":460 - * if self.view.itemsize > sizeof(array): - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: # <<<<<<<<<<<<<< - * raise MemoryError - * item = tmp - */ - } - - /* "View.MemoryView":462 - * if tmp == NULL: - * raise MemoryError - * item = tmp # <<<<<<<<<<<<<< - * else: - * item = array - */ - __pyx_v_item = __pyx_v_tmp; - - /* "View.MemoryView":458 - * dst_slice = get_slice_from_memview(dst, &tmp_slice) - * - * if self.view.itemsize > sizeof(array): # <<<<<<<<<<<<<< - * tmp = PyMem_Malloc(self.view.itemsize) - * if tmp == NULL: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":464 - * item = tmp - * else: - * item = array # <<<<<<<<<<<<<< - * - * try: - */ - /*else*/ { - __pyx_v_item = ((void *)__pyx_v_array); - } - __pyx_L3:; - - /* "View.MemoryView":466 - * item = array - * - * try: # <<<<<<<<<<<<<< - * if self.dtype_is_object: - * ( item)[0] = value - */ - /*try:*/ { - - /* "View.MemoryView":467 - * - * try: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * ( item)[0] = value - * else: - */ - __pyx_t_2 = (__pyx_v_self->dtype_is_object != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":468 - * try: - * if self.dtype_is_object: - * ( item)[0] = value # <<<<<<<<<<<<<< - * else: - * self.assign_item_from_object( item, value) - */ - (((PyObject **)__pyx_v_item)[0]) = ((PyObject *)__pyx_v_value); - - /* "View.MemoryView":467 - * - * try: - * if self.dtype_is_object: # <<<<<<<<<<<<<< - * ( item)[0] = value - * else: - */ - goto __pyx_L8; - } - - /* "View.MemoryView":470 - * ( item)[0] = value - * else: - * self.assign_item_from_object( item, value) # <<<<<<<<<<<<<< - * - * - */ - /*else*/ { - __pyx_t_3 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, ((char *)__pyx_v_item), __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 470, __pyx_L6_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __pyx_L8:; - - /* "View.MemoryView":474 - * - * - * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, - */ - __pyx_t_2 = ((__pyx_v_self->view.suboffsets != NULL) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":475 - * - * if self.view.suboffsets != NULL: - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) # <<<<<<<<<<<<<< - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, - * item, self.dtype_is_object) - */ - __pyx_t_3 = assert_direct_dimensions(__pyx_v_self->view.suboffsets, __pyx_v_self->view.ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 475, __pyx_L6_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":474 - * - * - * if self.view.suboffsets != NULL: # <<<<<<<<<<<<<< - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, - */ - } - - /* "View.MemoryView":476 - * if self.view.suboffsets != NULL: - * assert_direct_dimensions(self.view.suboffsets, self.view.ndim) - * slice_assign_scalar(dst_slice, dst.view.ndim, self.view.itemsize, # <<<<<<<<<<<<<< - * item, self.dtype_is_object) - * finally: - */ - __pyx_memoryview_slice_assign_scalar(__pyx_v_dst_slice, __pyx_v_dst->view.ndim, __pyx_v_self->view.itemsize, __pyx_v_item, __pyx_v_self->dtype_is_object); - } - - /* "View.MemoryView":479 - * item, self.dtype_is_object) - * finally: - * PyMem_Free(tmp) # <<<<<<<<<<<<<< - * - * cdef setitem_indexed(self, index, value): - */ - /*finally:*/ { - /*normal exit:*/{ - PyMem_Free(__pyx_v_tmp); - goto __pyx_L7; - } - __pyx_L6_error:; - /*exception exit:*/{ - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12); - if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9); - __Pyx_XGOTREF(__pyx_t_7); - __Pyx_XGOTREF(__pyx_t_8); - __Pyx_XGOTREF(__pyx_t_9); - __Pyx_XGOTREF(__pyx_t_10); - __Pyx_XGOTREF(__pyx_t_11); - __Pyx_XGOTREF(__pyx_t_12); - __pyx_t_4 = __pyx_lineno; __pyx_t_5 = __pyx_clineno; __pyx_t_6 = __pyx_filename; - { - PyMem_Free(__pyx_v_tmp); - } - if (PY_MAJOR_VERSION >= 3) { - __Pyx_XGIVEREF(__pyx_t_10); - __Pyx_XGIVEREF(__pyx_t_11); - __Pyx_XGIVEREF(__pyx_t_12); - __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); - } - __Pyx_XGIVEREF(__pyx_t_7); - __Pyx_XGIVEREF(__pyx_t_8); - __Pyx_XGIVEREF(__pyx_t_9); - __Pyx_ErrRestore(__pyx_t_7, __pyx_t_8, __pyx_t_9); - __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; - __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_5; __pyx_filename = __pyx_t_6; - goto __pyx_L1_error; - } - __pyx_L7:; - } - - /* "View.MemoryView":449 - * src.ndim, dst.ndim, self.dtype_is_object) - * - * cdef setitem_slice_assign_scalar(self, memoryview dst, value): # <<<<<<<<<<<<<< - * cdef int array[128] - * cdef void *tmp = NULL - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_slice_assign_scalar", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":481 - * PyMem_Free(tmp) - * - * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< - * cdef char *itemp = self.get_item_pointer(index) - * self.assign_item_from_object(itemp, value) - */ - -static PyObject *__pyx_memoryview_setitem_indexed(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { - char *__pyx_v_itemp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - char *__pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("setitem_indexed", 0); - - /* "View.MemoryView":482 - * - * cdef setitem_indexed(self, index, value): - * cdef char *itemp = self.get_item_pointer(index) # <<<<<<<<<<<<<< - * self.assign_item_from_object(itemp, value) - * - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->get_item_pointer(__pyx_v_self, __pyx_v_index); if (unlikely(__pyx_t_1 == ((char *)NULL))) __PYX_ERR(1, 482, __pyx_L1_error) - __pyx_v_itemp = __pyx_t_1; - - /* "View.MemoryView":483 - * cdef setitem_indexed(self, index, value): - * cdef char *itemp = self.get_item_pointer(index) - * self.assign_item_from_object(itemp, value) # <<<<<<<<<<<<<< - * - * cdef convert_item_to_object(self, char *itemp): - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_memoryview *)__pyx_v_self->__pyx_vtab)->assign_item_from_object(__pyx_v_self, __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 483, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "View.MemoryView":481 - * PyMem_Free(tmp) - * - * cdef setitem_indexed(self, index, value): # <<<<<<<<<<<<<< - * cdef char *itemp = self.get_item_pointer(index) - * self.assign_item_from_object(itemp, value) - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.setitem_indexed", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":485 - * self.assign_item_from_object(itemp, value) - * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - */ - -static PyObject *__pyx_memoryview_convert_item_to_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp) { - PyObject *__pyx_v_struct = NULL; - PyObject *__pyx_v_bytesitem = 0; - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - size_t __pyx_t_10; - int __pyx_t_11; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("convert_item_to_object", 0); - - /* "View.MemoryView":488 - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - * import struct # <<<<<<<<<<<<<< - * cdef bytes bytesitem - * - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 488, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_struct = __pyx_t_1; - __pyx_t_1 = 0; - - /* "View.MemoryView":491 - * cdef bytes bytesitem - * - * bytesitem = itemp[:self.view.itemsize] # <<<<<<<<<<<<<< - * try: - * result = struct.unpack(self.view.format, bytesitem) - */ - __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_itemp + 0, __pyx_v_self->view.itemsize - 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 491, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_bytesitem = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "View.MemoryView":492 - * - * bytesitem = itemp[:self.view.itemsize] - * try: # <<<<<<<<<<<<<< - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - */ - { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); - __Pyx_XGOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_t_4); - /*try:*/ { - - /* "View.MemoryView":493 - * bytesitem = itemp[:self.view.itemsize] - * try: - * result = struct.unpack(self.view.format, bytesitem) # <<<<<<<<<<<<<< - * except struct.error: - * raise ValueError("Unable to convert item to object") - */ - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 493, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 493, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_6, __pyx_v_bytesitem}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 493, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_6); - __Pyx_INCREF(__pyx_v_bytesitem); - __Pyx_GIVEREF(__pyx_v_bytesitem); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_v_bytesitem); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 493, __pyx_L3_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_result = __pyx_t_1; - __pyx_t_1 = 0; - - /* "View.MemoryView":492 - * - * bytesitem = itemp[:self.view.itemsize] - * try: # <<<<<<<<<<<<<< - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - */ - } - - /* "View.MemoryView":497 - * raise ValueError("Unable to convert item to object") - * else: - * if len(self.view.format) == 1: # <<<<<<<<<<<<<< - * return result[0] - * return result - */ - /*else:*/ { - __pyx_t_10 = strlen(__pyx_v_self->view.format); - __pyx_t_11 = ((__pyx_t_10 == 1) != 0); - if (__pyx_t_11) { - - /* "View.MemoryView":498 - * else: - * if len(self.view.format) == 1: - * return result[0] # <<<<<<<<<<<<<< - * return result - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 498, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L6_except_return; - - /* "View.MemoryView":497 - * raise ValueError("Unable to convert item to object") - * else: - * if len(self.view.format) == 1: # <<<<<<<<<<<<<< - * return result[0] - * return result - */ - } - - /* "View.MemoryView":499 - * if len(self.view.format) == 1: - * return result[0] - * return result # <<<<<<<<<<<<<< - * - * cdef assign_item_from_object(self, char *itemp, object value): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_result); - __pyx_r = __pyx_v_result; - goto __pyx_L6_except_return; - } - __pyx_L3_error:; - __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "View.MemoryView":494 - * try: - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: # <<<<<<<<<<<<<< - * raise ValueError("Unable to convert item to object") - * else: - */ - __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_5, &__pyx_t_9); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 494, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_6); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_ErrRestore(__pyx_t_1, __pyx_t_5, __pyx_t_9); - __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_9 = 0; - if (__pyx_t_8) { - __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(1, 494, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_t_1); - - /* "View.MemoryView":495 - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< - * else: - * if len(self.view.format) == 1: - */ - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 495, __pyx_L5_except_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(1, 495, __pyx_L5_except_error) - } - goto __pyx_L5_except_error; - __pyx_L5_except_error:; - - /* "View.MemoryView":492 - * - * bytesitem = itemp[:self.view.itemsize] - * try: # <<<<<<<<<<<<<< - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - */ - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); - goto __pyx_L1_error; - __pyx_L6_except_return:; - __Pyx_XGIVEREF(__pyx_t_2); - __Pyx_XGIVEREF(__pyx_t_3); - __Pyx_XGIVEREF(__pyx_t_4); - __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); - goto __pyx_L0; - } - - /* "View.MemoryView":485 - * self.assign_item_from_object(itemp, value) - * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("View.MemoryView.memoryview.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_struct); - __Pyx_XDECREF(__pyx_v_bytesitem); - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":501 - * return result - * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - */ - -static PyObject *__pyx_memoryview_assign_item_from_object(struct __pyx_memoryview_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { - PyObject *__pyx_v_struct = NULL; - char __pyx_v_c; - PyObject *__pyx_v_bytesvalue = 0; - Py_ssize_t __pyx_v_i; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - Py_ssize_t __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - char *__pyx_t_11; - char *__pyx_t_12; - char *__pyx_t_13; - char *__pyx_t_14; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("assign_item_from_object", 0); - - /* "View.MemoryView":504 - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - * import struct # <<<<<<<<<<<<<< - * cdef char c - * cdef bytes bytesvalue - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 504, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_struct = __pyx_t_1; - __pyx_t_1 = 0; - - /* "View.MemoryView":509 - * cdef Py_ssize_t i - * - * if isinstance(value, tuple): # <<<<<<<<<<<<<< - * bytesvalue = struct.pack(self.view.format, *value) - * else: - */ - __pyx_t_2 = PyTuple_Check(__pyx_v_value); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "View.MemoryView":510 - * - * if isinstance(value, tuple): - * bytesvalue = struct.pack(self.view.format, *value) # <<<<<<<<<<<<<< - * else: - * bytesvalue = struct.pack(self.view.format, value) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 510, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 510, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 510, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 510, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 510, __pyx_L1_error) - __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); - __pyx_t_4 = 0; - - /* "View.MemoryView":509 - * cdef Py_ssize_t i - * - * if isinstance(value, tuple): # <<<<<<<<<<<<<< - * bytesvalue = struct.pack(self.view.format, *value) - * else: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":512 - * bytesvalue = struct.pack(self.view.format, *value) - * else: - * bytesvalue = struct.pack(self.view.format, value) # <<<<<<<<<<<<<< - * - * for i, c in enumerate(bytesvalue): - */ - /*else*/ { - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_struct, __pyx_n_s_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 512, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->view.format); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 512, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_1, __pyx_v_value}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 512, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_1); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 512, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) __PYX_ERR(1, 512, __pyx_L1_error) - __pyx_v_bytesvalue = ((PyObject*)__pyx_t_4); - __pyx_t_4 = 0; - } - __pyx_L3:; - - /* "View.MemoryView":514 - * bytesvalue = struct.pack(self.view.format, value) - * - * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< - * itemp[i] = c - * - */ - __pyx_t_9 = 0; - if (unlikely(__pyx_v_bytesvalue == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); - __PYX_ERR(1, 514, __pyx_L1_error) - } - __Pyx_INCREF(__pyx_v_bytesvalue); - __pyx_t_10 = __pyx_v_bytesvalue; - __pyx_t_12 = PyBytes_AS_STRING(__pyx_t_10); - __pyx_t_13 = (__pyx_t_12 + PyBytes_GET_SIZE(__pyx_t_10)); - for (__pyx_t_14 = __pyx_t_12; __pyx_t_14 < __pyx_t_13; __pyx_t_14++) { - __pyx_t_11 = __pyx_t_14; - __pyx_v_c = (__pyx_t_11[0]); - - /* "View.MemoryView":515 - * - * for i, c in enumerate(bytesvalue): - * itemp[i] = c # <<<<<<<<<<<<<< - * - * @cname('getbuffer') - */ - __pyx_v_i = __pyx_t_9; - - /* "View.MemoryView":514 - * bytesvalue = struct.pack(self.view.format, value) - * - * for i, c in enumerate(bytesvalue): # <<<<<<<<<<<<<< - * itemp[i] = c - * - */ - __pyx_t_9 = (__pyx_t_9 + 1); - - /* "View.MemoryView":515 - * - * for i, c in enumerate(bytesvalue): - * itemp[i] = c # <<<<<<<<<<<<<< - * - * @cname('getbuffer') - */ - (__pyx_v_itemp[__pyx_v_i]) = __pyx_v_c; - } - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - - /* "View.MemoryView":501 - * return result - * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * """Only used if instantiated manually by the user, or if Cython doesn't - * know how to convert the type""" - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_AddTraceback("View.MemoryView.memoryview.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_struct); - __Pyx_XDECREF(__pyx_v_bytesvalue); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":518 - * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * if flags & PyBUF_WRITABLE and self.view.readonly: - * raise ValueError("Cannot create writable memory view from read-only memoryview") - */ - -/* Python wrapper */ -static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ -static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - Py_ssize_t *__pyx_t_4; - char *__pyx_t_5; - void *__pyx_t_6; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - if (__pyx_v_info == NULL) { - PyErr_SetString(PyExc_BufferError, "PyObject_GetBuffer: view==NULL argument is obsolete"); - return -1; - } - __Pyx_RefNannySetupContext("__getbuffer__", 0); - __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(__pyx_v_info->obj); - - /* "View.MemoryView":519 - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<< - * raise ValueError("Cannot create writable memory view from read-only memoryview") - * - */ - __pyx_t_2 = ((__pyx_v_flags & PyBUF_WRITABLE) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_2 = (__pyx_v_self->view.readonly != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L4_bool_binop_done:; - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":520 - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_WRITABLE and self.view.readonly: - * raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<< - * - * if flags & PyBUF_ND: - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 520, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 520, __pyx_L1_error) - - /* "View.MemoryView":519 - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_WRITABLE and self.view.readonly: # <<<<<<<<<<<<<< - * raise ValueError("Cannot create writable memory view from read-only memoryview") - * - */ - } - - /* "View.MemoryView":522 - * raise ValueError("Cannot create writable memory view from read-only memoryview") - * - * if flags & PyBUF_ND: # <<<<<<<<<<<<<< - * info.shape = self.view.shape - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_ND) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":523 - * - * if flags & PyBUF_ND: - * info.shape = self.view.shape # <<<<<<<<<<<<<< - * else: - * info.shape = NULL - */ - __pyx_t_4 = __pyx_v_self->view.shape; - __pyx_v_info->shape = __pyx_t_4; - - /* "View.MemoryView":522 - * raise ValueError("Cannot create writable memory view from read-only memoryview") - * - * if flags & PyBUF_ND: # <<<<<<<<<<<<<< - * info.shape = self.view.shape - * else: - */ - goto __pyx_L6; - } - - /* "View.MemoryView":525 - * info.shape = self.view.shape - * else: - * info.shape = NULL # <<<<<<<<<<<<<< - * - * if flags & PyBUF_STRIDES: - */ - /*else*/ { - __pyx_v_info->shape = NULL; - } - __pyx_L6:; - - /* "View.MemoryView":527 - * info.shape = NULL - * - * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< - * info.strides = self.view.strides - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_STRIDES) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":528 - * - * if flags & PyBUF_STRIDES: - * info.strides = self.view.strides # <<<<<<<<<<<<<< - * else: - * info.strides = NULL - */ - __pyx_t_4 = __pyx_v_self->view.strides; - __pyx_v_info->strides = __pyx_t_4; - - /* "View.MemoryView":527 - * info.shape = NULL - * - * if flags & PyBUF_STRIDES: # <<<<<<<<<<<<<< - * info.strides = self.view.strides - * else: - */ - goto __pyx_L7; - } - - /* "View.MemoryView":530 - * info.strides = self.view.strides - * else: - * info.strides = NULL # <<<<<<<<<<<<<< - * - * if flags & PyBUF_INDIRECT: - */ - /*else*/ { - __pyx_v_info->strides = NULL; - } - __pyx_L7:; - - /* "View.MemoryView":532 - * info.strides = NULL - * - * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< - * info.suboffsets = self.view.suboffsets - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_INDIRECT) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":533 - * - * if flags & PyBUF_INDIRECT: - * info.suboffsets = self.view.suboffsets # <<<<<<<<<<<<<< - * else: - * info.suboffsets = NULL - */ - __pyx_t_4 = __pyx_v_self->view.suboffsets; - __pyx_v_info->suboffsets = __pyx_t_4; - - /* "View.MemoryView":532 - * info.strides = NULL - * - * if flags & PyBUF_INDIRECT: # <<<<<<<<<<<<<< - * info.suboffsets = self.view.suboffsets - * else: - */ - goto __pyx_L8; - } - - /* "View.MemoryView":535 - * info.suboffsets = self.view.suboffsets - * else: - * info.suboffsets = NULL # <<<<<<<<<<<<<< - * - * if flags & PyBUF_FORMAT: - */ - /*else*/ { - __pyx_v_info->suboffsets = NULL; - } - __pyx_L8:; - - /* "View.MemoryView":537 - * info.suboffsets = NULL - * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.view.format - * else: - */ - __pyx_t_1 = ((__pyx_v_flags & PyBUF_FORMAT) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":538 - * - * if flags & PyBUF_FORMAT: - * info.format = self.view.format # <<<<<<<<<<<<<< - * else: - * info.format = NULL - */ - __pyx_t_5 = __pyx_v_self->view.format; - __pyx_v_info->format = __pyx_t_5; - - /* "View.MemoryView":537 - * info.suboffsets = NULL - * - * if flags & PyBUF_FORMAT: # <<<<<<<<<<<<<< - * info.format = self.view.format - * else: - */ - goto __pyx_L9; - } - - /* "View.MemoryView":540 - * info.format = self.view.format - * else: - * info.format = NULL # <<<<<<<<<<<<<< - * - * info.buf = self.view.buf - */ - /*else*/ { - __pyx_v_info->format = NULL; - } - __pyx_L9:; - - /* "View.MemoryView":542 - * info.format = NULL - * - * info.buf = self.view.buf # <<<<<<<<<<<<<< - * info.ndim = self.view.ndim - * info.itemsize = self.view.itemsize - */ - __pyx_t_6 = __pyx_v_self->view.buf; - __pyx_v_info->buf = __pyx_t_6; - - /* "View.MemoryView":543 - * - * info.buf = self.view.buf - * info.ndim = self.view.ndim # <<<<<<<<<<<<<< - * info.itemsize = self.view.itemsize - * info.len = self.view.len - */ - __pyx_t_7 = __pyx_v_self->view.ndim; - __pyx_v_info->ndim = __pyx_t_7; - - /* "View.MemoryView":544 - * info.buf = self.view.buf - * info.ndim = self.view.ndim - * info.itemsize = self.view.itemsize # <<<<<<<<<<<<<< - * info.len = self.view.len - * info.readonly = self.view.readonly - */ - __pyx_t_8 = __pyx_v_self->view.itemsize; - __pyx_v_info->itemsize = __pyx_t_8; - - /* "View.MemoryView":545 - * info.ndim = self.view.ndim - * info.itemsize = self.view.itemsize - * info.len = self.view.len # <<<<<<<<<<<<<< - * info.readonly = self.view.readonly - * info.obj = self - */ - __pyx_t_8 = __pyx_v_self->view.len; - __pyx_v_info->len = __pyx_t_8; - - /* "View.MemoryView":546 - * info.itemsize = self.view.itemsize - * info.len = self.view.len - * info.readonly = self.view.readonly # <<<<<<<<<<<<<< - * info.obj = self - * - */ - __pyx_t_1 = __pyx_v_self->view.readonly; - __pyx_v_info->readonly = __pyx_t_1; - - /* "View.MemoryView":547 - * info.len = self.view.len - * info.readonly = self.view.readonly - * info.obj = self # <<<<<<<<<<<<<< - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") - */ - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); - __pyx_v_info->obj = ((PyObject *)__pyx_v_self); - - /* "View.MemoryView":518 - * - * @cname('getbuffer') - * def __getbuffer__(self, Py_buffer *info, int flags): # <<<<<<<<<<<<<< - * if flags & PyBUF_WRITABLE and self.view.readonly: - * raise ValueError("Cannot create writable memory view from read-only memoryview") - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - if (__pyx_v_info->obj != NULL) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; - } - goto __pyx_L2; - __pyx_L0:; - if (__pyx_v_info->obj == Py_None) { - __Pyx_GOTREF(__pyx_v_info->obj); - __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = 0; - } - __pyx_L2:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":553 - * - * @property - * def T(self): # <<<<<<<<<<<<<< - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":554 - * @property - * def T(self): - * cdef _memoryviewslice result = memoryview_copy(self) # <<<<<<<<<<<<<< - * transpose_memslice(&result.from_slice) - * return result - */ - __pyx_t_1 = __pyx_memoryview_copy_object(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 554, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_memoryviewslice_type))))) __PYX_ERR(1, 554, __pyx_L1_error) - __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "View.MemoryView":555 - * def T(self): - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) # <<<<<<<<<<<<<< - * return result - * - */ - __pyx_t_2 = __pyx_memslice_transpose((&__pyx_v_result->from_slice)); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 555, __pyx_L1_error) - - /* "View.MemoryView":556 - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) - * return result # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L0; - - /* "View.MemoryView":553 - * - * @property - * def T(self): # <<<<<<<<<<<<<< - * cdef _memoryviewslice result = memoryview_copy(self) - * transpose_memslice(&result.from_slice) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.T.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":559 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.obj - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":560 - * @property - * def base(self): - * return self.obj # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->obj); - __pyx_r = __pyx_v_self->obj; - goto __pyx_L0; - - /* "View.MemoryView":559 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.obj - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":563 - * - * @property - * def shape(self): # <<<<<<<<<<<<<< - * return tuple([length for length in self.view.shape[:self.view.ndim]]) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_length; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":564 - * @property - * def shape(self): - * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 564, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); - for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { - __pyx_t_2 = __pyx_t_4; - __pyx_v_length = (__pyx_t_2[0]); - __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(1, 564, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 564, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "View.MemoryView":563 - * - * @property - * def shape(self): # <<<<<<<<<<<<<< - * return tuple([length for length in self.view.shape[:self.view.ndim]]) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":567 - * - * @property - * def strides(self): # <<<<<<<<<<<<<< - * if self.view.strides == NULL: - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_stride; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - PyObject *__pyx_t_6 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":568 - * @property - * def strides(self): - * if self.view.strides == NULL: # <<<<<<<<<<<<<< - * - * raise ValueError("Buffer view does not expose strides") - */ - __pyx_t_1 = ((__pyx_v_self->view.strides == NULL) != 0); - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":570 - * if self.view.strides == NULL: - * - * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< - * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 570, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(1, 570, __pyx_L1_error) - - /* "View.MemoryView":568 - * @property - * def strides(self): - * if self.view.strides == NULL: # <<<<<<<<<<<<<< - * - * raise ValueError("Buffer view does not expose strides") - */ - } - - /* "View.MemoryView":572 - * raise ValueError("Buffer view does not expose strides") - * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 572, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim); - for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { - __pyx_t_3 = __pyx_t_5; - __pyx_v_stride = (__pyx_t_3[0]); - __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) __PYX_ERR(1, 572, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 572, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_6; - __pyx_t_6 = 0; - goto __pyx_L0; - - /* "View.MemoryView":567 - * - * @property - * def strides(self): # <<<<<<<<<<<<<< - * if self.view.strides == NULL: - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":575 - * - * @property - * def suboffsets(self): # <<<<<<<<<<<<<< - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_suboffset; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - Py_ssize_t *__pyx_t_6; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":576 - * @property - * def suboffsets(self): - * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< - * return (-1,) * self.view.ndim - * - */ - __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":577 - * def suboffsets(self): - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< - * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__12, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "View.MemoryView":576 - * @property - * def suboffsets(self): - * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< - * return (-1,) * self.view.ndim - * - */ - } - - /* "View.MemoryView":579 - * return (-1,) * self.view.ndim - * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 579, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim); - for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) { - __pyx_t_4 = __pyx_t_6; - __pyx_v_suboffset = (__pyx_t_4[0]); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(1, 579, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 579, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":575 - * - * @property - * def suboffsets(self): # <<<<<<<<<<<<<< - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":582 - * - * @property - * def ndim(self): # <<<<<<<<<<<<<< - * return self.view.ndim - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":583 - * @property - * def ndim(self): - * return self.view.ndim # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 583, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "View.MemoryView":582 - * - * @property - * def ndim(self): # <<<<<<<<<<<<<< - * return self.view.ndim - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.ndim.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":586 - * - * @property - * def itemsize(self): # <<<<<<<<<<<<<< - * return self.view.itemsize - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":587 - * @property - * def itemsize(self): - * return self.view.itemsize # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 587, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "View.MemoryView":586 - * - * @property - * def itemsize(self): # <<<<<<<<<<<<<< - * return self.view.itemsize - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.itemsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":590 - * - * @property - * def nbytes(self): # <<<<<<<<<<<<<< - * return self.size * self.view.itemsize - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":591 - * @property - * def nbytes(self): - * return self.size * self.view.itemsize # <<<<<<<<<<<<<< - * - * @property - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 591, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->view.itemsize); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 591, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 591, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "View.MemoryView":590 - * - * @property - * def nbytes(self): # <<<<<<<<<<<<<< - * return self.size * self.view.itemsize - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.nbytes.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":594 - * - * @property - * def size(self): # <<<<<<<<<<<<<< - * if self._size is None: - * result = 1 - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_v_length = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - PyObject *__pyx_t_6 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":595 - * @property - * def size(self): - * if self._size is None: # <<<<<<<<<<<<<< - * result = 1 - * - */ - __pyx_t_1 = (__pyx_v_self->_size == Py_None); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":596 - * def size(self): - * if self._size is None: - * result = 1 # <<<<<<<<<<<<<< - * - * for length in self.view.shape[:self.view.ndim]: - */ - __Pyx_INCREF(__pyx_int_1); - __pyx_v_result = __pyx_int_1; - - /* "View.MemoryView":598 - * result = 1 - * - * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<< - * result *= length - * - */ - __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); - for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { - __pyx_t_3 = __pyx_t_5; - __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 598, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6); - __pyx_t_6 = 0; - - /* "View.MemoryView":599 - * - * for length in self.view.shape[:self.view.ndim]: - * result *= length # <<<<<<<<<<<<<< - * - * self._size = result - */ - __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 599, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6); - __pyx_t_6 = 0; - } - - /* "View.MemoryView":601 - * result *= length - * - * self._size = result # <<<<<<<<<<<<<< - * - * return self._size - */ - __Pyx_INCREF(__pyx_v_result); - __Pyx_GIVEREF(__pyx_v_result); - __Pyx_GOTREF(__pyx_v_self->_size); - __Pyx_DECREF(__pyx_v_self->_size); - __pyx_v_self->_size = __pyx_v_result; - - /* "View.MemoryView":595 - * @property - * def size(self): - * if self._size is None: # <<<<<<<<<<<<<< - * result = 1 - * - */ - } - - /* "View.MemoryView":603 - * self._size = result - * - * return self._size # <<<<<<<<<<<<<< - * - * def __len__(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->_size); - __pyx_r = __pyx_v_self->_size; - goto __pyx_L0; - - /* "View.MemoryView":594 - * - * @property - * def size(self): # <<<<<<<<<<<<<< - * if self._size is None: - * result = 1 - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_length); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":605 - * return self._size - * - * def __len__(self): # <<<<<<<<<<<<<< - * if self.view.ndim >= 1: - * return self.view.shape[0] - */ - -/* Python wrapper */ -static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self); /*proto*/ -static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) { - Py_ssize_t __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__len__", 0); - - /* "View.MemoryView":606 - * - * def __len__(self): - * if self.view.ndim >= 1: # <<<<<<<<<<<<<< - * return self.view.shape[0] - * - */ - __pyx_t_1 = ((__pyx_v_self->view.ndim >= 1) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":607 - * def __len__(self): - * if self.view.ndim >= 1: - * return self.view.shape[0] # <<<<<<<<<<<<<< - * - * return 0 - */ - __pyx_r = (__pyx_v_self->view.shape[0]); - goto __pyx_L0; - - /* "View.MemoryView":606 - * - * def __len__(self): - * if self.view.ndim >= 1: # <<<<<<<<<<<<<< - * return self.view.shape[0] - * - */ - } - - /* "View.MemoryView":609 - * return self.view.shape[0] - * - * return 0 # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "View.MemoryView":605 - * return self._size - * - * def __len__(self): # <<<<<<<<<<<<<< - * if self.view.ndim >= 1: - * return self.view.shape[0] - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":611 - * return 0 - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__, - * id(self)) - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "View.MemoryView":612 - * - * def __repr__(self): - * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< - * id(self)) - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 612, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "View.MemoryView":613 - * def __repr__(self): - * return "" % (self.base.__class__.__name__, - * id(self)) # <<<<<<<<<<<<<< - * - * def __str__(self): - */ - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_id, ((PyObject *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 613, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - - /* "View.MemoryView":612 - * - * def __repr__(self): - * return "" % (self.base.__class__.__name__, # <<<<<<<<<<<<<< - * id(self)) - * - */ - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 612, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 612, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":611 - * return 0 - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__, - * id(self)) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":615 - * id(self)) - * - * def __str__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__,) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__str__", 0); - - /* "View.MemoryView":616 - * - * def __str__(self): - * return "" % (self.base.__class__.__name__,) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_class); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 616, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_MemoryView_of_r_object, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 616, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "View.MemoryView":615 - * id(self)) - * - * def __str__(self): # <<<<<<<<<<<<<< - * return "" % (self.base.__class__.__name__,) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":619 - * - * - * def is_c_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice *__pyx_v_mslice; - __Pyx_memviewslice __pyx_v_tmp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice *__pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("is_c_contig", 0); - - /* "View.MemoryView":622 - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< - * return slice_is_contig(mslice[0], 'C', self.view.ndim) - * - */ - __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 622, __pyx_L1_error) - __pyx_v_mslice = __pyx_t_1; - - /* "View.MemoryView":623 - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) - * return slice_is_contig(mslice[0], 'C', self.view.ndim) # <<<<<<<<<<<<<< - * - * def is_f_contig(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'C', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 623, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":619 - * - * - * def is_c_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.is_c_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":625 - * return slice_is_contig(mslice[0], 'C', self.view.ndim) - * - * def is_f_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice *__pyx_v_mslice; - __Pyx_memviewslice __pyx_v_tmp; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice *__pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("is_f_contig", 0); - - /* "View.MemoryView":628 - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) # <<<<<<<<<<<<<< - * return slice_is_contig(mslice[0], 'F', self.view.ndim) - * - */ - __pyx_t_1 = __pyx_memoryview_get_slice_from_memoryview(__pyx_v_self, (&__pyx_v_tmp)); if (unlikely(__pyx_t_1 == ((__Pyx_memviewslice *)NULL))) __PYX_ERR(1, 628, __pyx_L1_error) - __pyx_v_mslice = __pyx_t_1; - - /* "View.MemoryView":629 - * cdef __Pyx_memviewslice tmp - * mslice = get_slice_from_memview(self, &tmp) - * return slice_is_contig(mslice[0], 'F', self.view.ndim) # <<<<<<<<<<<<<< - * - * def copy(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_memviewslice_is_contig((__pyx_v_mslice[0]), 'F', __pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 629, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":625 - * return slice_is_contig(mslice[0], 'C', self.view.ndim) - * - * def is_f_contig(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice *mslice - * cdef __Pyx_memviewslice tmp - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.is_f_contig", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":631 - * return slice_is_contig(mslice[0], 'F', self.view.ndim) - * - * def copy(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice mslice - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("copy (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice __pyx_v_mslice; - int __pyx_v_flags; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("copy", 0); - - /* "View.MemoryView":633 - * def copy(self): - * cdef __Pyx_memviewslice mslice - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS # <<<<<<<<<<<<<< - * - * slice_copy(self, &mslice) - */ - __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_F_CONTIGUOUS)); - - /* "View.MemoryView":635 - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS - * - * slice_copy(self, &mslice) # <<<<<<<<<<<<<< - * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, - * self.view.itemsize, - */ - __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_mslice)); - - /* "View.MemoryView":636 - * - * slice_copy(self, &mslice) - * mslice = slice_copy_contig(&mslice, "c", self.view.ndim, # <<<<<<<<<<<<<< - * self.view.itemsize, - * flags|PyBUF_C_CONTIGUOUS, - */ - __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_mslice), ((char *)"c"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_C_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 636, __pyx_L1_error) - __pyx_v_mslice = __pyx_t_1; - - /* "View.MemoryView":641 - * self.dtype_is_object) - * - * return memoryview_copy_from_slice(self, &mslice) # <<<<<<<<<<<<<< - * - * def copy_fortran(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_mslice)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 641, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":631 - * return slice_is_contig(mslice[0], 'F', self.view.ndim) - * - * def copy(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice mslice - * cdef int flags = self.flags & ~PyBUF_F_CONTIGUOUS - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.copy", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":643 - * return memoryview_copy_from_slice(self, &mslice) - * - * def copy_fortran(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice src, dst - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS - */ - -/* Python wrapper */ -static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { - __Pyx_memviewslice __pyx_v_src; - __Pyx_memviewslice __pyx_v_dst; - int __pyx_v_flags; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_memviewslice __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("copy_fortran", 0); - - /* "View.MemoryView":645 - * def copy_fortran(self): - * cdef __Pyx_memviewslice src, dst - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS # <<<<<<<<<<<<<< - * - * slice_copy(self, &src) - */ - __pyx_v_flags = (__pyx_v_self->flags & (~PyBUF_C_CONTIGUOUS)); - - /* "View.MemoryView":647 - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS - * - * slice_copy(self, &src) # <<<<<<<<<<<<<< - * dst = slice_copy_contig(&src, "fortran", self.view.ndim, - * self.view.itemsize, - */ - __pyx_memoryview_slice_copy(__pyx_v_self, (&__pyx_v_src)); - - /* "View.MemoryView":648 - * - * slice_copy(self, &src) - * dst = slice_copy_contig(&src, "fortran", self.view.ndim, # <<<<<<<<<<<<<< - * self.view.itemsize, - * flags|PyBUF_F_CONTIGUOUS, - */ - __pyx_t_1 = __pyx_memoryview_copy_new_contig((&__pyx_v_src), ((char *)"fortran"), __pyx_v_self->view.ndim, __pyx_v_self->view.itemsize, (__pyx_v_flags | PyBUF_F_CONTIGUOUS), __pyx_v_self->dtype_is_object); if (unlikely(PyErr_Occurred())) __PYX_ERR(1, 648, __pyx_L1_error) - __pyx_v_dst = __pyx_t_1; - - /* "View.MemoryView":653 - * self.dtype_is_object) - * - * return memoryview_copy_from_slice(self, &dst) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_copy_object_from_slice(__pyx_v_self, (&__pyx_v_dst)); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 653, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":643 - * return memoryview_copy_from_slice(self, &mslice) - * - * def copy_fortran(self): # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice src, dst - * cdef int flags = self.flags & ~PyBUF_C_CONTIGUOUS - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView.memoryview.copy_fortran", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw___pyx_memoryview_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_memoryview___reduce_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_memoryview___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw___pyx_memoryview_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_memoryview_2__setstate_cython__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_memoryview_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryview_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":657 - * - * @cname('__pyx_memoryview_new') - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo - */ - -static PyObject *__pyx_memoryview_new(PyObject *__pyx_v_o, int __pyx_v_flags, int __pyx_v_dtype_is_object, __Pyx_TypeInfo *__pyx_v_typeinfo) { - struct __pyx_memoryview_obj *__pyx_v_result = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("memoryview_cwrapper", 0); - - /* "View.MemoryView":658 - * @cname('__pyx_memoryview_new') - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): - * cdef memoryview result = memoryview(o, flags, dtype_is_object) # <<<<<<<<<<<<<< - * result.typeinfo = typeinfo - * return result - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 658, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 658, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_o); - __Pyx_GIVEREF(__pyx_v_o); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryview_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 658, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result = ((struct __pyx_memoryview_obj *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":659 - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo # <<<<<<<<<<<<<< - * return result - * - */ - __pyx_v_result->typeinfo = __pyx_v_typeinfo; - - /* "View.MemoryView":660 - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo - * return result # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_check') - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L0; - - /* "View.MemoryView":657 - * - * @cname('__pyx_memoryview_new') - * cdef memoryview_cwrapper(object o, int flags, bint dtype_is_object, __Pyx_TypeInfo *typeinfo): # <<<<<<<<<<<<<< - * cdef memoryview result = memoryview(o, flags, dtype_is_object) - * result.typeinfo = typeinfo - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview_cwrapper", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":663 - * - * @cname('__pyx_memoryview_check') - * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< - * return isinstance(o, memoryview) - * - */ - -static CYTHON_INLINE int __pyx_memoryview_check(PyObject *__pyx_v_o) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("memoryview_check", 0); - - /* "View.MemoryView":664 - * @cname('__pyx_memoryview_check') - * cdef inline bint memoryview_check(object o): - * return isinstance(o, memoryview) # <<<<<<<<<<<<<< - * - * cdef tuple _unellipsify(object index, int ndim): - */ - __pyx_t_1 = __Pyx_TypeCheck(__pyx_v_o, __pyx_memoryview_type); - __pyx_r = __pyx_t_1; - goto __pyx_L0; - - /* "View.MemoryView":663 - * - * @cname('__pyx_memoryview_check') - * cdef inline bint memoryview_check(object o): # <<<<<<<<<<<<<< - * return isinstance(o, memoryview) - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":666 - * return isinstance(o, memoryview) - * - * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< - * """ - * Replace all ellipses with full slices and fill incomplete indices with - */ - -static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { - PyObject *__pyx_v_tup = NULL; - PyObject *__pyx_v_result = NULL; - int __pyx_v_have_slices; - int __pyx_v_seen_ellipsis; - CYTHON_UNUSED PyObject *__pyx_v_idx = NULL; - PyObject *__pyx_v_item = NULL; - Py_ssize_t __pyx_v_nslices; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; - PyObject *(*__pyx_t_6)(PyObject *); - PyObject *__pyx_t_7 = NULL; - Py_ssize_t __pyx_t_8; - int __pyx_t_9; - int __pyx_t_10; - PyObject *__pyx_t_11 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("_unellipsify", 0); - - /* "View.MemoryView":671 - * full slices. - * """ - * if not isinstance(index, tuple): # <<<<<<<<<<<<<< - * tup = (index,) - * else: - */ - __pyx_t_1 = PyTuple_Check(__pyx_v_index); - __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":672 - * """ - * if not isinstance(index, tuple): - * tup = (index,) # <<<<<<<<<<<<<< - * else: - * tup = index - */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 672, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_index); - __Pyx_GIVEREF(__pyx_v_index); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_index); - __pyx_v_tup = __pyx_t_3; - __pyx_t_3 = 0; - - /* "View.MemoryView":671 - * full slices. - * """ - * if not isinstance(index, tuple): # <<<<<<<<<<<<<< - * tup = (index,) - * else: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":674 - * tup = (index,) - * else: - * tup = index # <<<<<<<<<<<<<< - * - * result = [] - */ - /*else*/ { - __Pyx_INCREF(__pyx_v_index); - __pyx_v_tup = __pyx_v_index; - } - __pyx_L3:; - - /* "View.MemoryView":676 - * tup = index - * - * result = [] # <<<<<<<<<<<<<< - * have_slices = False - * seen_ellipsis = False - */ - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 676, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_v_result = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - - /* "View.MemoryView":677 - * - * result = [] - * have_slices = False # <<<<<<<<<<<<<< - * seen_ellipsis = False - * for idx, item in enumerate(tup): - */ - __pyx_v_have_slices = 0; - - /* "View.MemoryView":678 - * result = [] - * have_slices = False - * seen_ellipsis = False # <<<<<<<<<<<<<< - * for idx, item in enumerate(tup): - * if item is Ellipsis: - */ - __pyx_v_seen_ellipsis = 0; - - /* "View.MemoryView":679 - * have_slices = False - * seen_ellipsis = False - * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< - * if item is Ellipsis: - * if not seen_ellipsis: - */ - __Pyx_INCREF(__pyx_int_0); - __pyx_t_3 = __pyx_int_0; - if (likely(PyList_CheckExact(__pyx_v_tup)) || PyTuple_CheckExact(__pyx_v_tup)) { - __pyx_t_4 = __pyx_v_tup; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; - __pyx_t_6 = NULL; - } else { - __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_tup); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 679, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 679, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_6)) { - if (likely(PyList_CheckExact(__pyx_t_4))) { - if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error) - #else - __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - } else { - if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(1, 679, __pyx_L1_error) - #else - __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - } - } else { - __pyx_t_7 = __pyx_t_6(__pyx_t_4); - if (unlikely(!__pyx_t_7)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(1, 679, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_7); - } - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_7); - __pyx_t_7 = 0; - __Pyx_INCREF(__pyx_t_3); - __Pyx_XDECREF_SET(__pyx_v_idx, __pyx_t_3); - __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 679, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); - __pyx_t_3 = __pyx_t_7; - __pyx_t_7 = 0; - - /* "View.MemoryView":680 - * seen_ellipsis = False - * for idx, item in enumerate(tup): - * if item is Ellipsis: # <<<<<<<<<<<<<< - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - */ - __pyx_t_2 = (__pyx_v_item == __pyx_builtin_Ellipsis); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":681 - * for idx, item in enumerate(tup): - * if item is Ellipsis: - * if not seen_ellipsis: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - * seen_ellipsis = True - */ - __pyx_t_1 = ((!(__pyx_v_seen_ellipsis != 0)) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":682 - * if item is Ellipsis: - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< - * seen_ellipsis = True - * else: - */ - __pyx_t_8 = PyObject_Length(__pyx_v_tup); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(1, 682, __pyx_L1_error) - __pyx_t_7 = PyList_New(1 * ((((__pyx_v_ndim - __pyx_t_8) + 1)<0) ? 0:((__pyx_v_ndim - __pyx_t_8) + 1))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - { Py_ssize_t __pyx_temp; - for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__15); - __Pyx_GIVEREF(__pyx_slice__15); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__15); - } - } - __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 682, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - - /* "View.MemoryView":683 - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - * seen_ellipsis = True # <<<<<<<<<<<<<< - * else: - * result.append(slice(None)) - */ - __pyx_v_seen_ellipsis = 1; - - /* "View.MemoryView":681 - * for idx, item in enumerate(tup): - * if item is Ellipsis: - * if not seen_ellipsis: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - * seen_ellipsis = True - */ - goto __pyx_L7; - } - - /* "View.MemoryView":685 - * seen_ellipsis = True - * else: - * result.append(slice(None)) # <<<<<<<<<<<<<< - * have_slices = True - * else: - */ - /*else*/ { - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__15); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 685, __pyx_L1_error) - } - __pyx_L7:; - - /* "View.MemoryView":686 - * else: - * result.append(slice(None)) - * have_slices = True # <<<<<<<<<<<<<< - * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): - */ - __pyx_v_have_slices = 1; - - /* "View.MemoryView":680 - * seen_ellipsis = False - * for idx, item in enumerate(tup): - * if item is Ellipsis: # <<<<<<<<<<<<<< - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) - */ - goto __pyx_L6; - } - - /* "View.MemoryView":688 - * have_slices = True - * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< - * raise TypeError("Cannot index with type '%s'" % type(item)) - * - */ - /*else*/ { - __pyx_t_2 = PySlice_Check(__pyx_v_item); - __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0); - if (__pyx_t_10) { - } else { - __pyx_t_1 = __pyx_t_10; - goto __pyx_L9_bool_binop_done; - } - __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0); - __pyx_t_1 = __pyx_t_10; - __pyx_L9_bool_binop_done:; - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":689 - * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): - * raise TypeError("Cannot index with type '%s'" % type(item)) # <<<<<<<<<<<<<< - * - * have_slices = have_slices or isinstance(item, slice) - */ - __pyx_t_7 = __Pyx_PyString_FormatSafe(__pyx_kp_s_Cannot_index_with_type_s, ((PyObject *)Py_TYPE(__pyx_v_item))); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 689, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_Raise(__pyx_t_11, 0, 0, 0); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __PYX_ERR(1, 689, __pyx_L1_error) - - /* "View.MemoryView":688 - * have_slices = True - * else: - * if not isinstance(item, slice) and not PyIndex_Check(item): # <<<<<<<<<<<<<< - * raise TypeError("Cannot index with type '%s'" % type(item)) - * - */ - } - - /* "View.MemoryView":691 - * raise TypeError("Cannot index with type '%s'" % type(item)) - * - * have_slices = have_slices or isinstance(item, slice) # <<<<<<<<<<<<<< - * result.append(item) - * - */ - __pyx_t_10 = (__pyx_v_have_slices != 0); - if (!__pyx_t_10) { - } else { - __pyx_t_1 = __pyx_t_10; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_10 = PySlice_Check(__pyx_v_item); - __pyx_t_2 = (__pyx_t_10 != 0); - __pyx_t_1 = __pyx_t_2; - __pyx_L11_bool_binop_done:; - __pyx_v_have_slices = __pyx_t_1; - - /* "View.MemoryView":692 - * - * have_slices = have_slices or isinstance(item, slice) - * result.append(item) # <<<<<<<<<<<<<< - * - * nslices = ndim - len(result) - */ - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 692, __pyx_L1_error) - } - __pyx_L6:; - - /* "View.MemoryView":679 - * have_slices = False - * seen_ellipsis = False - * for idx, item in enumerate(tup): # <<<<<<<<<<<<<< - * if item is Ellipsis: - * if not seen_ellipsis: - */ - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":694 - * result.append(item) - * - * nslices = ndim - len(result) # <<<<<<<<<<<<<< - * if nslices: - * result.extend([slice(None)] * nslices) - */ - __pyx_t_5 = PyList_GET_SIZE(__pyx_v_result); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 694, __pyx_L1_error) - __pyx_v_nslices = (__pyx_v_ndim - __pyx_t_5); - - /* "View.MemoryView":695 - * - * nslices = ndim - len(result) - * if nslices: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * nslices) - * - */ - __pyx_t_1 = (__pyx_v_nslices != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":696 - * nslices = ndim - len(result) - * if nslices: - * result.extend([slice(None)] * nslices) # <<<<<<<<<<<<<< - * - * return have_slices or nslices, tuple(result) - */ - __pyx_t_3 = PyList_New(1 * ((__pyx_v_nslices<0) ? 0:__pyx_v_nslices)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 696, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - { Py_ssize_t __pyx_temp; - for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__15); - __Pyx_GIVEREF(__pyx_slice__15); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__15); - } - } - __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 696, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":695 - * - * nslices = ndim - len(result) - * if nslices: # <<<<<<<<<<<<<< - * result.extend([slice(None)] * nslices) - * - */ - } - - /* "View.MemoryView":698 - * result.extend([slice(None)] * nslices) - * - * return have_slices or nslices, tuple(result) # <<<<<<<<<<<<<< - * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - */ - __Pyx_XDECREF(__pyx_r); - if (!__pyx_v_have_slices) { - } else { - __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L14_bool_binop_done; - } - __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_L14_bool_binop_done:; - __pyx_t_4 = PyList_AsTuple(__pyx_v_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(1, 698, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_4); - __pyx_t_3 = 0; - __pyx_t_4 = 0; - __pyx_r = ((PyObject*)__pyx_t_11); - __pyx_t_11 = 0; - goto __pyx_L0; - - /* "View.MemoryView":666 - * return isinstance(o, memoryview) - * - * cdef tuple _unellipsify(object index, int ndim): # <<<<<<<<<<<<<< - * """ - * Replace all ellipses with full slices and fill incomplete indices with - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("View.MemoryView._unellipsify", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_tup); - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_idx); - __Pyx_XDECREF(__pyx_v_item); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":700 - * return have_slices or nslices, tuple(result) - * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: - */ - -static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) { - Py_ssize_t __pyx_v_suboffset; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - Py_ssize_t *__pyx_t_1; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("assert_direct_dimensions", 0); - - /* "View.MemoryView":701 - * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<< - * if suboffset >= 0: - * raise ValueError("Indirect dimensions not supported") - */ - __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim); - for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) { - __pyx_t_1 = __pyx_t_3; - __pyx_v_suboffset = (__pyx_t_1[0]); - - /* "View.MemoryView":702 - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * raise ValueError("Indirect dimensions not supported") - * - */ - __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0); - if (unlikely(__pyx_t_4)) { - - /* "View.MemoryView":703 - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: - * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __PYX_ERR(1, 703, __pyx_L1_error) - - /* "View.MemoryView":702 - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * raise ValueError("Indirect dimensions not supported") - * - */ - } - } - - /* "View.MemoryView":700 - * return have_slices or nslices, tuple(result) - * - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":710 - * - * @cname('__pyx_memview_slice') - * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< - * cdef int new_ndim = 0, suboffset_dim = -1, dim - * cdef bint negative_step - */ - -static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_obj *__pyx_v_memview, PyObject *__pyx_v_indices) { - int __pyx_v_new_ndim; - int __pyx_v_suboffset_dim; - int __pyx_v_dim; - __Pyx_memviewslice __pyx_v_src; - __Pyx_memviewslice __pyx_v_dst; - __Pyx_memviewslice *__pyx_v_p_src; - struct __pyx_memoryviewslice_obj *__pyx_v_memviewsliceobj = 0; - __Pyx_memviewslice *__pyx_v_p_dst; - int *__pyx_v_p_suboffset_dim; - Py_ssize_t __pyx_v_start; - Py_ssize_t __pyx_v_stop; - Py_ssize_t __pyx_v_step; - int __pyx_v_have_start; - int __pyx_v_have_stop; - int __pyx_v_have_step; - PyObject *__pyx_v_index = NULL; - struct __pyx_memoryview_obj *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - struct __pyx_memoryview_obj *__pyx_t_4; - char *__pyx_t_5; - int __pyx_t_6; - Py_ssize_t __pyx_t_7; - PyObject *(*__pyx_t_8)(PyObject *); - PyObject *__pyx_t_9 = NULL; - Py_ssize_t __pyx_t_10; - int __pyx_t_11; - Py_ssize_t __pyx_t_12; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("memview_slice", 0); - - /* "View.MemoryView":711 - * @cname('__pyx_memview_slice') - * cdef memoryview memview_slice(memoryview memview, object indices): - * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<< - * cdef bint negative_step - * cdef __Pyx_memviewslice src, dst - */ - __pyx_v_new_ndim = 0; - __pyx_v_suboffset_dim = -1; - - /* "View.MemoryView":718 - * - * - * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<< - * - * cdef _memoryviewslice memviewsliceobj - */ - (void)(memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst)))); - - /* "View.MemoryView":722 - * cdef _memoryviewslice memviewsliceobj - * - * assert memview.view.ndim > 0 # <<<<<<<<<<<<<< - * - * if isinstance(memview, _memoryviewslice): - */ - #ifndef CYTHON_WITHOUT_ASSERTIONS - if (unlikely(!Py_OptimizeFlag)) { - if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) { - PyErr_SetNone(PyExc_AssertionError); - __PYX_ERR(1, 722, __pyx_L1_error) - } - } - #endif - - /* "View.MemoryView":724 - * assert memview.view.ndim > 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * memviewsliceobj = memview - * p_src = &memviewsliceobj.from_slice - */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":725 - * - * if isinstance(memview, _memoryviewslice): - * memviewsliceobj = memview # <<<<<<<<<<<<<< - * p_src = &memviewsliceobj.from_slice - * else: - */ - if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 725, __pyx_L1_error) - __pyx_t_3 = ((PyObject *)__pyx_v_memview); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "View.MemoryView":726 - * if isinstance(memview, _memoryviewslice): - * memviewsliceobj = memview - * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<< - * else: - * slice_copy(memview, &src) - */ - __pyx_v_p_src = (&__pyx_v_memviewsliceobj->from_slice); - - /* "View.MemoryView":724 - * assert memview.view.ndim > 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * memviewsliceobj = memview - * p_src = &memviewsliceobj.from_slice - */ - goto __pyx_L3; - } - - /* "View.MemoryView":728 - * p_src = &memviewsliceobj.from_slice - * else: - * slice_copy(memview, &src) # <<<<<<<<<<<<<< - * p_src = &src - * - */ - /*else*/ { - __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src)); - - /* "View.MemoryView":729 - * else: - * slice_copy(memview, &src) - * p_src = &src # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_p_src = (&__pyx_v_src); - } - __pyx_L3:; - - /* "View.MemoryView":735 - * - * - * dst.memview = p_src.memview # <<<<<<<<<<<<<< - * dst.data = p_src.data - * - */ - __pyx_t_4 = __pyx_v_p_src->memview; - __pyx_v_dst.memview = __pyx_t_4; - - /* "View.MemoryView":736 - * - * dst.memview = p_src.memview - * dst.data = p_src.data # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_5 = __pyx_v_p_src->data; - __pyx_v_dst.data = __pyx_t_5; - - /* "View.MemoryView":741 - * - * - * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<< - * cdef int *p_suboffset_dim = &suboffset_dim - * cdef Py_ssize_t start, stop, step - */ - __pyx_v_p_dst = (&__pyx_v_dst); - - /* "View.MemoryView":742 - * - * cdef __Pyx_memviewslice *p_dst = &dst - * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<< - * cdef Py_ssize_t start, stop, step - * cdef bint have_start, have_stop, have_step - */ - __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim); - - /* "View.MemoryView":746 - * cdef bint have_start, have_stop, have_step - * - * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< - * if PyIndex_Check(index): - * slice_memviewslice( - */ - __pyx_t_6 = 0; - if (likely(PyList_CheckExact(__pyx_v_indices)) || PyTuple_CheckExact(__pyx_v_indices)) { - __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; - __pyx_t_8 = NULL; - } else { - __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 746, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 746, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_8)) { - if (likely(PyList_CheckExact(__pyx_t_3))) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error) - #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - #endif - } else { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(1, 746, __pyx_L1_error) - #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 746, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - #endif - } - } else { - __pyx_t_9 = __pyx_t_8(__pyx_t_3); - if (unlikely(!__pyx_t_9)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(1, 746, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_9); - } - __Pyx_XDECREF_SET(__pyx_v_index, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_v_dim = __pyx_t_6; - __pyx_t_6 = (__pyx_t_6 + 1); - - /* "View.MemoryView":747 - * - * for dim, index in enumerate(indices): - * if PyIndex_Check(index): # <<<<<<<<<<<<<< - * slice_memviewslice( - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - */ - __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":751 - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - * dim, new_ndim, p_suboffset_dim, - * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<< - * 0, 0, 0, # have_{start,stop,step} - * False) - */ - __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 751, __pyx_L1_error) - - /* "View.MemoryView":748 - * for dim, index in enumerate(indices): - * if PyIndex_Check(index): - * slice_memviewslice( # <<<<<<<<<<<<<< - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - * dim, new_ndim, p_suboffset_dim, - */ - __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 748, __pyx_L1_error) - - /* "View.MemoryView":747 - * - * for dim, index in enumerate(indices): - * if PyIndex_Check(index): # <<<<<<<<<<<<<< - * slice_memviewslice( - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - */ - goto __pyx_L6; - } - - /* "View.MemoryView":754 - * 0, 0, 0, # have_{start,stop,step} - * False) - * elif index is None: # <<<<<<<<<<<<<< - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 - */ - __pyx_t_2 = (__pyx_v_index == Py_None); - __pyx_t_1 = (__pyx_t_2 != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":755 - * False) - * elif index is None: - * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<< - * p_dst.strides[new_ndim] = 0 - * p_dst.suboffsets[new_ndim] = -1 - */ - (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1; - - /* "View.MemoryView":756 - * elif index is None: - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<< - * p_dst.suboffsets[new_ndim] = -1 - * new_ndim += 1 - */ - (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0; - - /* "View.MemoryView":757 - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 - * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<< - * new_ndim += 1 - * else: - */ - (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L; - - /* "View.MemoryView":758 - * p_dst.strides[new_ndim] = 0 - * p_dst.suboffsets[new_ndim] = -1 - * new_ndim += 1 # <<<<<<<<<<<<<< - * else: - * start = index.start or 0 - */ - __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); - - /* "View.MemoryView":754 - * 0, 0, 0, # have_{start,stop,step} - * False) - * elif index is None: # <<<<<<<<<<<<<< - * p_dst.shape[new_ndim] = 1 - * p_dst.strides[new_ndim] = 0 - */ - goto __pyx_L6; - } - - /* "View.MemoryView":760 - * new_ndim += 1 - * else: - * start = index.start or 0 # <<<<<<<<<<<<<< - * stop = index.stop or 0 - * step = index.step or 0 - */ - /*else*/ { - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 760, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 760, __pyx_L1_error) - if (!__pyx_t_1) { - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 760, __pyx_L1_error) - __pyx_t_10 = __pyx_t_12; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L7_bool_binop_done; - } - __pyx_t_10 = 0; - __pyx_L7_bool_binop_done:; - __pyx_v_start = __pyx_t_10; - - /* "View.MemoryView":761 - * else: - * start = index.start or 0 - * stop = index.stop or 0 # <<<<<<<<<<<<<< - * step = index.step or 0 - * - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 761, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 761, __pyx_L1_error) - if (!__pyx_t_1) { - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 761, __pyx_L1_error) - __pyx_t_10 = __pyx_t_12; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L9_bool_binop_done; - } - __pyx_t_10 = 0; - __pyx_L9_bool_binop_done:; - __pyx_v_stop = __pyx_t_10; - - /* "View.MemoryView":762 - * start = index.start or 0 - * stop = index.stop or 0 - * step = index.step or 0 # <<<<<<<<<<<<<< - * - * have_start = index.start is not None - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 762, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(1, 762, __pyx_L1_error) - if (!__pyx_t_1) { - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 762, __pyx_L1_error) - __pyx_t_10 = __pyx_t_12; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_10 = 0; - __pyx_L11_bool_binop_done:; - __pyx_v_step = __pyx_t_10; - - /* "View.MemoryView":764 - * step = index.step or 0 - * - * have_start = index.start is not None # <<<<<<<<<<<<<< - * have_stop = index.stop is not None - * have_step = index.step is not None - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 764, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_have_start = __pyx_t_1; - - /* "View.MemoryView":765 - * - * have_start = index.start is not None - * have_stop = index.stop is not None # <<<<<<<<<<<<<< - * have_step = index.step is not None - * - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 765, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_have_stop = __pyx_t_1; - - /* "View.MemoryView":766 - * have_start = index.start is not None - * have_stop = index.stop is not None - * have_step = index.step is not None # <<<<<<<<<<<<<< - * - * slice_memviewslice( - */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 766, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_have_step = __pyx_t_1; - - /* "View.MemoryView":768 - * have_step = index.step is not None - * - * slice_memviewslice( # <<<<<<<<<<<<<< - * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], - * dim, new_ndim, p_suboffset_dim, - */ - __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(1, 768, __pyx_L1_error) - - /* "View.MemoryView":774 - * have_start, have_stop, have_step, - * True) - * new_ndim += 1 # <<<<<<<<<<<<<< - * - * if isinstance(memview, _memoryviewslice): - */ - __pyx_v_new_ndim = (__pyx_v_new_ndim + 1); - } - __pyx_L6:; - - /* "View.MemoryView":746 - * cdef bint have_start, have_stop, have_step - * - * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< - * if PyIndex_Check(index): - * slice_memviewslice( - */ - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "View.MemoryView":776 - * new_ndim += 1 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, - */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":777 - * - * if isinstance(memview, _memoryviewslice): - * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< - * memviewsliceobj.to_object_func, - * memviewsliceobj.to_dtype_func, - */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - - /* "View.MemoryView":778 - * if isinstance(memview, _memoryviewslice): - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<< - * memviewsliceobj.to_dtype_func, - * memview.dtype_is_object) - */ - if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 778, __pyx_L1_error) } - - /* "View.MemoryView":779 - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, - * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<< - * memview.dtype_is_object) - * else: - */ - if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); __PYX_ERR(1, 779, __pyx_L1_error) } - - /* "View.MemoryView":777 - * - * if isinstance(memview, _memoryviewslice): - * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< - * memviewsliceobj.to_object_func, - * memviewsliceobj.to_dtype_func, - */ - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 777, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 777, __pyx_L1_error) - __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "View.MemoryView":776 - * new_ndim += 1 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * return memoryview_fromslice(dst, new_ndim, - * memviewsliceobj.to_object_func, - */ - } - - /* "View.MemoryView":782 - * memview.dtype_is_object) - * else: - * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< - * memview.dtype_is_object) - * - */ - /*else*/ { - __Pyx_XDECREF(((PyObject *)__pyx_r)); - - /* "View.MemoryView":783 - * else: - * return memoryview_fromslice(dst, new_ndim, NULL, NULL, - * memview.dtype_is_object) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 782, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - - /* "View.MemoryView":782 - * memview.dtype_is_object) - * else: - * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< - * memview.dtype_is_object) - * - */ - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) __PYX_ERR(1, 782, __pyx_L1_error) - __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - } - - /* "View.MemoryView":710 - * - * @cname('__pyx_memview_slice') - * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< - * cdef int new_ndim = 0, suboffset_dim = -1, dim - * cdef bint negative_step - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("View.MemoryView.memview_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_memviewsliceobj); - __Pyx_XDECREF(__pyx_v_index); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":807 - * - * @cname('__pyx_memoryview_slice_memviewslice') - * cdef int slice_memviewslice( # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, - */ - -static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, Py_ssize_t __pyx_v_shape, Py_ssize_t __pyx_v_stride, Py_ssize_t __pyx_v_suboffset, int __pyx_v_dim, int __pyx_v_new_ndim, int *__pyx_v_suboffset_dim, Py_ssize_t __pyx_v_start, Py_ssize_t __pyx_v_stop, Py_ssize_t __pyx_v_step, int __pyx_v_have_start, int __pyx_v_have_stop, int __pyx_v_have_step, int __pyx_v_is_slice) { - Py_ssize_t __pyx_v_new_shape; - int __pyx_v_negative_step; - int __pyx_r; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - - /* "View.MemoryView":827 - * cdef bint negative_step - * - * if not is_slice: # <<<<<<<<<<<<<< - * - * if start < 0: - */ - __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":829 - * if not is_slice: - * - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if not 0 <= start < shape: - */ - __pyx_t_1 = ((__pyx_v_start < 0) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":830 - * - * if start < 0: - * start += shape # <<<<<<<<<<<<<< - * if not 0 <= start < shape: - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) - */ - __pyx_v_start = (__pyx_v_start + __pyx_v_shape); - - /* "View.MemoryView":829 - * if not is_slice: - * - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if not 0 <= start < shape: - */ - } - - /* "View.MemoryView":831 - * if start < 0: - * start += shape - * if not 0 <= start < shape: # <<<<<<<<<<<<<< - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) - * else: - */ - __pyx_t_1 = (0 <= __pyx_v_start); - if (__pyx_t_1) { - __pyx_t_1 = (__pyx_v_start < __pyx_v_shape); - } - __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":832 - * start += shape - * if not 0 <= start < shape: - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<< - * else: - * - */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"Index out of bounds (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 832, __pyx_L1_error) - - /* "View.MemoryView":831 - * if start < 0: - * start += shape - * if not 0 <= start < shape: # <<<<<<<<<<<<<< - * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) - * else: - */ - } - - /* "View.MemoryView":827 - * cdef bint negative_step - * - * if not is_slice: # <<<<<<<<<<<<<< - * - * if start < 0: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":835 - * else: - * - * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<< - * - * if have_step and step == 0: - */ - /*else*/ { - __pyx_t_1 = ((__pyx_v_have_step != 0) != 0); - if (__pyx_t_1) { - } else { - __pyx_t_2 = __pyx_t_1; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_1 = ((__pyx_v_step < 0) != 0); - __pyx_t_2 = __pyx_t_1; - __pyx_L6_bool_binop_done:; - __pyx_v_negative_step = __pyx_t_2; - - /* "View.MemoryView":837 - * negative_step = have_step != 0 and step < 0 - * - * if have_step and step == 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) - * - */ - __pyx_t_1 = (__pyx_v_have_step != 0); - if (__pyx_t_1) { - } else { - __pyx_t_2 = __pyx_t_1; - goto __pyx_L9_bool_binop_done; - } - __pyx_t_1 = ((__pyx_v_step == 0) != 0); - __pyx_t_2 = __pyx_t_1; - __pyx_L9_bool_binop_done:; - if (__pyx_t_2) { - - /* "View.MemoryView":838 - * - * if have_step and step == 0: - * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Step may not be zero (axis %d)"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 838, __pyx_L1_error) - - /* "View.MemoryView":837 - * negative_step = have_step != 0 and step < 0 - * - * if have_step and step == 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) - * - */ - } - - /* "View.MemoryView":841 - * - * - * if have_start: # <<<<<<<<<<<<<< - * if start < 0: - * start += shape - */ - __pyx_t_2 = (__pyx_v_have_start != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":842 - * - * if have_start: - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if start < 0: - */ - __pyx_t_2 = ((__pyx_v_start < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":843 - * if have_start: - * if start < 0: - * start += shape # <<<<<<<<<<<<<< - * if start < 0: - * start = 0 - */ - __pyx_v_start = (__pyx_v_start + __pyx_v_shape); - - /* "View.MemoryView":844 - * if start < 0: - * start += shape - * if start < 0: # <<<<<<<<<<<<<< - * start = 0 - * elif start >= shape: - */ - __pyx_t_2 = ((__pyx_v_start < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":845 - * start += shape - * if start < 0: - * start = 0 # <<<<<<<<<<<<<< - * elif start >= shape: - * if negative_step: - */ - __pyx_v_start = 0; - - /* "View.MemoryView":844 - * if start < 0: - * start += shape - * if start < 0: # <<<<<<<<<<<<<< - * start = 0 - * elif start >= shape: - */ - } - - /* "View.MemoryView":842 - * - * if have_start: - * if start < 0: # <<<<<<<<<<<<<< - * start += shape - * if start < 0: - */ - goto __pyx_L12; - } - - /* "View.MemoryView":846 - * if start < 0: - * start = 0 - * elif start >= shape: # <<<<<<<<<<<<<< - * if negative_step: - * start = shape - 1 - */ - __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":847 - * start = 0 - * elif start >= shape: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - __pyx_t_2 = (__pyx_v_negative_step != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":848 - * elif start >= shape: - * if negative_step: - * start = shape - 1 # <<<<<<<<<<<<<< - * else: - * start = shape - */ - __pyx_v_start = (__pyx_v_shape - 1); - - /* "View.MemoryView":847 - * start = 0 - * elif start >= shape: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - goto __pyx_L14; - } - - /* "View.MemoryView":850 - * start = shape - 1 - * else: - * start = shape # <<<<<<<<<<<<<< - * else: - * if negative_step: - */ - /*else*/ { - __pyx_v_start = __pyx_v_shape; - } - __pyx_L14:; - - /* "View.MemoryView":846 - * if start < 0: - * start = 0 - * elif start >= shape: # <<<<<<<<<<<<<< - * if negative_step: - * start = shape - 1 - */ - } - __pyx_L12:; - - /* "View.MemoryView":841 - * - * - * if have_start: # <<<<<<<<<<<<<< - * if start < 0: - * start += shape - */ - goto __pyx_L11; - } - - /* "View.MemoryView":852 - * start = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - /*else*/ { - __pyx_t_2 = (__pyx_v_negative_step != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":853 - * else: - * if negative_step: - * start = shape - 1 # <<<<<<<<<<<<<< - * else: - * start = 0 - */ - __pyx_v_start = (__pyx_v_shape - 1); - - /* "View.MemoryView":852 - * start = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * start = shape - 1 - * else: - */ - goto __pyx_L15; - } - - /* "View.MemoryView":855 - * start = shape - 1 - * else: - * start = 0 # <<<<<<<<<<<<<< - * - * if have_stop: - */ - /*else*/ { - __pyx_v_start = 0; - } - __pyx_L15:; - } - __pyx_L11:; - - /* "View.MemoryView":857 - * start = 0 - * - * if have_stop: # <<<<<<<<<<<<<< - * if stop < 0: - * stop += shape - */ - __pyx_t_2 = (__pyx_v_have_stop != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":858 - * - * if have_stop: - * if stop < 0: # <<<<<<<<<<<<<< - * stop += shape - * if stop < 0: - */ - __pyx_t_2 = ((__pyx_v_stop < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":859 - * if have_stop: - * if stop < 0: - * stop += shape # <<<<<<<<<<<<<< - * if stop < 0: - * stop = 0 - */ - __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape); - - /* "View.MemoryView":860 - * if stop < 0: - * stop += shape - * if stop < 0: # <<<<<<<<<<<<<< - * stop = 0 - * elif stop > shape: - */ - __pyx_t_2 = ((__pyx_v_stop < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":861 - * stop += shape - * if stop < 0: - * stop = 0 # <<<<<<<<<<<<<< - * elif stop > shape: - * stop = shape - */ - __pyx_v_stop = 0; - - /* "View.MemoryView":860 - * if stop < 0: - * stop += shape - * if stop < 0: # <<<<<<<<<<<<<< - * stop = 0 - * elif stop > shape: - */ - } - - /* "View.MemoryView":858 - * - * if have_stop: - * if stop < 0: # <<<<<<<<<<<<<< - * stop += shape - * if stop < 0: - */ - goto __pyx_L17; - } - - /* "View.MemoryView":862 - * if stop < 0: - * stop = 0 - * elif stop > shape: # <<<<<<<<<<<<<< - * stop = shape - * else: - */ - __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":863 - * stop = 0 - * elif stop > shape: - * stop = shape # <<<<<<<<<<<<<< - * else: - * if negative_step: - */ - __pyx_v_stop = __pyx_v_shape; - - /* "View.MemoryView":862 - * if stop < 0: - * stop = 0 - * elif stop > shape: # <<<<<<<<<<<<<< - * stop = shape - * else: - */ - } - __pyx_L17:; - - /* "View.MemoryView":857 - * start = 0 - * - * if have_stop: # <<<<<<<<<<<<<< - * if stop < 0: - * stop += shape - */ - goto __pyx_L16; - } - - /* "View.MemoryView":865 - * stop = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * stop = -1 - * else: - */ - /*else*/ { - __pyx_t_2 = (__pyx_v_negative_step != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":866 - * else: - * if negative_step: - * stop = -1 # <<<<<<<<<<<<<< - * else: - * stop = shape - */ - __pyx_v_stop = -1L; - - /* "View.MemoryView":865 - * stop = shape - * else: - * if negative_step: # <<<<<<<<<<<<<< - * stop = -1 - * else: - */ - goto __pyx_L19; - } - - /* "View.MemoryView":868 - * stop = -1 - * else: - * stop = shape # <<<<<<<<<<<<<< - * - * if not have_step: - */ - /*else*/ { - __pyx_v_stop = __pyx_v_shape; - } - __pyx_L19:; - } - __pyx_L16:; - - /* "View.MemoryView":870 - * stop = shape - * - * if not have_step: # <<<<<<<<<<<<<< - * step = 1 - * - */ - __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":871 - * - * if not have_step: - * step = 1 # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_step = 1; - - /* "View.MemoryView":870 - * stop = shape - * - * if not have_step: # <<<<<<<<<<<<<< - * step = 1 - * - */ - } - - /* "View.MemoryView":875 - * - * with cython.cdivision(True): - * new_shape = (stop - start) // step # <<<<<<<<<<<<<< - * - * if (stop - start) - step * new_shape: - */ - __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step); - - /* "View.MemoryView":877 - * new_shape = (stop - start) // step - * - * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< - * new_shape += 1 - * - */ - __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":878 - * - * if (stop - start) - step * new_shape: - * new_shape += 1 # <<<<<<<<<<<<<< - * - * if new_shape < 0: - */ - __pyx_v_new_shape = (__pyx_v_new_shape + 1); - - /* "View.MemoryView":877 - * new_shape = (stop - start) // step - * - * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< - * new_shape += 1 - * - */ - } - - /* "View.MemoryView":880 - * new_shape += 1 - * - * if new_shape < 0: # <<<<<<<<<<<<<< - * new_shape = 0 - * - */ - __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":881 - * - * if new_shape < 0: - * new_shape = 0 # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_new_shape = 0; - - /* "View.MemoryView":880 - * new_shape += 1 - * - * if new_shape < 0: # <<<<<<<<<<<<<< - * new_shape = 0 - * - */ - } - - /* "View.MemoryView":884 - * - * - * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<< - * dst.shape[new_ndim] = new_shape - * dst.suboffsets[new_ndim] = suboffset - */ - (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step); - - /* "View.MemoryView":885 - * - * dst.strides[new_ndim] = stride * step - * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<< - * dst.suboffsets[new_ndim] = suboffset - * - */ - (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape; - - /* "View.MemoryView":886 - * dst.strides[new_ndim] = stride * step - * dst.shape[new_ndim] = new_shape - * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<< - * - * - */ - (__pyx_v_dst->suboffsets[__pyx_v_new_ndim]) = __pyx_v_suboffset; - } - __pyx_L3:; - - /* "View.MemoryView":889 - * - * - * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< - * dst.data += start * stride - * else: - */ - __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":890 - * - * if suboffset_dim[0] < 0: - * dst.data += start * stride # <<<<<<<<<<<<<< - * else: - * dst.suboffsets[suboffset_dim[0]] += start * stride - */ - __pyx_v_dst->data = (__pyx_v_dst->data + (__pyx_v_start * __pyx_v_stride)); - - /* "View.MemoryView":889 - * - * - * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< - * dst.data += start * stride - * else: - */ - goto __pyx_L23; - } - - /* "View.MemoryView":892 - * dst.data += start * stride - * else: - * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<< - * - * if suboffset >= 0: - */ - /*else*/ { - __pyx_t_3 = (__pyx_v_suboffset_dim[0]); - (__pyx_v_dst->suboffsets[__pyx_t_3]) = ((__pyx_v_dst->suboffsets[__pyx_t_3]) + (__pyx_v_start * __pyx_v_stride)); - } - __pyx_L23:; - - /* "View.MemoryView":894 - * dst.suboffsets[suboffset_dim[0]] += start * stride - * - * if suboffset >= 0: # <<<<<<<<<<<<<< - * if not is_slice: - * if new_ndim == 0: - */ - __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":895 - * - * if suboffset >= 0: - * if not is_slice: # <<<<<<<<<<<<<< - * if new_ndim == 0: - * dst.data = ( dst.data)[0] + suboffset - */ - __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":896 - * if suboffset >= 0: - * if not is_slice: - * if new_ndim == 0: # <<<<<<<<<<<<<< - * dst.data = ( dst.data)[0] + suboffset - * else: - */ - __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":897 - * if not is_slice: - * if new_ndim == 0: - * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<< - * else: - * _err_dim(IndexError, "All dimensions preceding dimension %d " - */ - __pyx_v_dst->data = ((((char **)__pyx_v_dst->data)[0]) + __pyx_v_suboffset); - - /* "View.MemoryView":896 - * if suboffset >= 0: - * if not is_slice: - * if new_ndim == 0: # <<<<<<<<<<<<<< - * dst.data = ( dst.data)[0] + suboffset - * else: - */ - goto __pyx_L26; - } - - /* "View.MemoryView":899 - * dst.data = ( dst.data)[0] + suboffset - * else: - * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<< - * "must be indexed and not sliced", dim) - * else: - */ - /*else*/ { - - /* "View.MemoryView":900 - * else: - * _err_dim(IndexError, "All dimensions preceding dimension %d " - * "must be indexed and not sliced", dim) # <<<<<<<<<<<<<< - * else: - * suboffset_dim[0] = new_ndim - */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, ((char *)"All dimensions preceding dimension %d must be indexed and not sliced"), __pyx_v_dim); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 899, __pyx_L1_error) - } - __pyx_L26:; - - /* "View.MemoryView":895 - * - * if suboffset >= 0: - * if not is_slice: # <<<<<<<<<<<<<< - * if new_ndim == 0: - * dst.data = ( dst.data)[0] + suboffset - */ - goto __pyx_L25; - } - - /* "View.MemoryView":902 - * "must be indexed and not sliced", dim) - * else: - * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<< - * - * return 0 - */ - /*else*/ { - (__pyx_v_suboffset_dim[0]) = __pyx_v_new_ndim; - } - __pyx_L25:; - - /* "View.MemoryView":894 - * dst.suboffsets[suboffset_dim[0]] += start * stride - * - * if suboffset >= 0: # <<<<<<<<<<<<<< - * if not is_slice: - * if new_ndim == 0: - */ - } - - /* "View.MemoryView":904 - * suboffset_dim[0] = new_ndim - * - * return 0 # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "View.MemoryView":807 - * - * @cname('__pyx_memoryview_slice_memviewslice') - * cdef int slice_memviewslice( # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * Py_ssize_t shape, Py_ssize_t stride, Py_ssize_t suboffset, - */ - - /* function exit code */ - __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.slice_memviewslice", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = -1; - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":910 - * - * @cname('__pyx_pybuffer_index') - * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 - */ - -static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, Py_ssize_t __pyx_v_index, Py_ssize_t __pyx_v_dim) { - Py_ssize_t __pyx_v_shape; - Py_ssize_t __pyx_v_stride; - Py_ssize_t __pyx_v_suboffset; - Py_ssize_t __pyx_v_itemsize; - char *__pyx_v_resultp; - char *__pyx_r; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("pybuffer_index", 0); - - /* "View.MemoryView":912 - * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<< - * cdef Py_ssize_t itemsize = view.itemsize - * cdef char *resultp - */ - __pyx_v_suboffset = -1L; - - /* "View.MemoryView":913 - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 - * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<< - * cdef char *resultp - * - */ - __pyx_t_1 = __pyx_v_view->itemsize; - __pyx_v_itemsize = __pyx_t_1; - - /* "View.MemoryView":916 - * cdef char *resultp - * - * if view.ndim == 0: # <<<<<<<<<<<<<< - * shape = view.len / itemsize - * stride = itemsize - */ - __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":917 - * - * if view.ndim == 0: - * shape = view.len / itemsize # <<<<<<<<<<<<<< - * stride = itemsize - * else: - */ - if (unlikely(__pyx_v_itemsize == 0)) { - PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - __PYX_ERR(1, 917, __pyx_L1_error) - } - else if (sizeof(Py_ssize_t) == sizeof(long) && (!(((Py_ssize_t)-1) > 0)) && unlikely(__pyx_v_itemsize == (Py_ssize_t)-1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) { - PyErr_SetString(PyExc_OverflowError, "value too large to perform division"); - __PYX_ERR(1, 917, __pyx_L1_error) - } - __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize); - - /* "View.MemoryView":918 - * if view.ndim == 0: - * shape = view.len / itemsize - * stride = itemsize # <<<<<<<<<<<<<< - * else: - * shape = view.shape[dim] - */ - __pyx_v_stride = __pyx_v_itemsize; - - /* "View.MemoryView":916 - * cdef char *resultp - * - * if view.ndim == 0: # <<<<<<<<<<<<<< - * shape = view.len / itemsize - * stride = itemsize - */ - goto __pyx_L3; - } - - /* "View.MemoryView":920 - * stride = itemsize - * else: - * shape = view.shape[dim] # <<<<<<<<<<<<<< - * stride = view.strides[dim] - * if view.suboffsets != NULL: - */ - /*else*/ { - __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]); - - /* "View.MemoryView":921 - * else: - * shape = view.shape[dim] - * stride = view.strides[dim] # <<<<<<<<<<<<<< - * if view.suboffsets != NULL: - * suboffset = view.suboffsets[dim] - */ - __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]); - - /* "View.MemoryView":922 - * shape = view.shape[dim] - * stride = view.strides[dim] - * if view.suboffsets != NULL: # <<<<<<<<<<<<<< - * suboffset = view.suboffsets[dim] - * - */ - __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":923 - * stride = view.strides[dim] - * if view.suboffsets != NULL: - * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<< - * - * if index < 0: - */ - __pyx_v_suboffset = (__pyx_v_view->suboffsets[__pyx_v_dim]); - - /* "View.MemoryView":922 - * shape = view.shape[dim] - * stride = view.strides[dim] - * if view.suboffsets != NULL: # <<<<<<<<<<<<<< - * suboffset = view.suboffsets[dim] - * - */ - } - } - __pyx_L3:; - - /* "View.MemoryView":925 - * suboffset = view.suboffsets[dim] - * - * if index < 0: # <<<<<<<<<<<<<< - * index += view.shape[dim] - * if index < 0: - */ - __pyx_t_2 = ((__pyx_v_index < 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":926 - * - * if index < 0: - * index += view.shape[dim] # <<<<<<<<<<<<<< - * if index < 0: - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - */ - __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim])); - - /* "View.MemoryView":927 - * if index < 0: - * index += view.shape[dim] - * if index < 0: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - */ - __pyx_t_2 = ((__pyx_v_index < 0) != 0); - if (unlikely(__pyx_t_2)) { - - /* "View.MemoryView":928 - * index += view.shape[dim] - * if index < 0: - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< - * - * if index >= shape: - */ - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 928, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 928, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 928, __pyx_L1_error) - - /* "View.MemoryView":927 - * if index < 0: - * index += view.shape[dim] - * if index < 0: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - */ - } - - /* "View.MemoryView":925 - * suboffset = view.suboffsets[dim] - * - * if index < 0: # <<<<<<<<<<<<<< - * index += view.shape[dim] - * if index < 0: - */ - } - - /* "View.MemoryView":930 - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - * if index >= shape: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - */ - __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0); - if (unlikely(__pyx_t_2)) { - - /* "View.MemoryView":931 - * - * if index >= shape: - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< - * - * resultp = bufp + index * stride - */ - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 931, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IndexError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 931, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(1, 931, __pyx_L1_error) - - /* "View.MemoryView":930 - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - * if index >= shape: # <<<<<<<<<<<<<< - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - */ - } - - /* "View.MemoryView":933 - * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) - * - * resultp = bufp + index * stride # <<<<<<<<<<<<<< - * if suboffset >= 0: - * resultp = ( resultp)[0] + suboffset - */ - __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride)); - - /* "View.MemoryView":934 - * - * resultp = bufp + index * stride - * if suboffset >= 0: # <<<<<<<<<<<<<< - * resultp = ( resultp)[0] + suboffset - * - */ - __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":935 - * resultp = bufp + index * stride - * if suboffset >= 0: - * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<< - * - * return resultp - */ - __pyx_v_resultp = ((((char **)__pyx_v_resultp)[0]) + __pyx_v_suboffset); - - /* "View.MemoryView":934 - * - * resultp = bufp + index * stride - * if suboffset >= 0: # <<<<<<<<<<<<<< - * resultp = ( resultp)[0] + suboffset - * - */ - } - - /* "View.MemoryView":937 - * resultp = ( resultp)[0] + suboffset - * - * return resultp # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_resultp; - goto __pyx_L0; - - /* "View.MemoryView":910 - * - * @cname('__pyx_pybuffer_index') - * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< - * Py_ssize_t dim) except NULL: - * cdef Py_ssize_t shape, stride, suboffset = -1 - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("View.MemoryView.pybuffer_index", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":943 - * - * @cname('__pyx_memslice_transpose') - * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< - * cdef int ndim = memslice.memview.view.ndim - * - */ - -static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { - int __pyx_v_ndim; - Py_ssize_t *__pyx_v_shape; - Py_ssize_t *__pyx_v_strides; - int __pyx_v_i; - int __pyx_v_j; - int __pyx_r; - int __pyx_t_1; - Py_ssize_t *__pyx_t_2; - long __pyx_t_3; - long __pyx_t_4; - Py_ssize_t __pyx_t_5; - Py_ssize_t __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - int __pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - - /* "View.MemoryView":944 - * @cname('__pyx_memslice_transpose') - * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: - * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<< - * - * cdef Py_ssize_t *shape = memslice.shape - */ - __pyx_t_1 = __pyx_v_memslice->memview->view.ndim; - __pyx_v_ndim = __pyx_t_1; - - /* "View.MemoryView":946 - * cdef int ndim = memslice.memview.view.ndim - * - * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<< - * cdef Py_ssize_t *strides = memslice.strides - * - */ - __pyx_t_2 = __pyx_v_memslice->shape; - __pyx_v_shape = __pyx_t_2; - - /* "View.MemoryView":947 - * - * cdef Py_ssize_t *shape = memslice.shape - * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = __pyx_v_memslice->strides; - __pyx_v_strides = __pyx_t_2; - - /* "View.MemoryView":951 - * - * cdef int i, j - * for i in range(ndim / 2): # <<<<<<<<<<<<<< - * j = ndim - 1 - i - * strides[i], strides[j] = strides[j], strides[i] - */ - __pyx_t_3 = __Pyx_div_long(__pyx_v_ndim, 2); - __pyx_t_4 = __pyx_t_3; - for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_4; __pyx_t_1+=1) { - __pyx_v_i = __pyx_t_1; - - /* "View.MemoryView":952 - * cdef int i, j - * for i in range(ndim / 2): - * j = ndim - 1 - i # <<<<<<<<<<<<<< - * strides[i], strides[j] = strides[j], strides[i] - * shape[i], shape[j] = shape[j], shape[i] - */ - __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i); - - /* "View.MemoryView":953 - * for i in range(ndim / 2): - * j = ndim - 1 - i - * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<< - * shape[i], shape[j] = shape[j], shape[i] - * - */ - __pyx_t_5 = (__pyx_v_strides[__pyx_v_j]); - __pyx_t_6 = (__pyx_v_strides[__pyx_v_i]); - (__pyx_v_strides[__pyx_v_i]) = __pyx_t_5; - (__pyx_v_strides[__pyx_v_j]) = __pyx_t_6; - - /* "View.MemoryView":954 - * j = ndim - 1 - i - * strides[i], strides[j] = strides[j], strides[i] - * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<< - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: - */ - __pyx_t_6 = (__pyx_v_shape[__pyx_v_j]); - __pyx_t_5 = (__pyx_v_shape[__pyx_v_i]); - (__pyx_v_shape[__pyx_v_i]) = __pyx_t_6; - (__pyx_v_shape[__pyx_v_j]) = __pyx_t_5; - - /* "View.MemoryView":956 - * shape[i], shape[j] = shape[j], shape[i] - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") - * - */ - __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0); - if (!__pyx_t_8) { - } else { - __pyx_t_7 = __pyx_t_8; - goto __pyx_L6_bool_binop_done; - } - __pyx_t_8 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0); - __pyx_t_7 = __pyx_t_8; - __pyx_L6_bool_binop_done:; - if (__pyx_t_7) { - - /* "View.MemoryView":957 - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<< - * - * return 1 - */ - __pyx_t_9 = __pyx_memoryview_err(__pyx_builtin_ValueError, ((char *)"Cannot transpose memoryview with indirect dimensions")); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(1, 957, __pyx_L1_error) - - /* "View.MemoryView":956 - * shape[i], shape[j] = shape[j], shape[i] - * - * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") - * - */ - } - } - - /* "View.MemoryView":959 - * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") - * - * return 1 # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = 1; - goto __pyx_L0; - - /* "View.MemoryView":943 - * - * @cname('__pyx_memslice_transpose') - * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< - * cdef int ndim = memslice.memview.view.ndim - * - */ - - /* function exit code */ - __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.transpose_memslice", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = 0; - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":976 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) - * - */ - -/* Python wrapper */ -static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "View.MemoryView":977 - * - * def __dealloc__(self): - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<< - * - * cdef convert_item_to_object(self, char *itemp): - */ - __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1); - - /* "View.MemoryView":976 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) - * - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":979 - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) - * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * if self.to_object_func != NULL: - * return self.to_object_func(itemp) - */ - -static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("convert_item_to_object", 0); - - /* "View.MemoryView":980 - * - * cdef convert_item_to_object(self, char *itemp): - * if self.to_object_func != NULL: # <<<<<<<<<<<<<< - * return self.to_object_func(itemp) - * else: - */ - __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":981 - * cdef convert_item_to_object(self, char *itemp): - * if self.to_object_func != NULL: - * return self.to_object_func(itemp) # <<<<<<<<<<<<<< - * else: - * return memoryview.convert_item_to_object(self, itemp) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 981, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "View.MemoryView":980 - * - * cdef convert_item_to_object(self, char *itemp): - * if self.to_object_func != NULL: # <<<<<<<<<<<<<< - * return self.to_object_func(itemp) - * else: - */ - } - - /* "View.MemoryView":983 - * return self.to_object_func(itemp) - * else: - * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<< - * - * cdef assign_item_from_object(self, char *itemp, object value): - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 983, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - } - - /* "View.MemoryView":979 - * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) - * - * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< - * if self.to_object_func != NULL: - * return self.to_object_func(itemp) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("View.MemoryView._memoryviewslice.convert_item_to_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":985 - * return memoryview.convert_item_to_object(self, itemp) - * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * if self.to_dtype_func != NULL: - * self.to_dtype_func(itemp, value) - */ - -static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memoryviewslice_obj *__pyx_v_self, char *__pyx_v_itemp, PyObject *__pyx_v_value) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("assign_item_from_object", 0); - - /* "View.MemoryView":986 - * - * cdef assign_item_from_object(self, char *itemp, object value): - * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< - * self.to_dtype_func(itemp, value) - * else: - */ - __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":987 - * cdef assign_item_from_object(self, char *itemp, object value): - * if self.to_dtype_func != NULL: - * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<< - * else: - * memoryview.assign_item_from_object(self, itemp, value) - */ - __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == ((int)0))) __PYX_ERR(1, 987, __pyx_L1_error) - - /* "View.MemoryView":986 - * - * cdef assign_item_from_object(self, char *itemp, object value): - * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< - * self.to_dtype_func(itemp, value) - * else: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":989 - * self.to_dtype_func(itemp, value) - * else: - * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<< - * - * @property - */ - /*else*/ { - __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 989, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __pyx_L3:; - - /* "View.MemoryView":985 - * return memoryview.convert_item_to_object(self, itemp) - * - * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< - * if self.to_dtype_func != NULL: - * self.to_dtype_func(itemp, value) - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView._memoryviewslice.assign_item_from_object", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":992 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.from_object - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - - /* "View.MemoryView":993 - * @property - * def base(self): - * return self.from_object # <<<<<<<<<<<<<< - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->from_object); - __pyx_r = __pyx_v_self->from_object; - goto __pyx_L0; - - /* "View.MemoryView":992 - * - * @property - * def base(self): # <<<<<<<<<<<<<< - * return self.from_object - * - */ - - /* function exit code */ - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw___pyx_memoryviewslice_1__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_memoryviewslice___reduce_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_memoryviewslice___reduce_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw___pyx_memoryviewslice_3__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf___pyx_memoryviewslice_2__setstate_cython__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf___pyx_memoryviewslice_2__setstate_cython__(CYTHON_UNUSED struct __pyx_memoryviewslice_obj *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView._memoryviewslice.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":999 - * - * @cname('__pyx_memoryview_fromslice') - * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< - * int ndim, - * object (*to_object_func)(char *), - */ - -static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) { - struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; - Py_ssize_t __pyx_v_suboffset; - PyObject *__pyx_v_length = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_TypeInfo *__pyx_t_4; - Py_buffer __pyx_t_5; - Py_ssize_t *__pyx_t_6; - Py_ssize_t *__pyx_t_7; - Py_ssize_t *__pyx_t_8; - Py_ssize_t __pyx_t_9; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("memoryview_fromslice", 0); - - /* "View.MemoryView":1007 - * cdef _memoryviewslice result - * - * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< - * return None - * - */ - __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1008 - * - * if memviewslice.memview == Py_None: - * return None # <<<<<<<<<<<<<< - * - * - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "View.MemoryView":1007 - * cdef _memoryviewslice result - * - * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< - * return None - * - */ - } - - /* "View.MemoryView":1013 - * - * - * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<< - * - * result.from_slice = memviewslice - */ - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1013, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None); - __Pyx_INCREF(__pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_memoryviewslice_type), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1013, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":1015 - * result = _memoryviewslice(None, 0, dtype_is_object) - * - * result.from_slice = memviewslice # <<<<<<<<<<<<<< - * __PYX_INC_MEMVIEW(&memviewslice, 1) - * - */ - __pyx_v_result->from_slice = __pyx_v_memviewslice; - - /* "View.MemoryView":1016 - * - * result.from_slice = memviewslice - * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<< - * - * result.from_object = ( memviewslice.memview).base - */ - __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1); - - /* "View.MemoryView":1018 - * __PYX_INC_MEMVIEW(&memviewslice, 1) - * - * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<< - * result.typeinfo = memviewslice.memview.typeinfo - * - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1018, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_result->from_object); - __Pyx_DECREF(__pyx_v_result->from_object); - __pyx_v_result->from_object = __pyx_t_2; - __pyx_t_2 = 0; - - /* "View.MemoryView":1019 - * - * result.from_object = ( memviewslice.memview).base - * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<< - * - * result.view = memviewslice.memview.view - */ - __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo; - __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4; - - /* "View.MemoryView":1021 - * result.typeinfo = memviewslice.memview.typeinfo - * - * result.view = memviewslice.memview.view # <<<<<<<<<<<<<< - * result.view.buf = memviewslice.data - * result.view.ndim = ndim - */ - __pyx_t_5 = __pyx_v_memviewslice.memview->view; - __pyx_v_result->__pyx_base.view = __pyx_t_5; - - /* "View.MemoryView":1022 - * - * result.view = memviewslice.memview.view - * result.view.buf = memviewslice.data # <<<<<<<<<<<<<< - * result.view.ndim = ndim - * (<__pyx_buffer *> &result.view).obj = Py_None - */ - __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data); - - /* "View.MemoryView":1023 - * result.view = memviewslice.memview.view - * result.view.buf = memviewslice.data - * result.view.ndim = ndim # <<<<<<<<<<<<<< - * (<__pyx_buffer *> &result.view).obj = Py_None - * Py_INCREF(Py_None) - */ - __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim; - - /* "View.MemoryView":1024 - * result.view.buf = memviewslice.data - * result.view.ndim = ndim - * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<< - * Py_INCREF(Py_None) - * - */ - ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None; - - /* "View.MemoryView":1025 - * result.view.ndim = ndim - * (<__pyx_buffer *> &result.view).obj = Py_None - * Py_INCREF(Py_None) # <<<<<<<<<<<<<< - * - * if (memviewslice.memview).flags & PyBUF_WRITABLE: - */ - Py_INCREF(Py_None); - - /* "View.MemoryView":1027 - * Py_INCREF(Py_None) - * - * if (memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<< - * result.flags = PyBUF_RECORDS - * else: - */ - __pyx_t_1 = ((((struct __pyx_memoryview_obj *)__pyx_v_memviewslice.memview)->flags & PyBUF_WRITABLE) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1028 - * - * if (memviewslice.memview).flags & PyBUF_WRITABLE: - * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<< - * else: - * result.flags = PyBUF_RECORDS_RO - */ - __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS; - - /* "View.MemoryView":1027 - * Py_INCREF(Py_None) - * - * if (memviewslice.memview).flags & PyBUF_WRITABLE: # <<<<<<<<<<<<<< - * result.flags = PyBUF_RECORDS - * else: - */ - goto __pyx_L4; - } - - /* "View.MemoryView":1030 - * result.flags = PyBUF_RECORDS - * else: - * result.flags = PyBUF_RECORDS_RO # <<<<<<<<<<<<<< - * - * result.view.shape = result.from_slice.shape - */ - /*else*/ { - __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS_RO; - } - __pyx_L4:; - - /* "View.MemoryView":1032 - * result.flags = PyBUF_RECORDS_RO - * - * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<< - * result.view.strides = result.from_slice.strides - * - */ - __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape); - - /* "View.MemoryView":1033 - * - * result.view.shape = result.from_slice.shape - * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides); - - /* "View.MemoryView":1036 - * - * - * result.view.suboffsets = NULL # <<<<<<<<<<<<<< - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: - */ - __pyx_v_result->__pyx_base.view.suboffsets = NULL; - - /* "View.MemoryView":1037 - * - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<< - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets - */ - __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim); - for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { - __pyx_t_6 = __pyx_t_8; - __pyx_v_suboffset = (__pyx_t_6[0]); - - /* "View.MemoryView":1038 - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * result.view.suboffsets = result.from_slice.suboffsets - * break - */ - __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1039 - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< - * break - * - */ - __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); - - /* "View.MemoryView":1040 - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets - * break # <<<<<<<<<<<<<< - * - * result.view.len = result.view.itemsize - */ - goto __pyx_L6_break; - - /* "View.MemoryView":1038 - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * result.view.suboffsets = result.from_slice.suboffsets - * break - */ - } - } - __pyx_L6_break:; - - /* "View.MemoryView":1042 - * break - * - * result.view.len = result.view.itemsize # <<<<<<<<<<<<<< - * for length in result.view.shape[:ndim]: - * result.view.len *= length - */ - __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize; - __pyx_v_result->__pyx_base.view.len = __pyx_t_9; - - /* "View.MemoryView":1043 - * - * result.view.len = result.view.itemsize - * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<< - * result.view.len *= length - * - */ - __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim); - for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { - __pyx_t_6 = __pyx_t_8; - __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1043, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":1044 - * result.view.len = result.view.itemsize - * for length in result.view.shape[:ndim]: - * result.view.len *= length # <<<<<<<<<<<<<< - * - * result.to_object_func = to_object_func - */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1044, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1044, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 1044, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result->__pyx_base.view.len = __pyx_t_9; - } - - /* "View.MemoryView":1046 - * result.view.len *= length - * - * result.to_object_func = to_object_func # <<<<<<<<<<<<<< - * result.to_dtype_func = to_dtype_func - * - */ - __pyx_v_result->to_object_func = __pyx_v_to_object_func; - - /* "View.MemoryView":1047 - * - * result.to_object_func = to_object_func - * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<< - * - * return result - */ - __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func; - - /* "View.MemoryView":1049 - * result.to_dtype_func = to_dtype_func - * - * return result # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_get_slice_from_memoryview') - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = ((PyObject *)__pyx_v_result); - goto __pyx_L0; - - /* "View.MemoryView":999 - * - * @cname('__pyx_memoryview_fromslice') - * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< - * int ndim, - * object (*to_object_func)(char *), - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.memoryview_fromslice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XDECREF(__pyx_v_length); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1052 - * - * @cname('__pyx_memoryview_get_slice_from_memoryview') - * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *mslice) except NULL: - * cdef _memoryviewslice obj - */ - -static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_mslice) { - struct __pyx_memoryviewslice_obj *__pyx_v_obj = 0; - __Pyx_memviewslice *__pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_slice_from_memview", 0); - - /* "View.MemoryView":1055 - * __Pyx_memviewslice *mslice) except NULL: - * cdef _memoryviewslice obj - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * obj = memview - * return &obj.from_slice - */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1056 - * cdef _memoryviewslice obj - * if isinstance(memview, _memoryviewslice): - * obj = memview # <<<<<<<<<<<<<< - * return &obj.from_slice - * else: - */ - if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) __PYX_ERR(1, 1056, __pyx_L1_error) - __pyx_t_3 = ((PyObject *)__pyx_v_memview); - __Pyx_INCREF(__pyx_t_3); - __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "View.MemoryView":1057 - * if isinstance(memview, _memoryviewslice): - * obj = memview - * return &obj.from_slice # <<<<<<<<<<<<<< - * else: - * slice_copy(memview, mslice) - */ - __pyx_r = (&__pyx_v_obj->from_slice); - goto __pyx_L0; - - /* "View.MemoryView":1055 - * __Pyx_memviewslice *mslice) except NULL: - * cdef _memoryviewslice obj - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * obj = memview - * return &obj.from_slice - */ - } - - /* "View.MemoryView":1059 - * return &obj.from_slice - * else: - * slice_copy(memview, mslice) # <<<<<<<<<<<<<< - * return mslice - * - */ - /*else*/ { - __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice); - - /* "View.MemoryView":1060 - * else: - * slice_copy(memview, mslice) - * return mslice # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_slice_copy') - */ - __pyx_r = __pyx_v_mslice; - goto __pyx_L0; - } - - /* "View.MemoryView":1052 - * - * @cname('__pyx_memoryview_get_slice_from_memoryview') - * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *mslice) except NULL: - * cdef _memoryviewslice obj - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("View.MemoryView.get_slice_from_memview", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_obj); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1063 - * - * @cname('__pyx_memoryview_slice_copy') - * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< - * cdef int dim - * cdef (Py_ssize_t*) shape, strides, suboffsets - */ - -static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_dst) { - int __pyx_v_dim; - Py_ssize_t *__pyx_v_shape; - Py_ssize_t *__pyx_v_strides; - Py_ssize_t *__pyx_v_suboffsets; - __Pyx_RefNannyDeclarations - Py_ssize_t *__pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - Py_ssize_t __pyx_t_5; - __Pyx_RefNannySetupContext("slice_copy", 0); - - /* "View.MemoryView":1067 - * cdef (Py_ssize_t*) shape, strides, suboffsets - * - * shape = memview.view.shape # <<<<<<<<<<<<<< - * strides = memview.view.strides - * suboffsets = memview.view.suboffsets - */ - __pyx_t_1 = __pyx_v_memview->view.shape; - __pyx_v_shape = __pyx_t_1; - - /* "View.MemoryView":1068 - * - * shape = memview.view.shape - * strides = memview.view.strides # <<<<<<<<<<<<<< - * suboffsets = memview.view.suboffsets - * - */ - __pyx_t_1 = __pyx_v_memview->view.strides; - __pyx_v_strides = __pyx_t_1; - - /* "View.MemoryView":1069 - * shape = memview.view.shape - * strides = memview.view.strides - * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<< - * - * dst.memview = <__pyx_memoryview *> memview - */ - __pyx_t_1 = __pyx_v_memview->view.suboffsets; - __pyx_v_suboffsets = __pyx_t_1; - - /* "View.MemoryView":1071 - * suboffsets = memview.view.suboffsets - * - * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<< - * dst.data = memview.view.buf - * - */ - __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview); - - /* "View.MemoryView":1072 - * - * dst.memview = <__pyx_memoryview *> memview - * dst.data = memview.view.buf # <<<<<<<<<<<<<< - * - * for dim in range(memview.view.ndim): - */ - __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf); - - /* "View.MemoryView":1074 - * dst.data = memview.view.buf - * - * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<< - * dst.shape[dim] = shape[dim] - * dst.strides[dim] = strides[dim] - */ - __pyx_t_2 = __pyx_v_memview->view.ndim; - __pyx_t_3 = __pyx_t_2; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_dim = __pyx_t_4; - - /* "View.MemoryView":1075 - * - * for dim in range(memview.view.ndim): - * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<< - * dst.strides[dim] = strides[dim] - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 - */ - (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]); - - /* "View.MemoryView":1076 - * for dim in range(memview.view.ndim): - * dst.shape[dim] = shape[dim] - * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<< - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 - * - */ - (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]); - - /* "View.MemoryView":1077 - * dst.shape[dim] = shape[dim] - * dst.strides[dim] = strides[dim] - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_copy_object') - */ - if ((__pyx_v_suboffsets != 0)) { - __pyx_t_5 = (__pyx_v_suboffsets[__pyx_v_dim]); - } else { - __pyx_t_5 = -1L; - } - (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_5; - } - - /* "View.MemoryView":1063 - * - * @cname('__pyx_memoryview_slice_copy') - * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< - * cdef int dim - * cdef (Py_ssize_t*) shape, strides, suboffsets - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":1080 - * - * @cname('__pyx_memoryview_copy_object') - * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< - * "Create a new memoryview object" - * cdef __Pyx_memviewslice memviewslice - */ - -static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx_v_memview) { - __Pyx_memviewslice __pyx_v_memviewslice; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("memoryview_copy", 0); - - /* "View.MemoryView":1083 - * "Create a new memoryview object" - * cdef __Pyx_memviewslice memviewslice - * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<< - * return memoryview_copy_from_slice(memview, &memviewslice) - * - */ - __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice)); - - /* "View.MemoryView":1084 - * cdef __Pyx_memviewslice memviewslice - * slice_copy(memview, &memviewslice) - * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_copy_object_from_slice') - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1084, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "View.MemoryView":1080 - * - * @cname('__pyx_memoryview_copy_object') - * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< - * "Create a new memoryview object" - * cdef __Pyx_memviewslice memviewslice - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("View.MemoryView.memoryview_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1087 - * - * @cname('__pyx_memoryview_copy_object_from_slice') - * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< - * """ - * Create a new memoryview object from a given memoryview object and slice. - */ - -static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview_obj *__pyx_v_memview, __Pyx_memviewslice *__pyx_v_memviewslice) { - PyObject *(*__pyx_v_to_object_func)(char *); - int (*__pyx_v_to_dtype_func)(char *, PyObject *); - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *(*__pyx_t_3)(char *); - int (*__pyx_t_4)(char *, PyObject *); - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0); - - /* "View.MemoryView":1094 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * to_object_func = (<_memoryviewslice> memview).to_object_func - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func - */ - __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type); - __pyx_t_2 = (__pyx_t_1 != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1095 - * - * if isinstance(memview, _memoryviewslice): - * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<< - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func - * else: - */ - __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func; - __pyx_v_to_object_func = __pyx_t_3; - - /* "View.MemoryView":1096 - * if isinstance(memview, _memoryviewslice): - * to_object_func = (<_memoryviewslice> memview).to_object_func - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<< - * else: - * to_object_func = NULL - */ - __pyx_t_4 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_dtype_func; - __pyx_v_to_dtype_func = __pyx_t_4; - - /* "View.MemoryView":1094 - * cdef int (*to_dtype_func)(char *, object) except 0 - * - * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< - * to_object_func = (<_memoryviewslice> memview).to_object_func - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func - */ - goto __pyx_L3; - } - - /* "View.MemoryView":1098 - * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func - * else: - * to_object_func = NULL # <<<<<<<<<<<<<< - * to_dtype_func = NULL - * - */ - /*else*/ { - __pyx_v_to_object_func = NULL; - - /* "View.MemoryView":1099 - * else: - * to_object_func = NULL - * to_dtype_func = NULL # <<<<<<<<<<<<<< - * - * return memoryview_fromslice(memviewslice[0], memview.view.ndim, - */ - __pyx_v_to_dtype_func = NULL; - } - __pyx_L3:; - - /* "View.MemoryView":1101 - * to_dtype_func = NULL - * - * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<< - * to_object_func, to_dtype_func, - * memview.dtype_is_object) - */ - __Pyx_XDECREF(__pyx_r); - - /* "View.MemoryView":1103 - * return memoryview_fromslice(memviewslice[0], memview.view.ndim, - * to_object_func, to_dtype_func, - * memview.dtype_is_object) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 1101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "View.MemoryView":1087 - * - * @cname('__pyx_memoryview_copy_object_from_slice') - * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< - * """ - * Create a new memoryview object from a given memoryview object and slice. - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView.memoryview_copy_from_slice", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "View.MemoryView":1109 - * - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< - * if arg < 0: - * return -arg - */ - -static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { - Py_ssize_t __pyx_r; - int __pyx_t_1; - - /* "View.MemoryView":1110 - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: - * if arg < 0: # <<<<<<<<<<<<<< - * return -arg - * else: - */ - __pyx_t_1 = ((__pyx_v_arg < 0) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1111 - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: - * if arg < 0: - * return -arg # <<<<<<<<<<<<<< - * else: - * return arg - */ - __pyx_r = (-__pyx_v_arg); - goto __pyx_L0; - - /* "View.MemoryView":1110 - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: - * if arg < 0: # <<<<<<<<<<<<<< - * return -arg - * else: - */ - } - - /* "View.MemoryView":1113 - * return -arg - * else: - * return arg # <<<<<<<<<<<<<< - * - * @cname('__pyx_get_best_slice_order') - */ - /*else*/ { - __pyx_r = __pyx_v_arg; - goto __pyx_L0; - } - - /* "View.MemoryView":1109 - * - * - * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< - * if arg < 0: - * return -arg - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1116 - * - * @cname('__pyx_get_best_slice_order') - * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< - * """ - * Figure out the best memory access order for a given slice. - */ - -static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim) { - int __pyx_v_i; - Py_ssize_t __pyx_v_c_stride; - Py_ssize_t __pyx_v_f_stride; - char __pyx_r; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - - /* "View.MemoryView":1121 - * """ - * cdef int i - * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<< - * cdef Py_ssize_t f_stride = 0 - * - */ - __pyx_v_c_stride = 0; - - /* "View.MemoryView":1122 - * cdef int i - * cdef Py_ssize_t c_stride = 0 - * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<< - * - * for i in range(ndim - 1, -1, -1): - */ - __pyx_v_f_stride = 0; - - /* "View.MemoryView":1124 - * cdef Py_ssize_t f_stride = 0 - * - * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * if mslice.shape[i] > 1: - * c_stride = mslice.strides[i] - */ - for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { - __pyx_v_i = __pyx_t_1; - - /* "View.MemoryView":1125 - * - * for i in range(ndim - 1, -1, -1): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * c_stride = mslice.strides[i] - * break - */ - __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1126 - * for i in range(ndim - 1, -1, -1): - * if mslice.shape[i] > 1: - * c_stride = mslice.strides[i] # <<<<<<<<<<<<<< - * break - * - */ - __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - - /* "View.MemoryView":1127 - * if mslice.shape[i] > 1: - * c_stride = mslice.strides[i] - * break # <<<<<<<<<<<<<< - * - * for i in range(ndim): - */ - goto __pyx_L4_break; - - /* "View.MemoryView":1125 - * - * for i in range(ndim - 1, -1, -1): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * c_stride = mslice.strides[i] - * break - */ - } - } - __pyx_L4_break:; - - /* "View.MemoryView":1129 - * break - * - * for i in range(ndim): # <<<<<<<<<<<<<< - * if mslice.shape[i] > 1: - * f_stride = mslice.strides[i] - */ - __pyx_t_1 = __pyx_v_ndim; - __pyx_t_3 = __pyx_t_1; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "View.MemoryView":1130 - * - * for i in range(ndim): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * f_stride = mslice.strides[i] - * break - */ - __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1131 - * for i in range(ndim): - * if mslice.shape[i] > 1: - * f_stride = mslice.strides[i] # <<<<<<<<<<<<<< - * break - * - */ - __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - - /* "View.MemoryView":1132 - * if mslice.shape[i] > 1: - * f_stride = mslice.strides[i] - * break # <<<<<<<<<<<<<< - * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): - */ - goto __pyx_L7_break; - - /* "View.MemoryView":1130 - * - * for i in range(ndim): - * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< - * f_stride = mslice.strides[i] - * break - */ - } - } - __pyx_L7_break:; - - /* "View.MemoryView":1134 - * break - * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< - * return 'C' - * else: - */ - __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1135 - * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): - * return 'C' # <<<<<<<<<<<<<< - * else: - * return 'F' - */ - __pyx_r = 'C'; - goto __pyx_L0; - - /* "View.MemoryView":1134 - * break - * - * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< - * return 'C' - * else: - */ - } - - /* "View.MemoryView":1137 - * return 'C' - * else: - * return 'F' # <<<<<<<<<<<<<< - * - * @cython.cdivision(True) - */ - /*else*/ { - __pyx_r = 'F'; - goto __pyx_L0; - } - - /* "View.MemoryView":1116 - * - * @cname('__pyx_get_best_slice_order') - * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< - * """ - * Figure out the best memory access order for a given slice. - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1140 - * - * @cython.cdivision(True) - * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< - * char *dst_data, Py_ssize_t *dst_strides, - * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, - */ - -static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v_src_strides, char *__pyx_v_dst_data, Py_ssize_t *__pyx_v_dst_strides, Py_ssize_t *__pyx_v_src_shape, Py_ssize_t *__pyx_v_dst_shape, int __pyx_v_ndim, size_t __pyx_v_itemsize) { - CYTHON_UNUSED Py_ssize_t __pyx_v_i; - CYTHON_UNUSED Py_ssize_t __pyx_v_src_extent; - Py_ssize_t __pyx_v_dst_extent; - Py_ssize_t __pyx_v_src_stride; - Py_ssize_t __pyx_v_dst_stride; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - Py_ssize_t __pyx_t_4; - Py_ssize_t __pyx_t_5; - Py_ssize_t __pyx_t_6; - - /* "View.MemoryView":1147 - * - * cdef Py_ssize_t i - * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t dst_extent = dst_shape[0] - * cdef Py_ssize_t src_stride = src_strides[0] - */ - __pyx_v_src_extent = (__pyx_v_src_shape[0]); - - /* "View.MemoryView":1148 - * cdef Py_ssize_t i - * cdef Py_ssize_t src_extent = src_shape[0] - * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t src_stride = src_strides[0] - * cdef Py_ssize_t dst_stride = dst_strides[0] - */ - __pyx_v_dst_extent = (__pyx_v_dst_shape[0]); - - /* "View.MemoryView":1149 - * cdef Py_ssize_t src_extent = src_shape[0] - * cdef Py_ssize_t dst_extent = dst_shape[0] - * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t dst_stride = dst_strides[0] - * - */ - __pyx_v_src_stride = (__pyx_v_src_strides[0]); - - /* "View.MemoryView":1150 - * cdef Py_ssize_t dst_extent = dst_shape[0] - * cdef Py_ssize_t src_stride = src_strides[0] - * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<< - * - * if ndim == 1: - */ - __pyx_v_dst_stride = (__pyx_v_dst_strides[0]); - - /* "View.MemoryView":1152 - * cdef Py_ssize_t dst_stride = dst_strides[0] - * - * if ndim == 1: # <<<<<<<<<<<<<< - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): - */ - __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1153 - * - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) - */ - __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L5_bool_binop_done; - } - __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0); - if (__pyx_t_2) { - } else { - __pyx_t_1 = __pyx_t_2; - goto __pyx_L5_bool_binop_done; - } - - /* "View.MemoryView":1154 - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<< - * memcpy(dst_data, src_data, itemsize * dst_extent) - * else: - */ - __pyx_t_2 = (((size_t)__pyx_v_src_stride) == __pyx_v_itemsize); - if (__pyx_t_2) { - __pyx_t_2 = (__pyx_v_itemsize == ((size_t)__pyx_v_dst_stride)); - } - __pyx_t_3 = (__pyx_t_2 != 0); - __pyx_t_1 = __pyx_t_3; - __pyx_L5_bool_binop_done:; - - /* "View.MemoryView":1153 - * - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) - */ - if (__pyx_t_1) { - - /* "View.MemoryView":1155 - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<< - * else: - * for i in range(dst_extent): - */ - (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, (__pyx_v_itemsize * __pyx_v_dst_extent))); - - /* "View.MemoryView":1153 - * - * if ndim == 1: - * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< - * src_stride == itemsize == dst_stride): - * memcpy(dst_data, src_data, itemsize * dst_extent) - */ - goto __pyx_L4; - } - - /* "View.MemoryView":1157 - * memcpy(dst_data, src_data, itemsize * dst_extent) - * else: - * for i in range(dst_extent): # <<<<<<<<<<<<<< - * memcpy(dst_data, src_data, itemsize) - * src_data += src_stride - */ - /*else*/ { - __pyx_t_4 = __pyx_v_dst_extent; - __pyx_t_5 = __pyx_t_4; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_i = __pyx_t_6; - - /* "View.MemoryView":1158 - * else: - * for i in range(dst_extent): - * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<< - * src_data += src_stride - * dst_data += dst_stride - */ - (void)(memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize)); - - /* "View.MemoryView":1159 - * for i in range(dst_extent): - * memcpy(dst_data, src_data, itemsize) - * src_data += src_stride # <<<<<<<<<<<<<< - * dst_data += dst_stride - * else: - */ - __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); - - /* "View.MemoryView":1160 - * memcpy(dst_data, src_data, itemsize) - * src_data += src_stride - * dst_data += dst_stride # <<<<<<<<<<<<<< - * else: - * for i in range(dst_extent): - */ - __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); - } - } - __pyx_L4:; - - /* "View.MemoryView":1152 - * cdef Py_ssize_t dst_stride = dst_strides[0] - * - * if ndim == 1: # <<<<<<<<<<<<<< - * if (src_stride > 0 and dst_stride > 0 and - * src_stride == itemsize == dst_stride): - */ - goto __pyx_L3; - } - - /* "View.MemoryView":1162 - * dst_data += dst_stride - * else: - * for i in range(dst_extent): # <<<<<<<<<<<<<< - * _copy_strided_to_strided(src_data, src_strides + 1, - * dst_data, dst_strides + 1, - */ - /*else*/ { - __pyx_t_4 = __pyx_v_dst_extent; - __pyx_t_5 = __pyx_t_4; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_i = __pyx_t_6; - - /* "View.MemoryView":1163 - * else: - * for i in range(dst_extent): - * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<< - * dst_data, dst_strides + 1, - * src_shape + 1, dst_shape + 1, - */ - _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize); - - /* "View.MemoryView":1167 - * src_shape + 1, dst_shape + 1, - * ndim - 1, itemsize) - * src_data += src_stride # <<<<<<<<<<<<<< - * dst_data += dst_stride - * - */ - __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); - - /* "View.MemoryView":1168 - * ndim - 1, itemsize) - * src_data += src_stride - * dst_data += dst_stride # <<<<<<<<<<<<<< - * - * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, - */ - __pyx_v_dst_data = (__pyx_v_dst_data + __pyx_v_dst_stride); - } - } - __pyx_L3:; - - /* "View.MemoryView":1140 - * - * @cython.cdivision(True) - * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< - * char *dst_data, Py_ssize_t *dst_strides, - * Py_ssize_t *src_shape, Py_ssize_t *dst_shape, - */ - - /* function exit code */ -} - -/* "View.MemoryView":1170 - * dst_data += dst_stride - * - * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * int ndim, size_t itemsize) nogil: - */ - -static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) { - - /* "View.MemoryView":1173 - * __Pyx_memviewslice *dst, - * int ndim, size_t itemsize) nogil: - * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<< - * src.shape, dst.shape, ndim, itemsize) - * - */ - _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize); - - /* "View.MemoryView":1170 - * dst_data += dst_stride - * - * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *dst, - * int ndim, size_t itemsize) nogil: - */ - - /* function exit code */ -} - -/* "View.MemoryView":1177 - * - * @cname('__pyx_memoryview_slice_get_size') - * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< - * "Return the size of the memory occupied by the slice in number of bytes" - * cdef Py_ssize_t shape, size = src.memview.view.itemsize - */ - -static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_src, int __pyx_v_ndim) { - Py_ssize_t __pyx_v_shape; - Py_ssize_t __pyx_v_size; - Py_ssize_t __pyx_r; - Py_ssize_t __pyx_t_1; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - - /* "View.MemoryView":1179 - * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: - * "Return the size of the memory occupied by the slice in number of bytes" - * cdef Py_ssize_t shape, size = src.memview.view.itemsize # <<<<<<<<<<<<<< - * - * for shape in src.shape[:ndim]: - */ - __pyx_t_1 = __pyx_v_src->memview->view.itemsize; - __pyx_v_size = __pyx_t_1; - - /* "View.MemoryView":1181 - * cdef Py_ssize_t shape, size = src.memview.view.itemsize - * - * for shape in src.shape[:ndim]: # <<<<<<<<<<<<<< - * size *= shape - * - */ - __pyx_t_3 = (__pyx_v_src->shape + __pyx_v_ndim); - for (__pyx_t_4 = __pyx_v_src->shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { - __pyx_t_2 = __pyx_t_4; - __pyx_v_shape = (__pyx_t_2[0]); - - /* "View.MemoryView":1182 - * - * for shape in src.shape[:ndim]: - * size *= shape # <<<<<<<<<<<<<< - * - * return size - */ - __pyx_v_size = (__pyx_v_size * __pyx_v_shape); - } - - /* "View.MemoryView":1184 - * size *= shape - * - * return size # <<<<<<<<<<<<<< - * - * @cname('__pyx_fill_contig_strides_array') - */ - __pyx_r = __pyx_v_size; - goto __pyx_L0; - - /* "View.MemoryView":1177 - * - * @cname('__pyx_memoryview_slice_get_size') - * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< - * "Return the size of the memory occupied by the slice in number of bytes" - * cdef Py_ssize_t shape, size = src.memview.view.itemsize - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1187 - * - * @cname('__pyx_fill_contig_strides_array') - * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< - * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, - * int ndim, char order) nogil: - */ - -static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, Py_ssize_t __pyx_v_stride, int __pyx_v_ndim, char __pyx_v_order) { - int __pyx_v_idx; - Py_ssize_t __pyx_r; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - - /* "View.MemoryView":1196 - * cdef int idx - * - * if order == 'F': # <<<<<<<<<<<<<< - * for idx in range(ndim): - * strides[idx] = stride - */ - __pyx_t_1 = ((__pyx_v_order == 'F') != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1197 - * - * if order == 'F': - * for idx in range(ndim): # <<<<<<<<<<<<<< - * strides[idx] = stride - * stride *= shape[idx] - */ - __pyx_t_2 = __pyx_v_ndim; - __pyx_t_3 = __pyx_t_2; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_idx = __pyx_t_4; - - /* "View.MemoryView":1198 - * if order == 'F': - * for idx in range(ndim): - * strides[idx] = stride # <<<<<<<<<<<<<< - * stride *= shape[idx] - * else: - */ - (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; - - /* "View.MemoryView":1199 - * for idx in range(ndim): - * strides[idx] = stride - * stride *= shape[idx] # <<<<<<<<<<<<<< - * else: - * for idx in range(ndim - 1, -1, -1): - */ - __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); - } - - /* "View.MemoryView":1196 - * cdef int idx - * - * if order == 'F': # <<<<<<<<<<<<<< - * for idx in range(ndim): - * strides[idx] = stride - */ - goto __pyx_L3; - } - - /* "View.MemoryView":1201 - * stride *= shape[idx] - * else: - * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * strides[idx] = stride - * stride *= shape[idx] - */ - /*else*/ { - for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) { - __pyx_v_idx = __pyx_t_2; - - /* "View.MemoryView":1202 - * else: - * for idx in range(ndim - 1, -1, -1): - * strides[idx] = stride # <<<<<<<<<<<<<< - * stride *= shape[idx] - * - */ - (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; - - /* "View.MemoryView":1203 - * for idx in range(ndim - 1, -1, -1): - * strides[idx] = stride - * stride *= shape[idx] # <<<<<<<<<<<<<< - * - * return stride - */ - __pyx_v_stride = (__pyx_v_stride * (__pyx_v_shape[__pyx_v_idx])); - } - } - __pyx_L3:; - - /* "View.MemoryView":1205 - * stride *= shape[idx] - * - * return stride # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_copy_data_to_temp') - */ - __pyx_r = __pyx_v_stride; - goto __pyx_L0; - - /* "View.MemoryView":1187 - * - * @cname('__pyx_fill_contig_strides_array') - * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< - * Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t stride, - * int ndim, char order) nogil: - */ - - /* function exit code */ - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1208 - * - * @cname('__pyx_memoryview_copy_data_to_temp') - * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *tmpslice, - * char order, - */ - -static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_tmpslice, char __pyx_v_order, int __pyx_v_ndim) { - int __pyx_v_i; - void *__pyx_v_result; - size_t __pyx_v_itemsize; - size_t __pyx_v_size; - void *__pyx_r; - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - struct __pyx_memoryview_obj *__pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - - /* "View.MemoryView":1219 - * cdef void *result - * - * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< - * cdef size_t size = slice_get_size(src, ndim) - * - */ - __pyx_t_1 = __pyx_v_src->memview->view.itemsize; - __pyx_v_itemsize = __pyx_t_1; - - /* "View.MemoryView":1220 - * - * cdef size_t itemsize = src.memview.view.itemsize - * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<< - * - * result = malloc(size) - */ - __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim); - - /* "View.MemoryView":1222 - * cdef size_t size = slice_get_size(src, ndim) - * - * result = malloc(size) # <<<<<<<<<<<<<< - * if not result: - * _err(MemoryError, NULL) - */ - __pyx_v_result = malloc(__pyx_v_size); - - /* "View.MemoryView":1223 - * - * result = malloc(size) - * if not result: # <<<<<<<<<<<<<< - * _err(MemoryError, NULL) - * - */ - __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1224 - * result = malloc(size) - * if not result: - * _err(MemoryError, NULL) # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(1, 1224, __pyx_L1_error) - - /* "View.MemoryView":1223 - * - * result = malloc(size) - * if not result: # <<<<<<<<<<<<<< - * _err(MemoryError, NULL) - * - */ - } - - /* "View.MemoryView":1227 - * - * - * tmpslice.data = result # <<<<<<<<<<<<<< - * tmpslice.memview = src.memview - * for i in range(ndim): - */ - __pyx_v_tmpslice->data = ((char *)__pyx_v_result); - - /* "View.MemoryView":1228 - * - * tmpslice.data = result - * tmpslice.memview = src.memview # <<<<<<<<<<<<<< - * for i in range(ndim): - * tmpslice.shape[i] = src.shape[i] - */ - __pyx_t_4 = __pyx_v_src->memview; - __pyx_v_tmpslice->memview = __pyx_t_4; - - /* "View.MemoryView":1229 - * tmpslice.data = result - * tmpslice.memview = src.memview - * for i in range(ndim): # <<<<<<<<<<<<<< - * tmpslice.shape[i] = src.shape[i] - * tmpslice.suboffsets[i] = -1 - */ - __pyx_t_3 = __pyx_v_ndim; - __pyx_t_5 = __pyx_t_3; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_i = __pyx_t_6; - - /* "View.MemoryView":1230 - * tmpslice.memview = src.memview - * for i in range(ndim): - * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<< - * tmpslice.suboffsets[i] = -1 - * - */ - (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]); - - /* "View.MemoryView":1231 - * for i in range(ndim): - * tmpslice.shape[i] = src.shape[i] - * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< - * - * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, - */ - (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L; - } - - /* "View.MemoryView":1233 - * tmpslice.suboffsets[i] = -1 - * - * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<< - * ndim, order) - * - */ - (void)(__pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order)); - - /* "View.MemoryView":1237 - * - * - * for i in range(ndim): # <<<<<<<<<<<<<< - * if tmpslice.shape[i] == 1: - * tmpslice.strides[i] = 0 - */ - __pyx_t_3 = __pyx_v_ndim; - __pyx_t_5 = __pyx_t_3; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_i = __pyx_t_6; - - /* "View.MemoryView":1238 - * - * for i in range(ndim): - * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< - * tmpslice.strides[i] = 0 - * - */ - __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1239 - * for i in range(ndim): - * if tmpslice.shape[i] == 1: - * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<< - * - * if slice_is_contig(src[0], order, ndim): - */ - (__pyx_v_tmpslice->strides[__pyx_v_i]) = 0; - - /* "View.MemoryView":1238 - * - * for i in range(ndim): - * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< - * tmpslice.strides[i] = 0 - * - */ - } - } - - /* "View.MemoryView":1241 - * tmpslice.strides[i] = 0 - * - * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< - * memcpy(result, src.data, size) - * else: - */ - __pyx_t_2 = (__pyx_memviewslice_is_contig((__pyx_v_src[0]), __pyx_v_order, __pyx_v_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1242 - * - * if slice_is_contig(src[0], order, ndim): - * memcpy(result, src.data, size) # <<<<<<<<<<<<<< - * else: - * copy_strided_to_strided(src, tmpslice, ndim, itemsize) - */ - (void)(memcpy(__pyx_v_result, __pyx_v_src->data, __pyx_v_size)); - - /* "View.MemoryView":1241 - * tmpslice.strides[i] = 0 - * - * if slice_is_contig(src[0], order, ndim): # <<<<<<<<<<<<<< - * memcpy(result, src.data, size) - * else: - */ - goto __pyx_L9; - } - - /* "View.MemoryView":1244 - * memcpy(result, src.data, size) - * else: - * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<< - * - * return result - */ - /*else*/ { - copy_strided_to_strided(__pyx_v_src, __pyx_v_tmpslice, __pyx_v_ndim, __pyx_v_itemsize); - } - __pyx_L9:; - - /* "View.MemoryView":1246 - * copy_strided_to_strided(src, tmpslice, ndim, itemsize) - * - * return result # <<<<<<<<<<<<<< - * - * - */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; - - /* "View.MemoryView":1208 - * - * @cname('__pyx_memoryview_copy_data_to_temp') - * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice *tmpslice, - * char order, - */ - - /* function exit code */ - __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.copy_data_to_temp", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = NULL; - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1251 - * - * @cname('__pyx_memoryview_err_extents') - * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % - */ - -static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent1, Py_ssize_t __pyx_v_extent2) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_err_extents", 0); - - /* "View.MemoryView":1254 - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % - * (i, extent1, extent2)) # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_err_dim') - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_3 = 0; - - /* "View.MemoryView":1253 - * cdef int _err_extents(int i, Py_ssize_t extent1, - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<< - * (i, extent1, extent2)) - * - */ - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(1, 1253, __pyx_L1_error) - - /* "View.MemoryView":1251 - * - * @cname('__pyx_memoryview_err_extents') - * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< - * Py_ssize_t extent2) except -1 with gil: - * raise ValueError("got differing extents in dimension %d (got %d and %d)" % - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("View.MemoryView._err_extents", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - return __pyx_r; -} - -/* "View.MemoryView":1257 - * - * @cname('__pyx_memoryview_err_dim') - * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii') % dim) - * - */ - -static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, int __pyx_v_dim) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_err_dim", 0); - __Pyx_INCREF(__pyx_v_error); - - /* "View.MemoryView":1258 - * @cname('__pyx_memoryview_err_dim') - * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: - * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_err') - */ - __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 1258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_error); - __pyx_t_3 = __pyx_v_error; __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); - __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(1, 1258, __pyx_L1_error) - - /* "View.MemoryView":1257 - * - * @cname('__pyx_memoryview_err_dim') - * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii') % dim) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("View.MemoryView._err_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_XDECREF(__pyx_v_error); - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - return __pyx_r; -} - -/* "View.MemoryView":1261 - * - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< - * if msg != NULL: - * raise error(msg.decode('ascii')) - */ - -static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("_err", 0); - __Pyx_INCREF(__pyx_v_error); - - /* "View.MemoryView":1262 - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: - * if msg != NULL: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii')) - * else: - */ - __pyx_t_1 = ((__pyx_v_msg != NULL) != 0); - if (unlikely(__pyx_t_1)) { - - /* "View.MemoryView":1263 - * cdef int _err(object error, char *msg) except -1 with gil: - * if msg != NULL: - * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<< - * else: - * raise error - */ - __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 1263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_error); - __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1263, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(1, 1263, __pyx_L1_error) - - /* "View.MemoryView":1262 - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: - * if msg != NULL: # <<<<<<<<<<<<<< - * raise error(msg.decode('ascii')) - * else: - */ - } - - /* "View.MemoryView":1265 - * raise error(msg.decode('ascii')) - * else: - * raise error # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_copy_contents') - */ - /*else*/ { - __Pyx_Raise(__pyx_v_error, 0, 0, 0); - __PYX_ERR(1, 1265, __pyx_L1_error) - } - - /* "View.MemoryView":1261 - * - * @cname('__pyx_memoryview_err') - * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< - * if msg != NULL: - * raise error(msg.decode('ascii')) - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("View.MemoryView._err", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __Pyx_XDECREF(__pyx_v_error); - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - return __pyx_r; -} - -/* "View.MemoryView":1268 - * - * @cname('__pyx_memoryview_copy_contents') - * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice dst, - * int src_ndim, int dst_ndim, - */ - -static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_memviewslice __pyx_v_dst, int __pyx_v_src_ndim, int __pyx_v_dst_ndim, int __pyx_v_dtype_is_object) { - void *__pyx_v_tmpdata; - size_t __pyx_v_itemsize; - int __pyx_v_i; - char __pyx_v_order; - int __pyx_v_broadcasting; - int __pyx_v_direct_copy; - __Pyx_memviewslice __pyx_v_tmp; - int __pyx_v_ndim; - int __pyx_r; - Py_ssize_t __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - void *__pyx_t_7; - int __pyx_t_8; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - - /* "View.MemoryView":1276 - * Check for overlapping memory and verify the shapes. - * """ - * cdef void *tmpdata = NULL # <<<<<<<<<<<<<< - * cdef size_t itemsize = src.memview.view.itemsize - * cdef int i - */ - __pyx_v_tmpdata = NULL; - - /* "View.MemoryView":1277 - * """ - * cdef void *tmpdata = NULL - * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< - * cdef int i - * cdef char order = get_best_order(&src, src_ndim) - */ - __pyx_t_1 = __pyx_v_src.memview->view.itemsize; - __pyx_v_itemsize = __pyx_t_1; - - /* "View.MemoryView":1279 - * cdef size_t itemsize = src.memview.view.itemsize - * cdef int i - * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<< - * cdef bint broadcasting = False - * cdef bint direct_copy = False - */ - __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim); - - /* "View.MemoryView":1280 - * cdef int i - * cdef char order = get_best_order(&src, src_ndim) - * cdef bint broadcasting = False # <<<<<<<<<<<<<< - * cdef bint direct_copy = False - * cdef __Pyx_memviewslice tmp - */ - __pyx_v_broadcasting = 0; - - /* "View.MemoryView":1281 - * cdef char order = get_best_order(&src, src_ndim) - * cdef bint broadcasting = False - * cdef bint direct_copy = False # <<<<<<<<<<<<<< - * cdef __Pyx_memviewslice tmp - * - */ - __pyx_v_direct_copy = 0; - - /* "View.MemoryView":1284 - * cdef __Pyx_memviewslice tmp - * - * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: - */ - __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1285 - * - * if src_ndim < dst_ndim: - * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<< - * elif dst_ndim < src_ndim: - * broadcast_leading(&dst, dst_ndim, src_ndim) - */ - __pyx_memoryview_broadcast_leading((&__pyx_v_src), __pyx_v_src_ndim, __pyx_v_dst_ndim); - - /* "View.MemoryView":1284 - * cdef __Pyx_memviewslice tmp - * - * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: - */ - goto __pyx_L3; - } - - /* "View.MemoryView":1286 - * if src_ndim < dst_ndim: - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&dst, dst_ndim, src_ndim) - * - */ - __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1287 - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: - * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<< - * - * cdef int ndim = max(src_ndim, dst_ndim) - */ - __pyx_memoryview_broadcast_leading((&__pyx_v_dst), __pyx_v_dst_ndim, __pyx_v_src_ndim); - - /* "View.MemoryView":1286 - * if src_ndim < dst_ndim: - * broadcast_leading(&src, src_ndim, dst_ndim) - * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< - * broadcast_leading(&dst, dst_ndim, src_ndim) - * - */ - } - __pyx_L3:; - - /* "View.MemoryView":1289 - * broadcast_leading(&dst, dst_ndim, src_ndim) - * - * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<< - * - * for i in range(ndim): - */ - __pyx_t_3 = __pyx_v_dst_ndim; - __pyx_t_4 = __pyx_v_src_ndim; - if (((__pyx_t_3 > __pyx_t_4) != 0)) { - __pyx_t_5 = __pyx_t_3; - } else { - __pyx_t_5 = __pyx_t_4; - } - __pyx_v_ndim = __pyx_t_5; - - /* "View.MemoryView":1291 - * cdef int ndim = max(src_ndim, dst_ndim) - * - * for i in range(ndim): # <<<<<<<<<<<<<< - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: - */ - __pyx_t_5 = __pyx_v_ndim; - __pyx_t_3 = __pyx_t_5; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "View.MemoryView":1292 - * - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< - * if src.shape[i] == 1: - * broadcasting = True - */ - __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1293 - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: # <<<<<<<<<<<<<< - * broadcasting = True - * src.strides[i] = 0 - */ - __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1294 - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: - * broadcasting = True # <<<<<<<<<<<<<< - * src.strides[i] = 0 - * else: - */ - __pyx_v_broadcasting = 1; - - /* "View.MemoryView":1295 - * if src.shape[i] == 1: - * broadcasting = True - * src.strides[i] = 0 # <<<<<<<<<<<<<< - * else: - * _err_extents(i, dst.shape[i], src.shape[i]) - */ - (__pyx_v_src.strides[__pyx_v_i]) = 0; - - /* "View.MemoryView":1293 - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: - * if src.shape[i] == 1: # <<<<<<<<<<<<<< - * broadcasting = True - * src.strides[i] = 0 - */ - goto __pyx_L7; - } - - /* "View.MemoryView":1297 - * src.strides[i] = 0 - * else: - * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<< - * - * if src.suboffsets[i] >= 0: - */ - /*else*/ { - __pyx_t_6 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1297, __pyx_L1_error) - } - __pyx_L7:; - - /* "View.MemoryView":1292 - * - * for i in range(ndim): - * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< - * if src.shape[i] == 1: - * broadcasting = True - */ - } - - /* "View.MemoryView":1299 - * _err_extents(i, dst.shape[i], src.shape[i]) - * - * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Dimension %d is not direct", i) - * - */ - __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1300 - * - * if src.suboffsets[i] >= 0: - * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<< - * - * if slices_overlap(&src, &dst, ndim, itemsize): - */ - __pyx_t_6 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, ((char *)"Dimension %d is not direct"), __pyx_v_i); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 1300, __pyx_L1_error) - - /* "View.MemoryView":1299 - * _err_extents(i, dst.shape[i], src.shape[i]) - * - * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< - * _err_dim(ValueError, "Dimension %d is not direct", i) - * - */ - } - } - - /* "View.MemoryView":1302 - * _err_dim(ValueError, "Dimension %d is not direct", i) - * - * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< - * - * if not slice_is_contig(src, order, ndim): - */ - __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1304 - * if slices_overlap(&src, &dst, ndim, itemsize): - * - * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< - * order = get_best_order(&dst, ndim) - * - */ - __pyx_t_2 = ((!(__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1305 - * - * if not slice_is_contig(src, order, ndim): - * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<< - * - * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) - */ - __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim); - - /* "View.MemoryView":1304 - * if slices_overlap(&src, &dst, ndim, itemsize): - * - * if not slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< - * order = get_best_order(&dst, ndim) - * - */ - } - - /* "View.MemoryView":1307 - * order = get_best_order(&dst, ndim) - * - * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<< - * src = tmp - * - */ - __pyx_t_7 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_7 == ((void *)NULL))) __PYX_ERR(1, 1307, __pyx_L1_error) - __pyx_v_tmpdata = __pyx_t_7; - - /* "View.MemoryView":1308 - * - * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) - * src = tmp # <<<<<<<<<<<<<< - * - * if not broadcasting: - */ - __pyx_v_src = __pyx_v_tmp; - - /* "View.MemoryView":1302 - * _err_dim(ValueError, "Dimension %d is not direct", i) - * - * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< - * - * if not slice_is_contig(src, order, ndim): - */ - } - - /* "View.MemoryView":1310 - * src = tmp - * - * if not broadcasting: # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1313 - * - * - * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): - */ - __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'C', __pyx_v_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1314 - * - * if slice_is_contig(src, 'C', ndim): - * direct_copy = slice_is_contig(dst, 'C', ndim) # <<<<<<<<<<<<<< - * elif slice_is_contig(src, 'F', ndim): - * direct_copy = slice_is_contig(dst, 'F', ndim) - */ - __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'C', __pyx_v_ndim); - - /* "View.MemoryView":1313 - * - * - * if slice_is_contig(src, 'C', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): - */ - goto __pyx_L12; - } - - /* "View.MemoryView":1315 - * if slice_is_contig(src, 'C', ndim): - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'F', ndim) - * - */ - __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, 'F', __pyx_v_ndim) != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1316 - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): - * direct_copy = slice_is_contig(dst, 'F', ndim) # <<<<<<<<<<<<<< - * - * if direct_copy: - */ - __pyx_v_direct_copy = __pyx_memviewslice_is_contig(__pyx_v_dst, 'F', __pyx_v_ndim); - - /* "View.MemoryView":1315 - * if slice_is_contig(src, 'C', ndim): - * direct_copy = slice_is_contig(dst, 'C', ndim) - * elif slice_is_contig(src, 'F', ndim): # <<<<<<<<<<<<<< - * direct_copy = slice_is_contig(dst, 'F', ndim) - * - */ - } - __pyx_L12:; - - /* "View.MemoryView":1318 - * direct_copy = slice_is_contig(dst, 'F', ndim) - * - * if direct_copy: # <<<<<<<<<<<<<< - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - */ - __pyx_t_2 = (__pyx_v_direct_copy != 0); - if (__pyx_t_2) { - - /* "View.MemoryView":1320 - * if direct_copy: - * - * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) - * refcount_copying(&dst, dtype_is_object, ndim, True) - */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - - /* "View.MemoryView":1321 - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<< - * refcount_copying(&dst, dtype_is_object, ndim, True) - * free(tmpdata) - */ - (void)(memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim))); - - /* "View.MemoryView":1322 - * refcount_copying(&dst, dtype_is_object, ndim, False) - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) - * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< - * free(tmpdata) - * return 0 - */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); - - /* "View.MemoryView":1323 - * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) - * refcount_copying(&dst, dtype_is_object, ndim, True) - * free(tmpdata) # <<<<<<<<<<<<<< - * return 0 - * - */ - free(__pyx_v_tmpdata); - - /* "View.MemoryView":1324 - * refcount_copying(&dst, dtype_is_object, ndim, True) - * free(tmpdata) - * return 0 # <<<<<<<<<<<<<< - * - * if order == 'F' == get_best_order(&dst, ndim): - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "View.MemoryView":1318 - * direct_copy = slice_is_contig(dst, 'F', ndim) - * - * if direct_copy: # <<<<<<<<<<<<<< - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - */ - } - - /* "View.MemoryView":1310 - * src = tmp - * - * if not broadcasting: # <<<<<<<<<<<<<< - * - * - */ - } - - /* "View.MemoryView":1326 - * return 0 - * - * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = (__pyx_v_order == 'F'); - if (__pyx_t_2) { - __pyx_t_2 = ('F' == __pyx_get_best_slice_order((&__pyx_v_dst), __pyx_v_ndim)); - } - __pyx_t_8 = (__pyx_t_2 != 0); - if (__pyx_t_8) { - - /* "View.MemoryView":1329 - * - * - * transpose_memslice(&src) # <<<<<<<<<<<<<< - * transpose_memslice(&dst) - * - */ - __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1329, __pyx_L1_error) - - /* "View.MemoryView":1330 - * - * transpose_memslice(&src) - * transpose_memslice(&dst) # <<<<<<<<<<<<<< - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - */ - __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == ((int)0))) __PYX_ERR(1, 1330, __pyx_L1_error) - - /* "View.MemoryView":1326 - * return 0 - * - * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< - * - * - */ - } - - /* "View.MemoryView":1332 - * transpose_memslice(&dst) - * - * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< - * copy_strided_to_strided(&src, &dst, ndim, itemsize) - * refcount_copying(&dst, dtype_is_object, ndim, True) - */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - - /* "View.MemoryView":1333 - * - * refcount_copying(&dst, dtype_is_object, ndim, False) - * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<< - * refcount_copying(&dst, dtype_is_object, ndim, True) - * - */ - copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize); - - /* "View.MemoryView":1334 - * refcount_copying(&dst, dtype_is_object, ndim, False) - * copy_strided_to_strided(&src, &dst, ndim, itemsize) - * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< - * - * free(tmpdata) - */ - __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); - - /* "View.MemoryView":1336 - * refcount_copying(&dst, dtype_is_object, ndim, True) - * - * free(tmpdata) # <<<<<<<<<<<<<< - * return 0 - * - */ - free(__pyx_v_tmpdata); - - /* "View.MemoryView":1337 - * - * free(tmpdata) - * return 0 # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_broadcast_leading') - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "View.MemoryView":1268 - * - * @cname('__pyx_memoryview_copy_contents') - * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< - * __Pyx_memviewslice dst, - * int src_ndim, int dst_ndim, - */ - - /* function exit code */ - __pyx_L1_error:; - { - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_AddTraceback("View.MemoryView.memoryview_copy_contents", __pyx_clineno, __pyx_lineno, __pyx_filename); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif - } - __pyx_r = -1; - __pyx_L0:; - return __pyx_r; -} - -/* "View.MemoryView":1340 - * - * @cname('__pyx_memoryview_broadcast_leading') - * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< - * int ndim, - * int ndim_other) nogil: - */ - -static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) { - int __pyx_v_i; - int __pyx_v_offset; - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - - /* "View.MemoryView":1344 - * int ndim_other) nogil: - * cdef int i - * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<< - * - * for i in range(ndim - 1, -1, -1): - */ - __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim); - - /* "View.MemoryView":1346 - * cdef int offset = ndim_other - ndim - * - * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] - */ - for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { - __pyx_v_i = __pyx_t_1; - - /* "View.MemoryView":1347 - * - * for i in range(ndim - 1, -1, -1): - * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<< - * mslice.strides[i + offset] = mslice.strides[i] - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] - */ - (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]); - - /* "View.MemoryView":1348 - * for i in range(ndim - 1, -1, -1): - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<< - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] - * - */ - (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]); - - /* "View.MemoryView":1349 - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<< - * - * for i in range(offset): - */ - (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]); - } - - /* "View.MemoryView":1351 - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] - * - * for i in range(offset): # <<<<<<<<<<<<<< - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] - */ - __pyx_t_1 = __pyx_v_offset; - __pyx_t_2 = __pyx_t_1; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; - - /* "View.MemoryView":1352 - * - * for i in range(offset): - * mslice.shape[i] = 1 # <<<<<<<<<<<<<< - * mslice.strides[i] = mslice.strides[0] - * mslice.suboffsets[i] = -1 - */ - (__pyx_v_mslice->shape[__pyx_v_i]) = 1; - - /* "View.MemoryView":1353 - * for i in range(offset): - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<< - * mslice.suboffsets[i] = -1 - * - */ - (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]); - - /* "View.MemoryView":1354 - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] - * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< - * - * - */ - (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L; - } - - /* "View.MemoryView":1340 - * - * @cname('__pyx_memoryview_broadcast_leading') - * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< - * int ndim, - * int ndim_other) nogil: - */ - - /* function exit code */ -} - -/* "View.MemoryView":1362 - * - * @cname('__pyx_memoryview_refcount_copying') - * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< - * int ndim, bint inc) nogil: - * - */ - -static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) { - int __pyx_t_1; - - /* "View.MemoryView":1366 - * - * - * if dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice_with_gil(dst.data, dst.shape, - * dst.strides, ndim, inc) - */ - __pyx_t_1 = (__pyx_v_dtype_is_object != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1367 - * - * if dtype_is_object: - * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<< - * dst.strides, ndim, inc) - * - */ - __pyx_memoryview_refcount_objects_in_slice_with_gil(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_inc); - - /* "View.MemoryView":1366 - * - * - * if dtype_is_object: # <<<<<<<<<<<<<< - * refcount_objects_in_slice_with_gil(dst.data, dst.shape, - * dst.strides, ndim, inc) - */ - } - - /* "View.MemoryView":1362 - * - * @cname('__pyx_memoryview_refcount_copying') - * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< - * int ndim, bint inc) nogil: - * - */ - - /* function exit code */ -} - -/* "View.MemoryView":1371 - * - * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') - * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * bint inc) with gil: - */ - -static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { - __Pyx_RefNannyDeclarations - #ifdef WITH_THREAD - PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); - #endif - __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); - - /* "View.MemoryView":1374 - * Py_ssize_t *strides, int ndim, - * bint inc) with gil: - * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<< - * - * @cname('__pyx_memoryview_refcount_objects_in_slice') - */ - __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc); - - /* "View.MemoryView":1371 - * - * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') - * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * bint inc) with gil: - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - #ifdef WITH_THREAD - __Pyx_PyGILState_Release(__pyx_gilstate_save); - #endif -} - -/* "View.MemoryView":1377 - * - * @cname('__pyx_memoryview_refcount_objects_in_slice') - * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, bint inc): - * cdef Py_ssize_t i - */ - -static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, int __pyx_v_inc) { - CYTHON_UNUSED Py_ssize_t __pyx_v_i; - __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - Py_ssize_t __pyx_t_2; - Py_ssize_t __pyx_t_3; - int __pyx_t_4; - __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0); - - /* "View.MemoryView":1381 - * cdef Py_ssize_t i - * - * for i in range(shape[0]): # <<<<<<<<<<<<<< - * if ndim == 1: - * if inc: - */ - __pyx_t_1 = (__pyx_v_shape[0]); - __pyx_t_2 = __pyx_t_1; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; - - /* "View.MemoryView":1382 - * - * for i in range(shape[0]): - * if ndim == 1: # <<<<<<<<<<<<<< - * if inc: - * Py_INCREF(( data)[0]) - */ - __pyx_t_4 = ((__pyx_v_ndim == 1) != 0); - if (__pyx_t_4) { - - /* "View.MemoryView":1383 - * for i in range(shape[0]): - * if ndim == 1: - * if inc: # <<<<<<<<<<<<<< - * Py_INCREF(( data)[0]) - * else: - */ - __pyx_t_4 = (__pyx_v_inc != 0); - if (__pyx_t_4) { - - /* "View.MemoryView":1384 - * if ndim == 1: - * if inc: - * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<< - * else: - * Py_DECREF(( data)[0]) - */ - Py_INCREF((((PyObject **)__pyx_v_data)[0])); - - /* "View.MemoryView":1383 - * for i in range(shape[0]): - * if ndim == 1: - * if inc: # <<<<<<<<<<<<<< - * Py_INCREF(( data)[0]) - * else: - */ - goto __pyx_L6; - } - - /* "View.MemoryView":1386 - * Py_INCREF(( data)[0]) - * else: - * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<< - * else: - * refcount_objects_in_slice(data, shape + 1, strides + 1, - */ - /*else*/ { - Py_DECREF((((PyObject **)__pyx_v_data)[0])); - } - __pyx_L6:; - - /* "View.MemoryView":1382 - * - * for i in range(shape[0]): - * if ndim == 1: # <<<<<<<<<<<<<< - * if inc: - * Py_INCREF(( data)[0]) - */ - goto __pyx_L5; - } - - /* "View.MemoryView":1388 - * Py_DECREF(( data)[0]) - * else: - * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< - * ndim - 1, inc) - * - */ - /*else*/ { - - /* "View.MemoryView":1389 - * else: - * refcount_objects_in_slice(data, shape + 1, strides + 1, - * ndim - 1, inc) # <<<<<<<<<<<<<< - * - * data += strides[0] - */ - __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_inc); - } - __pyx_L5:; - - /* "View.MemoryView":1391 - * ndim - 1, inc) - * - * data += strides[0] # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); - } - - /* "View.MemoryView":1377 - * - * @cname('__pyx_memoryview_refcount_objects_in_slice') - * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, bint inc): - * cdef Py_ssize_t i - */ - - /* function exit code */ - __Pyx_RefNannyFinishContext(); -} - -/* "View.MemoryView":1397 - * - * @cname('__pyx_memoryview_slice_assign_scalar') - * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< - * size_t itemsize, void *item, - * bint dtype_is_object) nogil: - */ - -static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) { - - /* "View.MemoryView":1400 - * size_t itemsize, void *item, - * bint dtype_is_object) nogil: - * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< - * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, - * itemsize, item) - */ - __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - - /* "View.MemoryView":1401 - * bint dtype_is_object) nogil: - * refcount_copying(dst, dtype_is_object, ndim, False) - * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<< - * itemsize, item) - * refcount_copying(dst, dtype_is_object, ndim, True) - */ - __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item); - - /* "View.MemoryView":1403 - * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, - * itemsize, item) - * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< - * - * - */ - __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1); - - /* "View.MemoryView":1397 - * - * @cname('__pyx_memoryview_slice_assign_scalar') - * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< - * size_t itemsize, void *item, - * bint dtype_is_object) nogil: - */ - - /* function exit code */ -} - -/* "View.MemoryView":1407 - * - * @cname('__pyx_memoryview__slice_assign_scalar') - * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * size_t itemsize, void *item) nogil: - */ - -static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t *__pyx_v_shape, Py_ssize_t *__pyx_v_strides, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item) { - CYTHON_UNUSED Py_ssize_t __pyx_v_i; - Py_ssize_t __pyx_v_stride; - Py_ssize_t __pyx_v_extent; - int __pyx_t_1; - Py_ssize_t __pyx_t_2; - Py_ssize_t __pyx_t_3; - Py_ssize_t __pyx_t_4; - - /* "View.MemoryView":1411 - * size_t itemsize, void *item) nogil: - * cdef Py_ssize_t i - * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<< - * cdef Py_ssize_t extent = shape[0] - * - */ - __pyx_v_stride = (__pyx_v_strides[0]); - - /* "View.MemoryView":1412 - * cdef Py_ssize_t i - * cdef Py_ssize_t stride = strides[0] - * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<< - * - * if ndim == 1: - */ - __pyx_v_extent = (__pyx_v_shape[0]); - - /* "View.MemoryView":1414 - * cdef Py_ssize_t extent = shape[0] - * - * if ndim == 1: # <<<<<<<<<<<<<< - * for i in range(extent): - * memcpy(data, item, itemsize) - */ - __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":1415 - * - * if ndim == 1: - * for i in range(extent): # <<<<<<<<<<<<<< - * memcpy(data, item, itemsize) - * data += stride - */ - __pyx_t_2 = __pyx_v_extent; - __pyx_t_3 = __pyx_t_2; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "View.MemoryView":1416 - * if ndim == 1: - * for i in range(extent): - * memcpy(data, item, itemsize) # <<<<<<<<<<<<<< - * data += stride - * else: - */ - (void)(memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize)); - - /* "View.MemoryView":1417 - * for i in range(extent): - * memcpy(data, item, itemsize) - * data += stride # <<<<<<<<<<<<<< - * else: - * for i in range(extent): - */ - __pyx_v_data = (__pyx_v_data + __pyx_v_stride); - } - - /* "View.MemoryView":1414 - * cdef Py_ssize_t extent = shape[0] - * - * if ndim == 1: # <<<<<<<<<<<<<< - * for i in range(extent): - * memcpy(data, item, itemsize) - */ - goto __pyx_L3; - } - - /* "View.MemoryView":1419 - * data += stride - * else: - * for i in range(extent): # <<<<<<<<<<<<<< - * _slice_assign_scalar(data, shape + 1, strides + 1, - * ndim - 1, itemsize, item) - */ - /*else*/ { - __pyx_t_2 = __pyx_v_extent; - __pyx_t_3 = __pyx_t_2; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; - - /* "View.MemoryView":1420 - * else: - * for i in range(extent): - * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< - * ndim - 1, itemsize, item) - * data += stride - */ - __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item); - - /* "View.MemoryView":1422 - * _slice_assign_scalar(data, shape + 1, strides + 1, - * ndim - 1, itemsize, item) - * data += stride # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_data = (__pyx_v_data + __pyx_v_stride); - } - } - __pyx_L3:; - - /* "View.MemoryView":1407 - * - * @cname('__pyx_memoryview__slice_assign_scalar') - * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< - * Py_ssize_t *strides, int ndim, - * size_t itemsize, void *item) nogil: - */ - - /* function exit code */ -} - -/* "(tree fragment)":1 - * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< - * cdef object __pyx_PickleError - * cdef object __pyx_result - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum = {"__pyx_unpickle_Enum", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_15View_dot_MemoryView_1__pyx_unpickle_Enum(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v___pyx_type = 0; - long __pyx_v___pyx_checksum; - PyObject *__pyx_v___pyx_state = 0; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__pyx_unpickle_Enum (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - CYTHON_FALLTHROUGH; - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error) - } - CYTHON_FALLTHROUGH; - case 2: - if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_Enum") < 0)) __PYX_ERR(1, 1, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v___pyx_type = values[0]; - __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error) - __pyx_v___pyx_state = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_Enum", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_15View_dot_MemoryView___pyx_unpickle_Enum(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_v___pyx_PickleError = 0; - PyObject *__pyx_v___pyx_result = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__pyx_unpickle_Enum", 0); - - /* "(tree fragment)":4 - * cdef object __pyx_PickleError - * cdef object __pyx_result - * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): # <<<<<<<<<<<<<< - * from pickle import PickleError as __pyx_PickleError - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) - */ - __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_1, __pyx_tuple__19, Py_NE)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "(tree fragment)":5 - * cdef object __pyx_result - * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): - * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<< - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) - * __pyx_result = Enum.__new__(__pyx_type) - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_PickleError); - __Pyx_GIVEREF(__pyx_n_s_PickleError); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_PickleError); - __pyx_t_4 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_1); - __pyx_v___pyx_PickleError = __pyx_t_1; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "(tree fragment)":6 - * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): - * from pickle import PickleError as __pyx_PickleError - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) # <<<<<<<<<<<<<< - * __pyx_result = Enum.__new__(__pyx_type) - * if __pyx_state is not None: - */ - __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(1, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_INCREF(__pyx_v___pyx_PickleError); - __pyx_t_1 = __pyx_v___pyx_PickleError; __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __PYX_ERR(1, 6, __pyx_L1_error) - - /* "(tree fragment)":4 - * cdef object __pyx_PickleError - * cdef object __pyx_result - * if __pyx_checksum not in (0xb068931, 0x82a3537, 0x6ae9995): # <<<<<<<<<<<<<< - * from pickle import PickleError as __pyx_PickleError - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) - */ - } - - /* "(tree fragment)":7 - * from pickle import PickleError as __pyx_PickleError - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) - * __pyx_result = Enum.__new__(__pyx_type) # <<<<<<<<<<<<<< - * if __pyx_state is not None: - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_MemviewEnum_type), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v___pyx_type); - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 7, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v___pyx_result = __pyx_t_4; - __pyx_t_4 = 0; - - /* "(tree fragment)":8 - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) - * __pyx_result = Enum.__new__(__pyx_type) - * if __pyx_state is not None: # <<<<<<<<<<<<<< - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - * return __pyx_result - */ - __pyx_t_3 = (__pyx_v___pyx_state != Py_None); - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "(tree fragment)":9 - * __pyx_result = Enum.__new__(__pyx_type) - * if __pyx_state is not None: - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) # <<<<<<<<<<<<<< - * return __pyx_result - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): - */ - if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error) - __pyx_t_4 = __pyx_unpickle_Enum__set_state(((struct __pyx_MemviewEnum_obj *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 9, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "(tree fragment)":8 - * raise __pyx_PickleError("Incompatible checksums (0x%x vs (0xb068931, 0x82a3537, 0x6ae9995) = (name))" % __pyx_checksum) - * __pyx_result = Enum.__new__(__pyx_type) - * if __pyx_state is not None: # <<<<<<<<<<<<<< - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - * return __pyx_result - */ - } - - /* "(tree fragment)":10 - * if __pyx_state is not None: - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - * return __pyx_result # <<<<<<<<<<<<<< - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): - * __pyx_result.name = __pyx_state[0] - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v___pyx_result); - __pyx_r = __pyx_v___pyx_result; - goto __pyx_L0; - - /* "(tree fragment)":1 - * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< - * cdef object __pyx_PickleError - * cdef object __pyx_result - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v___pyx_PickleError); - __Pyx_XDECREF(__pyx_v___pyx_result); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":11 - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - * return __pyx_result - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< - * __pyx_result.name = __pyx_state[0] - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): - */ - -static PyObject *__pyx_unpickle_Enum__set_state(struct __pyx_MemviewEnum_obj *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__pyx_unpickle_Enum__set_state", 0); - - /* "(tree fragment)":12 - * return __pyx_result - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): - * __pyx_result.name = __pyx_state[0] # <<<<<<<<<<<<<< - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): - * __pyx_result.__dict__.update(__pyx_state[1]) - */ - if (unlikely(__pyx_v___pyx_state == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 12, __pyx_L1_error) - } - __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v___pyx_result->name); - __Pyx_DECREF(__pyx_v___pyx_result->name); - __pyx_v___pyx_result->name = __pyx_t_1; - __pyx_t_1 = 0; - - /* "(tree fragment)":13 - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): - * __pyx_result.name = __pyx_state[0] - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< - * __pyx_result.__dict__.update(__pyx_state[1]) - */ - if (unlikely(__pyx_v___pyx_state == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(1, 13, __pyx_L1_error) - } - __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error) - __pyx_t_4 = ((__pyx_t_3 > 1) != 0); - if (__pyx_t_4) { - } else { - __pyx_t_2 = __pyx_t_4; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_4 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error) - __pyx_t_5 = (__pyx_t_4 != 0); - __pyx_t_2 = __pyx_t_5; - __pyx_L4_bool_binop_done:; - if (__pyx_t_2) { - - /* "(tree fragment)":14 - * __pyx_result.name = __pyx_state[0] - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): - * __pyx_result.__dict__.update(__pyx_state[1]) # <<<<<<<<<<<<<< - */ - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_update); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(__pyx_v___pyx_state == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(1, 14, __pyx_L1_error) - } - __pyx_t_6 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(1, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - } - } - __pyx_t_1 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "(tree fragment)":13 - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): - * __pyx_result.name = __pyx_state[0] - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<< - * __pyx_result.__dict__.update(__pyx_state[1]) - */ - } - - /* "(tree fragment)":11 - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - * return __pyx_result - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< - * __pyx_result.name = __pyx_state[0] - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("View.MemoryView.__pyx_unpickle_Enum__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_array __pyx_vtable_array; - -static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_array_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_array_obj *)o); - p->__pyx_vtab = __pyx_vtabptr_array; - p->mode = ((PyObject*)Py_None); Py_INCREF(Py_None); - p->_format = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_array___cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_array(PyObject *o) { - struct __pyx_array_obj *p = (struct __pyx_array_obj *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); - __pyx_array___dealloc__(o); - __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); - PyErr_Restore(etype, eval, etb); - } - Py_CLEAR(p->mode); - Py_CLEAR(p->_format); - (*Py_TYPE(o)->tp_free)(o); -} -static PyObject *__pyx_sq_item_array(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} - -static int __pyx_mp_ass_subscript_array(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_array___setitem__(o, i, v); - } - else { - PyErr_Format(PyExc_NotImplementedError, - "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); - return -1; - } -} - -static PyObject *__pyx_tp_getattro_array(PyObject *o, PyObject *n) { - PyObject *v = __Pyx_PyObject_GenericGetAttr(o, n); - if (!v && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - v = __pyx_array___getattr__(o, n); - } - return v; -} - -static PyObject *__pyx_getprop___pyx_array_memview(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_5array_7memview_1__get__(o); -} - -static PyMethodDef __pyx_methods_array[] = { - {"__getattr__", (PyCFunction)__pyx_array___getattr__, METH_O|METH_COEXIST, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_array_1__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_array_3__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static struct PyGetSetDef __pyx_getsets_array[] = { - {(char *)"memview", __pyx_getprop___pyx_array_memview, 0, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; - -static PySequenceMethods __pyx_tp_as_sequence_array = { - __pyx_array___len__, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - __pyx_sq_item_array, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_array = { - __pyx_array___len__, /*mp_length*/ - __pyx_array___getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_array, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_array = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - __pyx_array_getbuffer, /*bf_getbuffer*/ - 0, /*bf_releasebuffer*/ -}; - -static PyTypeObject __pyx_type___pyx_array = { - PyVarObject_HEAD_INIT(0, 0) - "strings_udf._lib.cudf_jit_udf.array", /*tp_name*/ - sizeof(struct __pyx_array_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_array, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - &__pyx_tp_as_sequence_array, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_array, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - __pyx_tp_getattro_array, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_array, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_array, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_array, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_array, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif - #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 - 0, /*tp_pypy_flags*/ - #endif -}; - -static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_MemviewEnum_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_MemviewEnum_obj *)o); - p->name = Py_None; Py_INCREF(Py_None); - return o; -} - -static void __pyx_tp_dealloc_Enum(PyObject *o) { - struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->name); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_Enum(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; - if (p->name) { - e = (*v)(p->name, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_Enum(PyObject *o) { - PyObject* tmp; - struct __pyx_MemviewEnum_obj *p = (struct __pyx_MemviewEnum_obj *)o; - tmp = ((PyObject*)p->name); - p->name = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_Enum[] = { - {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_1__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_MemviewEnum_3__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type___pyx_MemviewEnum = { - PyVarObject_HEAD_INIT(0, 0) - "strings_udf._lib.cudf_jit_udf.Enum", /*tp_name*/ - sizeof(struct __pyx_MemviewEnum_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_Enum, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - __pyx_MemviewEnum___repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_Enum, /*tp_traverse*/ - __pyx_tp_clear_Enum, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_Enum, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_MemviewEnum___init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_Enum, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif - #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 - 0, /*tp_pypy_flags*/ - #endif -}; -static struct __pyx_vtabstruct_memoryview __pyx_vtable_memoryview; - -static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_memoryview_obj *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_memoryview_obj *)o); - p->__pyx_vtab = __pyx_vtabptr_memoryview; - p->obj = Py_None; Py_INCREF(Py_None); - p->_size = Py_None; Py_INCREF(Py_None); - p->_array_interface = Py_None; Py_INCREF(Py_None); - p->view.obj = NULL; - if (unlikely(__pyx_memoryview___cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_memoryview(PyObject *o) { - struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); - __pyx_memoryview___dealloc__(o); - __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); - PyErr_Restore(etype, eval, etb); - } - Py_CLEAR(p->obj); - Py_CLEAR(p->_size); - Py_CLEAR(p->_array_interface); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_memoryview(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; - if (p->obj) { - e = (*v)(p->obj, a); if (e) return e; - } - if (p->_size) { - e = (*v)(p->_size, a); if (e) return e; - } - if (p->_array_interface) { - e = (*v)(p->_array_interface, a); if (e) return e; - } - if (p->view.obj) { - e = (*v)(p->view.obj, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_memoryview(PyObject *o) { - PyObject* tmp; - struct __pyx_memoryview_obj *p = (struct __pyx_memoryview_obj *)o; - tmp = ((PyObject*)p->obj); - p->obj = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_size); - p->_size = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_array_interface); - p->_array_interface = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - Py_CLEAR(p->view.obj); - return 0; -} -static PyObject *__pyx_sq_item_memoryview(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} - -static int __pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_memoryview___setitem__(o, i, v); - } - else { - PyErr_Format(PyExc_NotImplementedError, - "Subscript deletion not supported by %.200s", Py_TYPE(o)->tp_name); - return -1; - } -} - -static PyObject *__pyx_getprop___pyx_memoryview_T(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_1T_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_base(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_4base_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_shape(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_5shape_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_strides(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_7strides_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_suboffsets(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_10suboffsets_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_ndim(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_4ndim_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_itemsize(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_8itemsize_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_nbytes(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_6nbytes_1__get__(o); -} - -static PyObject *__pyx_getprop___pyx_memoryview_size(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_10memoryview_4size_1__get__(o); -} - -static PyMethodDef __pyx_methods_memoryview[] = { - {"is_c_contig", (PyCFunction)__pyx_memoryview_is_c_contig, METH_NOARGS, 0}, - {"is_f_contig", (PyCFunction)__pyx_memoryview_is_f_contig, METH_NOARGS, 0}, - {"copy", (PyCFunction)__pyx_memoryview_copy, METH_NOARGS, 0}, - {"copy_fortran", (PyCFunction)__pyx_memoryview_copy_fortran, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_1__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryview_3__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static struct PyGetSetDef __pyx_getsets_memoryview[] = { - {(char *)"T", __pyx_getprop___pyx_memoryview_T, 0, (char *)0, 0}, - {(char *)"base", __pyx_getprop___pyx_memoryview_base, 0, (char *)0, 0}, - {(char *)"shape", __pyx_getprop___pyx_memoryview_shape, 0, (char *)0, 0}, - {(char *)"strides", __pyx_getprop___pyx_memoryview_strides, 0, (char *)0, 0}, - {(char *)"suboffsets", __pyx_getprop___pyx_memoryview_suboffsets, 0, (char *)0, 0}, - {(char *)"ndim", __pyx_getprop___pyx_memoryview_ndim, 0, (char *)0, 0}, - {(char *)"itemsize", __pyx_getprop___pyx_memoryview_itemsize, 0, (char *)0, 0}, - {(char *)"nbytes", __pyx_getprop___pyx_memoryview_nbytes, 0, (char *)0, 0}, - {(char *)"size", __pyx_getprop___pyx_memoryview_size, 0, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; - -static PySequenceMethods __pyx_tp_as_sequence_memoryview = { - __pyx_memoryview___len__, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - __pyx_sq_item_memoryview, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_memoryview = { - __pyx_memoryview___len__, /*mp_length*/ - __pyx_memoryview___getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_memoryview, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_memoryview = { - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getreadbuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getwritebuffer*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getsegcount*/ - #endif - #if PY_MAJOR_VERSION < 3 - 0, /*bf_getcharbuffer*/ - #endif - __pyx_memoryview_getbuffer, /*bf_getbuffer*/ - 0, /*bf_releasebuffer*/ -}; - -static PyTypeObject __pyx_type___pyx_memoryview = { - PyVarObject_HEAD_INIT(0, 0) - "strings_udf._lib.cudf_jit_udf.memoryview", /*tp_name*/ - sizeof(struct __pyx_memoryview_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_memoryview, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - __pyx_memoryview___repr__, /*tp_repr*/ - 0, /*tp_as_number*/ - &__pyx_tp_as_sequence_memoryview, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_memoryview, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - __pyx_memoryview___str__, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_memoryview, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_memoryview, /*tp_traverse*/ - __pyx_tp_clear_memoryview, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_memoryview, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_memoryview, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_memoryview, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif - #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 - 0, /*tp_pypy_flags*/ - #endif -}; -static struct __pyx_vtabstruct__memoryviewslice __pyx_vtable__memoryviewslice; - -static PyObject *__pyx_tp_new__memoryviewslice(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_memoryviewslice_obj *p; - PyObject *o = __pyx_tp_new_memoryview(t, a, k); - if (unlikely(!o)) return 0; - p = ((struct __pyx_memoryviewslice_obj *)o); - p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_memoryview*)__pyx_vtabptr__memoryviewslice; - p->from_object = Py_None; Py_INCREF(Py_None); - p->from_slice.memview = NULL; - return o; -} - -static void __pyx_tp_dealloc__memoryviewslice(PyObject *o) { - struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1); - __pyx_memoryviewslice___dealloc__(o); - __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1); - PyErr_Restore(etype, eval, etb); - } - Py_CLEAR(p->from_object); - PyObject_GC_Track(o); - __pyx_tp_dealloc_memoryview(o); -} - -static int __pyx_tp_traverse__memoryviewslice(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; - e = __pyx_tp_traverse_memoryview(o, v, a); if (e) return e; - if (p->from_object) { - e = (*v)(p->from_object, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear__memoryviewslice(PyObject *o) { - PyObject* tmp; - struct __pyx_memoryviewslice_obj *p = (struct __pyx_memoryviewslice_obj *)o; - __pyx_tp_clear_memoryview(o); - tmp = ((PyObject*)p->from_object); - p->from_object = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - __PYX_XDEC_MEMVIEW(&p->from_slice, 1); - return 0; -} - -static PyObject *__pyx_getprop___pyx_memoryviewslice_base(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_15View_dot_MemoryView_16_memoryviewslice_4base_1__get__(o); -} - -static PyMethodDef __pyx_methods__memoryviewslice[] = { - {"__reduce_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_1__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw___pyx_memoryviewslice_3__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static struct PyGetSetDef __pyx_getsets__memoryviewslice[] = { - {(char *)"base", __pyx_getprop___pyx_memoryviewslice_base, 0, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type___pyx_memoryviewslice = { - PyVarObject_HEAD_INIT(0, 0) - "strings_udf._lib.cudf_jit_udf._memoryviewslice", /*tp_name*/ - sizeof(struct __pyx_memoryviewslice_obj), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc__memoryviewslice, /*tp_dealloc*/ - #if PY_VERSION_HEX < 0x030800b4 - 0, /*tp_print*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 - 0, /*tp_vectorcall_offset*/ - #endif - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - #if CYTHON_COMPILING_IN_PYPY - __pyx_memoryview___repr__, /*tp_repr*/ - #else - 0, /*tp_repr*/ - #endif - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - #if CYTHON_COMPILING_IN_PYPY - __pyx_memoryview___str__, /*tp_str*/ - #else - 0, /*tp_str*/ - #endif - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - "Internal class for passing memoryview slices to Python", /*tp_doc*/ - __pyx_tp_traverse__memoryviewslice, /*tp_traverse*/ - __pyx_tp_clear__memoryviewslice, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods__memoryviewslice, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets__memoryviewslice, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new__memoryviewslice, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ - 0, /*tp_del*/ - 0, /*tp_version_tag*/ - #if PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif - #if PY_VERSION_HEX >= 0x030800b1 && (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800) - 0, /*tp_vectorcall*/ - #endif - #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000 - 0, /*tp_print*/ - #endif - #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 - 0, /*tp_pypy_flags*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec_cudf_jit_udf(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec_cudf_jit_udf}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "cudf_jit_udf", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif -#ifndef CYTHON_SMALL_CODE -#if defined(__clang__) - #define CYTHON_SMALL_CODE -#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) - #define CYTHON_SMALL_CODE __attribute__((cold)) -#else - #define CYTHON_SMALL_CODE -#endif -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_s_ASCII, __pyx_k_ASCII, sizeof(__pyx_k_ASCII), 0, 0, 1, 1}, - {&__pyx_n_s_Buffer, __pyx_k_Buffer, sizeof(__pyx_k_Buffer), 0, 0, 1, 1}, - {&__pyx_kp_s_Buffer_view_does_not_expose_stri, __pyx_k_Buffer_view_does_not_expose_stri, sizeof(__pyx_k_Buffer_view_does_not_expose_stri), 0, 0, 1, 0}, - {&__pyx_n_u_CONDA_PREFIX, __pyx_k_CONDA_PREFIX, sizeof(__pyx_k_CONDA_PREFIX), 0, 1, 0, 1}, - {&__pyx_kp_s_Can_only_create_a_buffer_that_is, __pyx_k_Can_only_create_a_buffer_that_is, sizeof(__pyx_k_Can_only_create_a_buffer_that_is), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_assign_to_read_only_memor, __pyx_k_Cannot_assign_to_read_only_memor, sizeof(__pyx_k_Cannot_assign_to_read_only_memor), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_create_writable_memory_vi, __pyx_k_Cannot_create_writable_memory_vi, sizeof(__pyx_k_Cannot_create_writable_memory_vi), 0, 0, 1, 0}, - {&__pyx_kp_s_Cannot_index_with_type_s, __pyx_k_Cannot_index_with_type_s, sizeof(__pyx_k_Cannot_index_with_type_s), 0, 0, 1, 0}, - {&__pyx_n_s_Ellipsis, __pyx_k_Ellipsis, sizeof(__pyx_k_Ellipsis), 0, 0, 1, 1}, - {&__pyx_kp_s_Empty_shape_tuple_for_cython_arr, __pyx_k_Empty_shape_tuple_for_cython_arr, sizeof(__pyx_k_Empty_shape_tuple_for_cython_arr), 0, 0, 1, 0}, - {&__pyx_kp_u_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 1, 0, 0}, - {&__pyx_kp_s_Incompatible_checksums_0x_x_vs_0, __pyx_k_Incompatible_checksums_0x_x_vs_0, sizeof(__pyx_k_Incompatible_checksums_0x_x_vs_0), 0, 0, 1, 0}, - {&__pyx_n_s_IndexError, __pyx_k_IndexError, sizeof(__pyx_k_IndexError), 0, 0, 1, 1}, - {&__pyx_kp_s_Indirect_dimensions_not_supporte, __pyx_k_Indirect_dimensions_not_supporte, sizeof(__pyx_k_Indirect_dimensions_not_supporte), 0, 0, 1, 0}, - {&__pyx_kp_s_Invalid_mode_expected_c_or_fortr, __pyx_k_Invalid_mode_expected_c_or_fortr, sizeof(__pyx_k_Invalid_mode_expected_c_or_fortr), 0, 0, 1, 0}, - {&__pyx_kp_s_Invalid_shape_in_axis_d_d, __pyx_k_Invalid_shape_in_axis_d_d, sizeof(__pyx_k_Invalid_shape_in_axis_d_d), 0, 0, 1, 0}, - {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1}, - {&__pyx_kp_s_MemoryView_of_r_at_0x_x, __pyx_k_MemoryView_of_r_at_0x_x, sizeof(__pyx_k_MemoryView_of_r_at_0x_x), 0, 0, 1, 0}, - {&__pyx_kp_s_MemoryView_of_r_object, __pyx_k_MemoryView_of_r_object, sizeof(__pyx_k_MemoryView_of_r_object), 0, 0, 1, 0}, - {&__pyx_n_b_O, __pyx_k_O, sizeof(__pyx_k_O), 0, 0, 0, 1}, - {&__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_k_Out_of_bounds_on_buffer_access_a, sizeof(__pyx_k_Out_of_bounds_on_buffer_access_a), 0, 0, 1, 0}, - {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_kp_u_UTF_8, __pyx_k_UTF_8, sizeof(__pyx_k_UTF_8), 0, 1, 0, 0}, - {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_n_s_View_MemoryView, __pyx_k_View_MemoryView, sizeof(__pyx_k_View_MemoryView), 0, 0, 1, 1}, - {&__pyx_n_s_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, - {&__pyx_n_s_buffer, __pyx_k_buffer, sizeof(__pyx_k_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1}, - {&__pyx_n_u_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 1, 0, 1}, - {&__pyx_n_s_c_buffer, __pyx_k_c_buffer, sizeof(__pyx_k_c_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_c_columns, __pyx_k_c_columns, sizeof(__pyx_k_c_columns), 0, 0, 1, 1}, - {&__pyx_n_s_c_module, __pyx_k_c_module, sizeof(__pyx_k_c_module), 0, 0, 1, 1}, - {&__pyx_n_s_c_name, __pyx_k_c_name, sizeof(__pyx_k_c_name), 0, 0, 1, 1}, - {&__pyx_n_s_c_options, __pyx_k_c_options, sizeof(__pyx_k_c_options), 0, 0, 1, 1}, - {&__pyx_n_s_c_result, __pyx_k_c_result, sizeof(__pyx_k_c_result), 0, 0, 1, 1}, - {&__pyx_n_s_c_size, __pyx_k_c_size, sizeof(__pyx_k_c_size), 0, 0, 1, 1}, - {&__pyx_n_s_c_udf, __pyx_k_c_udf, sizeof(__pyx_k_c_udf), 0, 0, 1, 1}, - {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_col, __pyx_k_col, sizeof(__pyx_k_col), 0, 0, 1, 1}, - {&__pyx_n_s_cols, __pyx_k_cols, sizeof(__pyx_k_cols), 0, 0, 1, 1}, - {&__pyx_n_s_column, __pyx_k_column, sizeof(__pyx_k_column), 0, 0, 1, 1}, - {&__pyx_kp_s_contiguous_and_direct, __pyx_k_contiguous_and_direct, sizeof(__pyx_k_contiguous_and_direct), 0, 0, 1, 0}, - {&__pyx_kp_s_contiguous_and_indirect, __pyx_k_contiguous_and_indirect, sizeof(__pyx_k_contiguous_and_indirect), 0, 0, 1, 0}, - {&__pyx_n_s_cudf_core_buffer, __pyx_k_cudf_core_buffer, sizeof(__pyx_k_cudf_core_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_d_buffer, __pyx_k_d_buffer, sizeof(__pyx_k_d_buffer), 0, 0, 1, 1}, - {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1}, - {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1}, - {&__pyx_n_s_dtype_is_object, __pyx_k_dtype_is_object, sizeof(__pyx_k_dtype_is_object), 0, 0, 1, 1}, - {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, - {&__pyx_n_s_enumerate, __pyx_k_enumerate, sizeof(__pyx_k_enumerate), 0, 0, 1, 1}, - {&__pyx_n_s_environ, __pyx_k_environ, sizeof(__pyx_k_environ), 0, 0, 1, 1}, - {&__pyx_n_s_error, __pyx_k_error, sizeof(__pyx_k_error), 0, 0, 1, 1}, - {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1}, - {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1}, - {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, - {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, - {&__pyx_n_s_from_dstring_array, __pyx_k_from_dstring_array, sizeof(__pyx_k_from_dstring_array), 0, 0, 1, 1}, - {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1}, - {&__pyx_n_s_get_character_flags_table_ptr, __pyx_k_get_character_flags_table_ptr, sizeof(__pyx_k_get_character_flags_table_ptr), 0, 0, 1, 1}, - {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, - {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, - {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_kp_u_include, __pyx_k_include, sizeof(__pyx_k_include), 0, 1, 0, 0}, - {&__pyx_n_s_include_path, __pyx_k_include_path, sizeof(__pyx_k_include_path), 0, 0, 1, 1}, - {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1}, - {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, - {&__pyx_kp_s_itemsize_0_for_cython_array, __pyx_k_itemsize_0_for_cython_array, sizeof(__pyx_k_itemsize_0_for_cython_array), 0, 0, 1, 0}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_memview, __pyx_k_memview, sizeof(__pyx_k_memview), 0, 0, 1, 1}, - {&__pyx_n_s_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_name_2, __pyx_k_name_2, sizeof(__pyx_k_name_2), 0, 0, 1, 1}, - {&__pyx_n_s_ndim, __pyx_k_ndim, sizeof(__pyx_k_ndim), 0, 0, 1, 1}, - {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1}, - {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, - {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, - {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1}, - {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1}, - {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, - {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1}, - {&__pyx_n_s_process_udf, __pyx_k_process_udf, sizeof(__pyx_k_process_udf), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_getbuffer, __pyx_k_pyx_getbuffer, sizeof(__pyx_k_pyx_getbuffer), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_unpickle_Enum, __pyx_k_pyx_unpickle_Enum, sizeof(__pyx_k_pyx_unpickle_Enum), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, - {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, - {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, - {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, - {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, - {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1}, - {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1}, - {&__pyx_n_s_step, __pyx_k_step, sizeof(__pyx_k_step), 0, 0, 1, 1}, - {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1}, - {&__pyx_kp_s_strided_and_direct, __pyx_k_strided_and_direct, sizeof(__pyx_k_strided_and_direct), 0, 0, 1, 0}, - {&__pyx_kp_s_strided_and_direct_or_indirect, __pyx_k_strided_and_direct_or_indirect, sizeof(__pyx_k_strided_and_direct_or_indirect), 0, 0, 1, 0}, - {&__pyx_kp_s_strided_and_indirect, __pyx_k_strided_and_indirect, sizeof(__pyx_k_strided_and_indirect), 0, 0, 1, 0}, - {&__pyx_n_s_strings_col, __pyx_k_strings_col, sizeof(__pyx_k_strings_col), 0, 0, 1, 1}, - {&__pyx_n_s_strings_udf__lib_cudf_jit_udf, __pyx_k_strings_udf__lib_cudf_jit_udf, sizeof(__pyx_k_strings_udf__lib_cudf_jit_udf), 0, 0, 1, 1}, - {&__pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_k_strings_udf__lib_cudf_jit_udf_py, sizeof(__pyx_k_strings_udf__lib_cudf_jit_udf_py), 0, 0, 1, 0}, - {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0}, - {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, - {&__pyx_n_s_tbl_ptr, __pyx_k_tbl_ptr, sizeof(__pyx_k_tbl_ptr), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_to_string_view_array, __pyx_k_to_string_view_array, sizeof(__pyx_k_to_string_view_array), 0, 0, 1, 1}, - {&__pyx_n_s_udf, __pyx_k_udf, sizeof(__pyx_k_udf), 0, 0, 1, 1}, - {&__pyx_kp_s_unable_to_allocate_array_data, __pyx_k_unable_to_allocate_array_data, sizeof(__pyx_k_unable_to_allocate_array_data), 0, 0, 1, 0}, - {&__pyx_kp_s_unable_to_allocate_shape_and_str, __pyx_k_unable_to_allocate_shape_and_str, sizeof(__pyx_k_unable_to_allocate_shape_and_str), 0, 0, 1, 0}, - {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, - {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(1, 133, __pyx_L1_error) - __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(1, 148, __pyx_L1_error) - __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(1, 151, __pyx_L1_error) - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(1, 180, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) - __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) __PYX_ERR(1, 404, __pyx_L1_error) - __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) __PYX_ERR(1, 613, __pyx_L1_error) - __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) __PYX_ERR(1, 832, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "View.MemoryView":133 - * - * if not self.ndim: - * raise ValueError("Empty shape tuple for cython.array") # <<<<<<<<<<<<<< - * - * if itemsize <= 0: - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Empty_shape_tuple_for_cython_arr); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "View.MemoryView":136 - * - * if itemsize <= 0: - * raise ValueError("itemsize <= 0 for cython.array") # <<<<<<<<<<<<<< - * - * if not isinstance(format, bytes): - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_itemsize_0_for_cython_array); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "View.MemoryView":148 - * - * if not self._shape: - * raise MemoryError("unable to allocate shape and strides.") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_shape_and_str); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "View.MemoryView":176 - * self.data = malloc(self.len) - * if not self.data: - * raise MemoryError("unable to allocate array data.") # <<<<<<<<<<<<<< - * - * if self.dtype_is_object: - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_unable_to_allocate_array_data); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "View.MemoryView":192 - * bufmode = PyBUF_F_CONTIGUOUS | PyBUF_ANY_CONTIGUOUS - * if not (flags & bufmode): - * raise ValueError("Can only create a buffer that is contiguous in memory.") # <<<<<<<<<<<<<< - * info.buf = self.data - * info.len = self.len - */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Can_only_create_a_buffer_that_is); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__5); - __Pyx_GIVEREF(__pyx_tuple__5); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - - /* "View.MemoryView":418 - * def __setitem__(memoryview self, object index, object value): - * if self.view.readonly: - * raise TypeError("Cannot assign to read-only memoryview") # <<<<<<<<<<<<<< - * - * have_slices, index = _unellipsify(index, self.view.ndim) - */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_Cannot_assign_to_read_only_memor); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(1, 418, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - - /* "View.MemoryView":495 - * result = struct.unpack(self.view.format, bytesitem) - * except struct.error: - * raise ValueError("Unable to convert item to object") # <<<<<<<<<<<<<< - * else: - * if len(self.view.format) == 1: - */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Unable_to_convert_item_to_object); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(1, 495, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); - - /* "View.MemoryView":520 - * def __getbuffer__(self, Py_buffer *info, int flags): - * if flags & PyBUF_WRITABLE and self.view.readonly: - * raise ValueError("Cannot create writable memory view from read-only memoryview") # <<<<<<<<<<<<<< - * - * if flags & PyBUF_ND: - */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_Cannot_create_writable_memory_vi); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(1, 520, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - - /* "View.MemoryView":570 - * if self.view.strides == NULL: - * - * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< - * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) - */ - __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(1, 570, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__11); - __Pyx_GIVEREF(__pyx_tuple__11); - - /* "View.MemoryView":577 - * def suboffsets(self): - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< - * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) - */ - __pyx_tuple__12 = PyTuple_New(1); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(1, 577, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_INCREF(__pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__12, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__12); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__13); - __Pyx_GIVEREF(__pyx_tuple__13); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); - - /* "View.MemoryView":682 - * if item is Ellipsis: - * if not seen_ellipsis: - * result.extend([slice(None)] * (ndim - len(tup) + 1)) # <<<<<<<<<<<<<< - * seen_ellipsis = True - * else: - */ - __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) __PYX_ERR(1, 682, __pyx_L1_error) - __Pyx_GOTREF(__pyx_slice__15); - __Pyx_GIVEREF(__pyx_slice__15); - - /* "View.MemoryView":703 - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: - * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(1, 703, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__18); - __Pyx_GIVEREF(__pyx_tuple__18); - __pyx_tuple__19 = PyTuple_Pack(3, __pyx_int_184977713, __pyx_int_136983863, __pyx_int_112105877); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - - /* "strings_udf/_lib/cudf_jit_udf.pyx":35 - * import numpy as np - * - * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< - * cdef string c_udf - * cdef string c_name - */ - __pyx_tuple__20 = PyTuple_Pack(13, __pyx_n_s_udf, __pyx_n_s_name, __pyx_n_s_cols, __pyx_n_s_c_udf, __pyx_n_s_c_name, __pyx_n_s_c_size, __pyx_n_s_c_columns, __pyx_n_s_c_module, __pyx_n_s_c_options, __pyx_n_s_c_result, __pyx_n_s_col, __pyx_n_s_c, __pyx_n_s_include_path); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); - __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(3, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_process_udf, 35, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 35, __pyx_L1_error) - - /* "strings_udf/_lib/cudf_jit_udf.pyx":68 - * - * - * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< - * cdef unique_ptr[device_buffer] c_buffer - * - */ - __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_strings_col, __pyx_n_s_c_buffer, __pyx_n_s_buffer); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_to_string_view_array, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 68, __pyx_L1_error) - - /* "strings_udf/_lib/cudf_jit_udf.pyx":79 - * - * - * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< - * cdef size_t size = d_buffer.c_size() - * cdef void* data = d_buffer.c_data() - */ - __pyx_tuple__24 = PyTuple_Pack(4, __pyx_n_s_d_buffer, __pyx_n_s_size, __pyx_n_s_data, __pyx_n_s_c_result); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__24); - __Pyx_GIVEREF(__pyx_tuple__24); - __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_from_dstring_array, 79, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 79, __pyx_L1_error) - - /* "strings_udf/_lib/cudf_jit_udf.pyx":90 - * return Column.from_unique_ptr(move(c_result)) - * - * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< - * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() - * return np.int64(tbl_ptr) - */ - __pyx_tuple__26 = PyTuple_Pack(1, __pyx_n_s_tbl_ptr); if (unlikely(!__pyx_tuple__26)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__26); - __Pyx_GIVEREF(__pyx_tuple__26); - __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_strings_udf__lib_cudf_jit_udf_py, __pyx_n_s_get_character_flags_table_ptr, 90, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) __PYX_ERR(0, 90, __pyx_L1_error) - - /* "View.MemoryView":286 - * return self.name - * - * cdef generic = Enum("") # <<<<<<<<<<<<<< - * cdef strided = Enum("") # default - * cdef indirect = Enum("") - */ - __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(1, 286, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__28); - __Pyx_GIVEREF(__pyx_tuple__28); - - /* "View.MemoryView":287 - * - * cdef generic = Enum("") - * cdef strided = Enum("") # default # <<<<<<<<<<<<<< - * cdef indirect = Enum("") - * - */ - __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(1, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); - - /* "View.MemoryView":288 - * cdef generic = Enum("") - * cdef strided = Enum("") # default - * cdef indirect = Enum("") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(1, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__30); - __Pyx_GIVEREF(__pyx_tuple__30); - - /* "View.MemoryView":291 - * - * - * cdef contiguous = Enum("") # <<<<<<<<<<<<<< - * cdef indirect_contiguous = Enum("") - * - */ - __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(1, 291, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); - - /* "View.MemoryView":292 - * - * cdef contiguous = Enum("") - * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__32)) __PYX_ERR(1, 292, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); - - /* "(tree fragment)":1 - * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< - * cdef object __pyx_PickleError - * cdef object __pyx_result - */ - __pyx_tuple__33 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(1, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__33); - __Pyx_GIVEREF(__pyx_tuple__33); - __pyx_codeobj__34 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__33, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_Enum, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__34)) __PYX_ERR(1, 1, __pyx_L1_error) - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_112105877 = PyInt_FromLong(112105877L); if (unlikely(!__pyx_int_112105877)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_136983863 = PyInt_FromLong(136983863L); if (unlikely(!__pyx_int_136983863)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_184977713 = PyInt_FromLong(184977713L); if (unlikely(!__pyx_int_184977713)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/ -static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/ - -static int __Pyx_modinit_global_init_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); - /*--- Global init code ---*/ - generic = Py_None; Py_INCREF(Py_None); - strided = Py_None; Py_INCREF(Py_None); - indirect = Py_None; Py_INCREF(Py_None); - contiguous = Py_None; Py_INCREF(Py_None); - indirect_contiguous = Py_None; Py_INCREF(Py_None); - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_variable_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); - /*--- Variable export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_export_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); - /*--- Function export code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_type_init_code(void) { - __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); - /*--- Type init code ---*/ - __pyx_vtabptr_array = &__pyx_vtable_array; - __pyx_vtable_array.get_memview = (PyObject *(*)(struct __pyx_array_obj *))__pyx_array_get_memview; - if (PyType_Ready(&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type___pyx_array.tp_print = 0; - #endif - if (__Pyx_SetVtable(__pyx_type___pyx_array.tp_dict, __pyx_vtabptr_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_array) < 0) __PYX_ERR(1, 105, __pyx_L1_error) - __pyx_array_type = &__pyx_type___pyx_array; - if (PyType_Ready(&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type___pyx_MemviewEnum.tp_print = 0; - #endif - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_MemviewEnum.tp_dictoffset && __pyx_type___pyx_MemviewEnum.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type___pyx_MemviewEnum.tp_getattro = __Pyx_PyObject_GenericGetAttr; - } - if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_MemviewEnum) < 0) __PYX_ERR(1, 279, __pyx_L1_error) - __pyx_MemviewEnum_type = &__pyx_type___pyx_MemviewEnum; - __pyx_vtabptr_memoryview = &__pyx_vtable_memoryview; - __pyx_vtable_memoryview.get_item_pointer = (char *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_get_item_pointer; - __pyx_vtable_memoryview.is_slice = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_is_slice; - __pyx_vtable_memoryview.setitem_slice_assignment = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_slice_assignment; - __pyx_vtable_memoryview.setitem_slice_assign_scalar = (PyObject *(*)(struct __pyx_memoryview_obj *, struct __pyx_memoryview_obj *, PyObject *))__pyx_memoryview_setitem_slice_assign_scalar; - __pyx_vtable_memoryview.setitem_indexed = (PyObject *(*)(struct __pyx_memoryview_obj *, PyObject *, PyObject *))__pyx_memoryview_setitem_indexed; - __pyx_vtable_memoryview.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryview_convert_item_to_object; - __pyx_vtable_memoryview.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryview_assign_item_from_object; - if (PyType_Ready(&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type___pyx_memoryview.tp_print = 0; - #endif - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryview.tp_dictoffset && __pyx_type___pyx_memoryview.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type___pyx_memoryview.tp_getattro = __Pyx_PyObject_GenericGetAttr; - } - if (__Pyx_SetVtable(__pyx_type___pyx_memoryview.tp_dict, __pyx_vtabptr_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryview) < 0) __PYX_ERR(1, 330, __pyx_L1_error) - __pyx_memoryview_type = &__pyx_type___pyx_memoryview; - __pyx_vtabptr__memoryviewslice = &__pyx_vtable__memoryviewslice; - __pyx_vtable__memoryviewslice.__pyx_base = *__pyx_vtabptr_memoryview; - __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object; - __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object; - __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type; - if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error) - #if PY_VERSION_HEX < 0x030800B1 - __pyx_type___pyx_memoryviewslice.tp_print = 0; - #endif - if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type___pyx_memoryviewslice.tp_dictoffset && __pyx_type___pyx_memoryviewslice.tp_getattro == PyObject_GenericGetAttr)) { - __pyx_type___pyx_memoryviewslice.tp_getattro = __Pyx_PyObject_GenericGetAttr; - } - if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type___pyx_memoryviewslice) < 0) __PYX_ERR(1, 965, __pyx_L1_error) - __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_type_import_code(void) { - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); - /*--- Type import code ---*/ - __pyx_t_1 = PyImport_ImportModule("rmm._cuda.stream"); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_3rmm_5_cuda_6stream_Stream = __Pyx_ImportType(__pyx_t_1, "rmm._cuda.stream", "Stream", sizeof(struct __pyx_obj_3rmm_5_cuda_6stream_Stream), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_5_cuda_6stream_Stream) __PYX_ERR(2, 22, __pyx_L1_error) - __pyx_vtabptr_3rmm_5_cuda_6stream_Stream = (struct __pyx_vtabstruct_3rmm_5_cuda_6stream_Stream*)__Pyx_GetVtable(__pyx_ptype_3rmm_5_cuda_6stream_Stream->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_5_cuda_6stream_Stream)) __PYX_ERR(2, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("rmm._lib.memory_resource"); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "DeviceMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_DeviceMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource) __PYX_ERR(3, 27, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_DeviceMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_DeviceMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_DeviceMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_DeviceMemoryResource)) __PYX_ERR(3, 27, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "UpstreamResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor) __PYX_ERR(3, 31, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_UpstreamResourceAdaptor)) __PYX_ERR(3, 31, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "CudaMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource) __PYX_ERR(3, 36, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_CudaMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaMemoryResource)) __PYX_ERR(3, 36, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "ManagedMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_ManagedMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource) __PYX_ERR(3, 39, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_ManagedMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_ManagedMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_ManagedMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_ManagedMemoryResource)) __PYX_ERR(3, 39, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "CudaAsyncMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource) __PYX_ERR(3, 42, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_CudaAsyncMemoryResource)) __PYX_ERR(3, 42, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "PoolMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_PoolMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource) __PYX_ERR(3, 45, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_PoolMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_PoolMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_PoolMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_PoolMemoryResource)) __PYX_ERR(3, 45, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "FixedSizeMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource) __PYX_ERR(3, 48, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_FixedSizeMemoryResource)) __PYX_ERR(3, 48, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "BinningMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_BinningMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource) __PYX_ERR(3, 51, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_BinningMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_BinningMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_BinningMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_BinningMemoryResource)) __PYX_ERR(3, 51, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "CallbackMemoryResource", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_CallbackMemoryResource), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource) __PYX_ERR(3, 60, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_CallbackMemoryResource = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_CallbackMemoryResource*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_CallbackMemoryResource->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_CallbackMemoryResource)) __PYX_ERR(3, 60, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "LoggingResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor) __PYX_ERR(3, 64, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_LoggingResourceAdaptor)) __PYX_ERR(3, 64, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "StatisticsResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor) __PYX_ERR(3, 69, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_StatisticsResourceAdaptor)) __PYX_ERR(3, 69, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "TrackingResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor) __PYX_ERR(3, 72, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_TrackingResourceAdaptor)) __PYX_ERR(3, 72, __pyx_L1_error) - __pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor = __Pyx_ImportType(__pyx_t_1, "rmm._lib.memory_resource", "FailureCallbackResourceAdaptor", sizeof(struct __pyx_obj_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor) __PYX_ERR(3, 75, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor = (struct __pyx_vtabstruct_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_15memory_resource_FailureCallbackResourceAdaptor)) __PYX_ERR(3, 75, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("rmm._lib.device_buffer"); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 36, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer = __Pyx_ImportType(__pyx_t_1, "rmm._lib.device_buffer", "DeviceBuffer", sizeof(struct __pyx_obj_3rmm_4_lib_13device_buffer_DeviceBuffer), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer) __PYX_ERR(4, 36, __pyx_L1_error) - __pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer = (struct __pyx_vtabstruct_3rmm_4_lib_13device_buffer_DeviceBuffer*)__Pyx_GetVtable(__pyx_ptype_3rmm_4_lib_13device_buffer_DeviceBuffer->tp_dict); if (unlikely(!__pyx_vtabptr_3rmm_4_lib_13device_buffer_DeviceBuffer)) __PYX_ERR(4, 36, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyImport_ImportModule("cudf._lib.column"); if (unlikely(!__pyx_t_1)) __PYX_ERR(5, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_ptype_4cudf_4_lib_6column_Column = __Pyx_ImportType(__pyx_t_1, "cudf._lib.column", "Column", sizeof(struct __pyx_obj_4cudf_4_lib_6column_Column), __Pyx_ImportType_CheckSize_Warn); - if (!__pyx_ptype_4cudf_4_lib_6column_Column) __PYX_ERR(5, 13, __pyx_L1_error) - __pyx_vtabptr_4cudf_4_lib_6column_Column = (struct __pyx_vtabstruct_4cudf_4_lib_6column_Column*)__Pyx_GetVtable(__pyx_ptype_4cudf_4_lib_6column_Column->tp_dict); if (unlikely(!__pyx_vtabptr_4cudf_4_lib_6column_Column)) __PYX_ERR(5, 13, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_modinit_variable_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); - /*--- Variable import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - -static int __Pyx_modinit_function_import_code(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); - /*--- Function import code ---*/ - __Pyx_RefNannyFinishContext(); - return 0; -} - - -#ifndef CYTHON_NO_PYINIT_EXPORT -#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC -#elif PY_MAJOR_VERSION < 3 -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" void -#else -#define __Pyx_PyMODINIT_FUNC void -#endif -#else -#ifdef __cplusplus -#define __Pyx_PyMODINIT_FUNC extern "C" PyObject * -#else -#define __Pyx_PyMODINIT_FUNC PyObject * -#endif -#endif - - -#if PY_MAJOR_VERSION < 3 -__Pyx_PyMODINIT_FUNC initcudf_jit_udf(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC initcudf_jit_udf(void) -#else -__Pyx_PyMODINIT_FUNC PyInit_cudf_jit_udf(void) CYTHON_SMALL_CODE; /*proto*/ -__Pyx_PyMODINIT_FUNC PyInit_cudf_jit_udf(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) { - #if PY_VERSION_HEX >= 0x030700A1 - static PY_INT64_T main_interpreter_id = -1; - PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp); - if (main_interpreter_id == -1) { - main_interpreter_id = current_id; - return (unlikely(current_id == -1)) ? -1 : 0; - } else if (unlikely(main_interpreter_id != current_id)) - #else - static PyInterpreterState *main_interpreter = NULL; - PyInterpreterState *current_interpreter = PyThreadState_Get()->interp; - if (!main_interpreter) { - main_interpreter = current_interpreter; - } else if (unlikely(main_interpreter != current_interpreter)) - #endif - { - PyErr_SetString( - PyExc_ImportError, - "Interpreter change detected - this module can only be loaded into one interpreter per process."); - return -1; - } - return 0; -} -static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - if (allow_none || value != Py_None) { - result = PyDict_SetItemString(moddict, to_name, value); - } - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - if (__Pyx_check_single_interpreter()) - return NULL; - if (__pyx_m) - return __Pyx_NewRef(__pyx_m); - modname = PyObject_GetAttrString(spec, "name"); - if (unlikely(!modname)) goto bad; - module = PyModule_NewObject(modname); - Py_DECREF(modname); - if (unlikely(!module)) goto bad; - moddict = PyModule_GetDict(module); - if (unlikely(!moddict)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static CYTHON_SMALL_CODE int __pyx_pymod_exec_cudf_jit_udf(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - static PyThread_type_lock __pyx_t_3[8]; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m) { - if (__pyx_m == __pyx_pyinit_module) return 0; - PyErr_SetString(PyExc_RuntimeError, "Module 'cudf_jit_udf' has already been imported. Re-initialisation is not supported."); - return -1; - } - #elif PY_MAJOR_VERSION >= 3 - if (__pyx_m) return __Pyx_NewRef(__pyx_m); - #endif - #if CYTHON_REFNANNY -__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); -if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); -} -#endif - __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cudf_jit_udf(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pxy_PyFrame_Initialize_Offsets - __Pxy_PyFrame_Initialize_Offsets(); - #endif - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(WITH_THREAD) && PY_VERSION_HEX < 0x030700F0 && defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - PyEval_InitThreads(); - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("cudf_jit_udf", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_b); - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_cython_runtime); - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_strings_udf___lib__cudf_jit_udf) { - if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name_2, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "strings_udf._lib.cudf_jit_udf")) { - if (unlikely(PyDict_SetItemString(modules, "strings_udf._lib.cudf_jit_udf", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global type/function init code ---*/ - (void)__Pyx_modinit_global_init_code(); - (void)__Pyx_modinit_variable_export_code(); - (void)__Pyx_modinit_function_export_code(); - if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - (void)__Pyx_modinit_variable_import_code(); - (void)__Pyx_modinit_function_import_code(); - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "strings_udf/_lib/cudf_jit_udf.pyx":6 - * # cython: c_string_type=unicode, c_string_encoding=utf8 - * - * import os # <<<<<<<<<<<<<< - * - * from libcpp.string cimport string - */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":13 - * from libcpp.utility cimport move - * - * from cudf.core.buffer import Buffer # <<<<<<<<<<<<<< - * - * from cudf._lib.cpp.column.column cimport column - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_Buffer); - __Pyx_GIVEREF(__pyx_n_s_Buffer); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Buffer); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_cudf_core_buffer, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_Buffer, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":33 - * from libc.stdint cimport uintptr_t, uint8_t - * - * import numpy as np # <<<<<<<<<<<<<< - * - * def process_udf( udf, name, cols ): - */ - __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":35 - * import numpy as np - * - * def process_udf( udf, name, cols ): # <<<<<<<<<<<<<< - * cdef string c_udf - * cdef string c_name - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_1process_udf, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_process_udf, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":68 - * - * - * def to_string_view_array(Column strings_col): # <<<<<<<<<<<<<< - * cdef unique_ptr[device_buffer] c_buffer - * - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_3to_string_view_array, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_string_view_array, __pyx_t_2) < 0) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":79 - * - * - * def from_dstring_array(DeviceBuffer d_buffer): # <<<<<<<<<<<<<< - * cdef size_t size = d_buffer.c_size() - * cdef void* data = d_buffer.c_data() - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_5from_dstring_array, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_from_dstring_array, __pyx_t_2) < 0) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":90 - * return Column.from_unique_ptr(move(c_result)) - * - * def get_character_flags_table_ptr(): # <<<<<<<<<<<<<< - * cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() - * return np.int64(tbl_ptr) - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_11strings_udf_4_lib_12cudf_jit_udf_7get_character_flags_table_ptr, NULL, __pyx_n_s_strings_udf__lib_cudf_jit_udf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_character_flags_table_ptr, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "strings_udf/_lib/cudf_jit_udf.pyx":1 - * # Copyright (c) 2021-2022, NVIDIA CORPORATION. # <<<<<<<<<<<<<< - * # - * # distutils: language = c++ - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "View.MemoryView":209 - * info.obj = self - * - * __pyx_getbuffer = capsule( &__pyx_array_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< - * - * def __dealloc__(array self): - */ - __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_array_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem((PyObject *)__pyx_array_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(1, 209, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - PyType_Modified(__pyx_array_type); - - /* "View.MemoryView":286 - * return self.name - * - * cdef generic = Enum("") # <<<<<<<<<<<<<< - * cdef strided = Enum("") # default - * cdef indirect = Enum("") - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 286, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(generic); - __Pyx_DECREF_SET(generic, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":287 - * - * cdef generic = Enum("") - * cdef strided = Enum("") # default # <<<<<<<<<<<<<< - * cdef indirect = Enum("") - * - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 287, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(strided); - __Pyx_DECREF_SET(strided, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":288 - * cdef generic = Enum("") - * cdef strided = Enum("") # default - * cdef indirect = Enum("") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(indirect); - __Pyx_DECREF_SET(indirect, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":291 - * - * - * cdef contiguous = Enum("") # <<<<<<<<<<<<<< - * cdef indirect_contiguous = Enum("") - * - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 291, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(contiguous); - __Pyx_DECREF_SET(contiguous, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":292 - * - * cdef contiguous = Enum("") - * cdef indirect_contiguous = Enum("") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_MemviewEnum_type), __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 292, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(indirect_contiguous); - __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - - /* "View.MemoryView":316 - * - * DEF THREAD_LOCKS_PREALLOCATED = 8 - * cdef int __pyx_memoryview_thread_locks_used = 0 # <<<<<<<<<<<<<< - * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ - * PyThread_allocate_lock(), - */ - __pyx_memoryview_thread_locks_used = 0; - - /* "View.MemoryView":317 - * DEF THREAD_LOCKS_PREALLOCATED = 8 - * cdef int __pyx_memoryview_thread_locks_used = 0 - * cdef PyThread_type_lock[THREAD_LOCKS_PREALLOCATED] __pyx_memoryview_thread_locks = [ # <<<<<<<<<<<<<< - * PyThread_allocate_lock(), - * PyThread_allocate_lock(), - */ - __pyx_t_3[0] = PyThread_allocate_lock(); - __pyx_t_3[1] = PyThread_allocate_lock(); - __pyx_t_3[2] = PyThread_allocate_lock(); - __pyx_t_3[3] = PyThread_allocate_lock(); - __pyx_t_3[4] = PyThread_allocate_lock(); - __pyx_t_3[5] = PyThread_allocate_lock(); - __pyx_t_3[6] = PyThread_allocate_lock(); - __pyx_t_3[7] = PyThread_allocate_lock(); - memcpy(&(__pyx_memoryview_thread_locks[0]), __pyx_t_3, sizeof(__pyx_memoryview_thread_locks[0]) * (8)); - - /* "View.MemoryView":549 - * info.obj = self - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 549, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem((PyObject *)__pyx_memoryview_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(1, 549, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - PyType_Modified(__pyx_memoryview_type); - - /* "View.MemoryView":995 - * return self.from_object - * - * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), ((char *)"getbuffer(obj, view, flags)")); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 995, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem((PyObject *)__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) __PYX_ERR(1, 995, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - PyType_Modified(__pyx_memoryviewslice_type); - - /* "(tree fragment)":1 - * def __pyx_unpickle_Enum(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<< - * cdef object __pyx_PickleError - * cdef object __pyx_result - */ - __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_15View_dot_MemoryView_1__pyx_unpickle_Enum, NULL, __pyx_n_s_View_MemoryView); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_Enum, __pyx_t_2) < 0) __PYX_ERR(1, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "(tree fragment)":11 - * __pyx_unpickle_Enum__set_state( __pyx_result, __pyx_state) - * return __pyx_result - * cdef __pyx_unpickle_Enum__set_state(Enum __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<< - * __pyx_result.name = __pyx_state[0] - * if len(__pyx_state) > 1 and hasattr(__pyx_result, '__dict__'): - */ - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init strings_udf._lib.cudf_jit_udf", __pyx_clineno, __pyx_lineno, __pyx_filename); - } - Py_CLEAR(__pyx_m); - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init strings_udf._lib.cudf_jit_udf"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- Runtime support code --- */ -/* Refnanny */ -#if CYTHON_REFNANNY -static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { - PyObject *m = NULL, *p = NULL; - void *r = NULL; - m = PyImport_ImportModule(modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, "RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* RaiseArgTupleInvalid */ -static void __Pyx_RaiseArgtupleInvalid( - const char* func_name, - int exact, - Py_ssize_t num_min, - Py_ssize_t num_max, - Py_ssize_t num_found) -{ - Py_ssize_t num_expected; - const char *more_or_less; - if (num_found < num_min) { - num_expected = num_min; - more_or_less = "at least"; - } else { - num_expected = num_max; - more_or_less = "at most"; - } - if (exact) { - more_or_less = "exactly"; - } - PyErr_Format(PyExc_TypeError, - "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", - func_name, more_or_less, num_expected, - (num_expected == 1) ? "" : "s", num_found); -} - -/* RaiseDoubleKeywords */ -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - return 0; -arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, key); - goto bad; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - goto bad; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* PyObjectGetAttrStr */ -#if CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#endif - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = __Pyx_PyFrame_GetLocalsplus(f); - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, (int)nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = Py_TYPE(func)->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = (*call)(func, arg, kw); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCall2Args */ -static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) { - PyObject *args, *result = NULL; - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyFunction_FastCall(function, args, 2); - } - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(function)) { - PyObject *args[2] = {arg1, arg2}; - return __Pyx_PyCFunction_FastCall(function, args, 2); - } - #endif - args = PyTuple_New(2); - if (unlikely(!args)) goto done; - Py_INCREF(arg1); - PyTuple_SET_ITEM(args, 0, arg1); - Py_INCREF(arg2); - PyTuple_SET_ITEM(args, 1, arg2); - Py_INCREF(function); - result = __Pyx_PyObject_Call(function, args, NULL); - Py_DECREF(args); - Py_DECREF(function); -done: - return result; -} - -/* PyObjectCallMethO */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { - PyObject *self, *result; - PyCFunction cfunc; - cfunc = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) - return NULL; - result = cfunc(self, arg); - Py_LeaveRecursiveCall(); - if (unlikely(!result) && unlikely(!PyErr_Occurred())) { - PyErr_SetString( - PyExc_SystemError, - "NULL result without error in PyObject_Call"); - } - return result; -} -#endif - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (__Pyx_PyFastCFunction_Check(func)) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* GetItemInt */ -static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!j) return NULL; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyTuple_GET_SIZE(o); - } - if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* ExtTypeTest */ -static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - if (likely(__Pyx_TypeCheck(obj, type))) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", - Py_TYPE(obj)->tp_name, type->tp_name); - return 0; -} - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* PyDictVersioning */ -#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS -static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0; -} -static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) { - PyObject **dictptr = NULL; - Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset; - if (offset) { -#if CYTHON_COMPILING_IN_CPYTHON - dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj); -#else - dictptr = _PyObject_GetDictPtr(obj); -#endif - } - return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0; -} -static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) { - PyObject *dict = Py_TYPE(obj)->tp_dict; - if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict))) - return 0; - return obj_dict_version == __Pyx_get_object_dict_version(obj); -} -#endif - -/* GetModuleGlobalName */ -#if CYTHON_USE_DICT_VERSIONS -static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value) -#else -static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name) -#endif -{ - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS -#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 - result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } else if (unlikely(PyErr_Occurred())) { - return NULL; - } -#else - result = PyDict_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } -#endif -#else - result = PyObject_GetItem(__pyx_d, name); - __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version) - if (likely(result)) { - return __Pyx_NewRef(result); - } - PyErr_Clear(); -#endif - return __Pyx_GetBuiltinName(name); -} - -/* ArgTypeTest */ -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* PyErrFetchRestore */ -#if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - tmp_type = tstate->curexc_type; - tmp_value = tstate->curexc_value; - tmp_tb = tstate->curexc_traceback; - tstate->curexc_type = type; - tstate->curexc_value = value; - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *type = tstate->curexc_type; - *value = tstate->curexc_value; - *tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -} -#endif - -/* RaiseException */ -#if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { - PyObject* owned_instance = NULL; - if (tb == Py_None) { - tb = 0; - } else if (tb && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto bad; - } - if (value == Py_None) - value = 0; - if (PyExceptionInstance_Check(type)) { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto bad; - } - value = type; - type = (PyObject*) Py_TYPE(value); - } else if (PyExceptionClass_Check(type)) { - PyObject *instance_class = NULL; - if (value && PyExceptionInstance_Check(value)) { - instance_class = (PyObject*) Py_TYPE(value); - if (instance_class != type) { - int is_subclass = PyObject_IsSubclass(instance_class, type); - if (!is_subclass) { - instance_class = NULL; - } else if (unlikely(is_subclass == -1)) { - goto bad; - } else { - type = instance_class; - } - } - } - if (!instance_class) { - PyObject *args; - if (!value) - args = PyTuple_New(0); - else if (PyTuple_Check(value)) { - Py_INCREF(value); - args = value; - } else - args = PyTuple_Pack(1, value); - if (!args) - goto bad; - owned_instance = PyObject_Call(type, args, NULL); - Py_DECREF(args); - if (!owned_instance) - goto bad; - value = owned_instance; - if (!PyExceptionInstance_Check(value)) { - PyErr_Format(PyExc_TypeError, - "calling %R should have returned an instance of " - "BaseException, not %R", - type, Py_TYPE(value)); - goto bad; - } - } - } else { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto bad; - } - if (cause) { - PyObject *fixed_cause; - if (cause == Py_None) { - fixed_cause = NULL; - } else if (PyExceptionClass_Check(cause)) { - fixed_cause = PyObject_CallObject(cause, NULL); - if (fixed_cause == NULL) - goto bad; - } else if (PyExceptionInstance_Check(cause)) { - fixed_cause = cause; - Py_INCREF(fixed_cause); - } else { - PyErr_SetString(PyExc_TypeError, - "exception causes must derive from " - "BaseException"); - goto bad; - } - PyException_SetCause(value, fixed_cause); - } - PyErr_SetObject(type, value); - if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* tmp_tb = tstate->curexc_traceback; - if (tb != tmp_tb) { - Py_INCREF(tb); - tstate->curexc_traceback = tb; - Py_XDECREF(tmp_tb); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* BytesEquals */ -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else - if (s1 == s2) { - return (equals == Py_EQ); - } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { - const char *ps1, *ps2; - Py_ssize_t length = PyBytes_GET_SIZE(s1); - if (length != PyBytes_GET_SIZE(s2)) - return (equals == Py_NE); - ps1 = PyBytes_AS_STRING(s1); - ps2 = PyBytes_AS_STRING(s2); - if (ps1[0] != ps2[0]) { - return (equals == Py_NE); - } else if (length == 1) { - return (equals == Py_EQ); - } else { - int result; -#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000) - Py_hash_t hash1, hash2; - hash1 = ((PyBytesObject*)s1)->ob_shash; - hash2 = ((PyBytesObject*)s2)->ob_shash; - if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { - return (equals == Py_NE); - } -#endif - result = memcmp(ps1, ps2, (size_t)length); - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -#endif -} - -/* UnicodeEquals */ -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else -#if PY_MAJOR_VERSION < 3 - PyObject* owned_ref = NULL; -#endif - int s1_is_unicode, s2_is_unicode; - if (s1 == s2) { - goto return_eq; - } - s1_is_unicode = PyUnicode_CheckExact(s1); - s2_is_unicode = PyUnicode_CheckExact(s2); -#if PY_MAJOR_VERSION < 3 - if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) { - owned_ref = PyUnicode_FromObject(s2); - if (unlikely(!owned_ref)) - return -1; - s2 = owned_ref; - s2_is_unicode = 1; - } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) { - owned_ref = PyUnicode_FromObject(s1); - if (unlikely(!owned_ref)) - return -1; - s1 = owned_ref; - s1_is_unicode = 1; - } else if (((!s2_is_unicode) & (!s1_is_unicode))) { - return __Pyx_PyBytes_Equals(s1, s2, equals); - } -#endif - if (s1_is_unicode & s2_is_unicode) { - Py_ssize_t length; - int kind; - void *data1, *data2; - if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0)) - return -1; - length = __Pyx_PyUnicode_GET_LENGTH(s1); - if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { - goto return_ne; - } -#if CYTHON_USE_UNICODE_INTERNALS - { - Py_hash_t hash1, hash2; - #if CYTHON_PEP393_ENABLED - hash1 = ((PyASCIIObject*)s1)->hash; - hash2 = ((PyASCIIObject*)s2)->hash; - #else - hash1 = ((PyUnicodeObject*)s1)->hash; - hash2 = ((PyUnicodeObject*)s2)->hash; - #endif - if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { - goto return_ne; - } - } -#endif - kind = __Pyx_PyUnicode_KIND(s1); - if (kind != __Pyx_PyUnicode_KIND(s2)) { - goto return_ne; - } - data1 = __Pyx_PyUnicode_DATA(s1); - data2 = __Pyx_PyUnicode_DATA(s2); - if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) { - goto return_ne; - } else if (length == 1) { - goto return_eq; - } else { - int result = memcmp(data1, data2, (size_t)(length * kind)); - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & s2_is_unicode) { - goto return_ne; - } else if ((s2 == Py_None) & s1_is_unicode) { - goto return_ne; - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -return_eq: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_EQ); -return_ne: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(owned_ref); - #endif - return (equals == Py_NE); -#endif -} - -/* DivInt[Py_ssize_t] */ -static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ssize_t b) { - Py_ssize_t q = a / b; - Py_ssize_t r = a - q*b; - q -= ((r != 0) & ((r ^ b) < 0)); - return q; -} - -/* GetAttr */ -static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) { -#if CYTHON_USE_TYPE_SLOTS -#if PY_MAJOR_VERSION >= 3 - if (likely(PyUnicode_Check(n))) -#else - if (likely(PyString_Check(n))) -#endif - return __Pyx_PyObject_GetAttrStr(o, n); -#endif - return PyObject_GetAttr(o, n); -} - -/* ObjectGetItem */ -#if CYTHON_USE_TYPE_SLOTS -static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) { - PyObject *runerr; - Py_ssize_t key_value; - PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence; - if (unlikely(!(m && m->sq_item))) { - PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name); - return NULL; - } - key_value = __Pyx_PyIndex_AsSsize_t(index); - if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) { - return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1); - } - if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) { - PyErr_Clear(); - PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name); - } - return NULL; -} -static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) { - PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping; - if (likely(m && m->mp_subscript)) { - return m->mp_subscript(obj, key); - } - return __Pyx_PyObject_GetIndex(obj, key); -} -#endif - -/* decode_c_string */ -static CYTHON_INLINE PyObject* __Pyx_decode_c_string( - const char* cstring, Py_ssize_t start, Py_ssize_t stop, - const char* encoding, const char* errors, - PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { - Py_ssize_t length; - if (unlikely((start < 0) | (stop < 0))) { - size_t slen = strlen(cstring); - if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { - PyErr_SetString(PyExc_OverflowError, - "c-string too long to convert to Python"); - return NULL; - } - length = (Py_ssize_t) slen; - if (start < 0) { - start += length; - if (start < 0) - start = 0; - } - if (stop < 0) - stop += length; - } - if (unlikely(stop <= start)) - return __Pyx_NewRef(__pyx_empty_unicode); - length = stop - start; - cstring += start; - if (decode_func) { - return decode_func(cstring, length, errors); - } else { - return PyUnicode_Decode(cstring, length, encoding, errors); - } -} - -/* PyErrExceptionMatches */ -#if CYTHON_FAST_THREAD_STATE -static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; icurexc_type; - if (exc_type == err) return 1; - if (unlikely(!exc_type)) return 0; - if (unlikely(PyTuple_Check(err))) - return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err); - return __Pyx_PyErr_GivenExceptionMatches(exc_type, err); -} -#endif - -/* GetAttr3 */ -static PyObject *__Pyx_GetAttr3Default(PyObject *d) { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) - return NULL; - __Pyx_PyErr_Clear(); - Py_INCREF(d); - return d; -} -static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) { - PyObject *r = __Pyx_GetAttr(o, n); - return (likely(r)) ? r : __Pyx_GetAttr3Default(d); -} - -/* RaiseTooManyValuesToUnpack */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* RaiseNoneIterError */ -static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); -} - -/* GetTopmostException */ -#if CYTHON_USE_EXC_INFO_STACK -static _PyErr_StackItem * -__Pyx_PyErr_GetTopmostException(PyThreadState *tstate) -{ - _PyErr_StackItem *exc_info = tstate->exc_info; - while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) && - exc_info->previous_item != NULL) - { - exc_info = exc_info->previous_item; - } - return exc_info; -} -#endif - -/* SaveResetException */ -#if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate); - *type = exc_info->exc_type; - *value = exc_info->exc_value; - *tb = exc_info->exc_traceback; - #else - *type = tstate->exc_type; - *value = tstate->exc_value; - *tb = tstate->exc_traceback; - #endif - Py_XINCREF(*type); - Py_XINCREF(*value); - Py_XINCREF(*tb); -} -static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = type; - exc_info->exc_value = value; - exc_info->exc_traceback = tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = type; - tstate->exc_value = value; - tstate->exc_traceback = tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -} -#endif - -/* GetException */ -#if CYTHON_FAST_THREAD_STATE -static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) -#else -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) -#endif -{ - PyObject *local_type, *local_value, *local_tb; -#if CYTHON_FAST_THREAD_STATE - PyObject *tmp_type, *tmp_value, *tmp_tb; - local_type = tstate->curexc_type; - local_value = tstate->curexc_value; - local_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; -#else - PyErr_Fetch(&local_type, &local_value, &local_tb); -#endif - PyErr_NormalizeException(&local_type, &local_value, &local_tb); -#if CYTHON_FAST_THREAD_STATE - if (unlikely(tstate->curexc_type)) -#else - if (unlikely(PyErr_Occurred())) -#endif - goto bad; - #if PY_MAJOR_VERSION >= 3 - if (local_tb) { - if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) - goto bad; - } - #endif - Py_XINCREF(local_tb); - Py_XINCREF(local_type); - Py_XINCREF(local_value); - *type = local_type; - *value = local_value; - *tb = local_tb; -#if CYTHON_FAST_THREAD_STATE - #if CYTHON_USE_EXC_INFO_STACK - { - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = local_type; - exc_info->exc_value = local_value; - exc_info->exc_traceback = local_tb; - } - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = local_type; - tstate->exc_value = local_value; - tstate->exc_traceback = local_tb; - #endif - Py_XDECREF(tmp_type); - Py_XDECREF(tmp_value); - Py_XDECREF(tmp_tb); -#else - PyErr_SetExcInfo(local_type, local_value, local_tb); -#endif - return 0; -bad: - *type = 0; - *value = 0; - *tb = 0; - Py_XDECREF(local_type); - Py_XDECREF(local_value); - Py_XDECREF(local_tb); - return -1; -} - -/* SwapException */ -#if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - #if CYTHON_USE_EXC_INFO_STACK - _PyErr_StackItem *exc_info = tstate->exc_info; - tmp_type = exc_info->exc_type; - tmp_value = exc_info->exc_value; - tmp_tb = exc_info->exc_traceback; - exc_info->exc_type = *type; - exc_info->exc_value = *value; - exc_info->exc_traceback = *tb; - #else - tmp_type = tstate->exc_type; - tmp_value = tstate->exc_value; - tmp_tb = tstate->exc_traceback; - tstate->exc_type = *type; - tstate->exc_value = *value; - tstate->exc_traceback = *tb; - #endif - *type = tmp_type; - *value = tmp_value; - *tb = tmp_tb; -} -#else -static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb); - PyErr_SetExcInfo(*type, *value, *tb); - *type = tmp_type; - *value = tmp_value; - *tb = tmp_tb; -} -#endif - -/* Import */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, (PyObject *)NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_list); - Py_XDECREF(empty_dict); - return module; -} - -/* FastTypeChecks */ -#if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - if (a == b) - return 1; - } - return b == &PyBaseObject_Type; -} -static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { - PyObject *mro; - if (a == b) return 1; - mro = a->tp_mro; - if (likely(mro)) { - Py_ssize_t i, n; - n = PyTuple_GET_SIZE(mro); - for (i = 0; i < n; i++) { - if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) - return 1; - } - return 0; - } - return __Pyx_InBases(a, b); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) { - Py_ssize_t i, n; - assert(PyExceptionClass_Check(exc_type)); - n = PyTuple_GET_SIZE(tuple); -#if PY_MAJOR_VERSION >= 3 - for (i=0; i= 0 || (x^b) >= 0)) - return PyInt_FromLong(x); - return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG llb = intval; - PY_LONG_LONG lla, llx; -#endif - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } else { - switch (size) { - case -2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 3: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case -4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - case 4: - if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_LONG - } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); - goto long_long; -#endif - } - CYTHON_FALLTHROUGH; - default: return PyLong_Type.tp_as_number->nb_add(op1, op2); - } - } - x = a + b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla + llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - if (PyFloat_CheckExact(op1)) { - const long b = intval; - double a = PyFloat_AS_DOUBLE(op1); - double result; - PyFPE_START_PROTECT("add", return NULL) - result = ((double)a) + (double)b; - PyFPE_END_PROTECT(result) - return PyFloat_FromDouble(result); - } - return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2); -} -#endif - -/* None */ -static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) { - PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname); -} - -/* DivInt[long] */ -static CYTHON_INLINE long __Pyx_div_long(long a, long b) { - long q = a / b; - long r = a - q*b; - q -= ((r != 0) & ((r ^ b) < 0)); - return q; -} - -/* ImportFrom */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { - PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); - if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* HasAttr */ -static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) { - PyObject *r; - if (unlikely(!__Pyx_PyBaseString_Check(n))) { - PyErr_SetString(PyExc_TypeError, - "hasattr(): attribute name must be string"); - return -1; - } - r = __Pyx_GetAttr(o, n); - if (unlikely(!r)) { - PyErr_Clear(); - return 0; - } else { - Py_DECREF(r); - return 1; - } -} - -/* PyObject_GenericGetAttrNoDict */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { - PyErr_Format(PyExc_AttributeError, -#if PY_MAJOR_VERSION >= 3 - "'%.50s' object has no attribute '%U'", - tp->tp_name, attr_name); -#else - "'%.50s' object has no attribute '%.400s'", - tp->tp_name, PyString_AS_STRING(attr_name)); -#endif - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { - PyObject *descr; - PyTypeObject *tp = Py_TYPE(obj); - if (unlikely(!PyString_Check(attr_name))) { - return PyObject_GenericGetAttr(obj, attr_name); - } - assert(!tp->tp_dictoffset); - descr = _PyType_Lookup(tp, attr_name); - if (unlikely(!descr)) { - return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); - } - Py_INCREF(descr); - #if PY_MAJOR_VERSION < 3 - if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) - #endif - { - descrgetfunc f = Py_TYPE(descr)->tp_descr_get; - if (unlikely(f)) { - PyObject *res = f(descr, obj, (PyObject *)tp); - Py_DECREF(descr); - return res; - } - } - return descr; -} -#endif - -/* PyObject_GenericGetAttr */ -#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 -static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) { - if (unlikely(Py_TYPE(obj)->tp_dictoffset)) { - return PyObject_GenericGetAttr(obj, attr_name); - } - return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name); -} -#endif - -/* SetVTable */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -/* PyObjectGetAttrStrNoError */ -static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) { - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError))) - __Pyx_PyErr_Clear(); -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) { - PyObject *result; -#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1 - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) { - return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1); - } -#endif - result = __Pyx_PyObject_GetAttrStr(obj, attr_name); - if (unlikely(!result)) { - __Pyx_PyObject_GetAttrStr_ClearAttributeError(); - } - return result; -} - -/* SetupReduce */ -static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { - int ret; - PyObject *name_attr; - name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name_2); - if (likely(name_attr)) { - ret = PyObject_RichCompareBool(name_attr, name, Py_EQ); - } else { - ret = -1; - } - if (unlikely(ret < 0)) { - PyErr_Clear(); - ret = 0; - } - Py_XDECREF(name_attr); - return ret; -} -static int __Pyx_setup_reduce(PyObject* type_obj) { - int ret = 0; - PyObject *object_reduce = NULL; - PyObject *object_getstate = NULL; - PyObject *object_reduce_ex = NULL; - PyObject *reduce = NULL; - PyObject *reduce_ex = NULL; - PyObject *reduce_cython = NULL; - PyObject *setstate = NULL; - PyObject *setstate_cython = NULL; - PyObject *getstate = NULL; -#if CYTHON_USE_PYTYPE_LOOKUP - getstate = _PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate); -#else - getstate = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_getstate); - if (!getstate && PyErr_Occurred()) { - goto __PYX_BAD; - } -#endif - if (getstate) { -#if CYTHON_USE_PYTYPE_LOOKUP - object_getstate = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_getstate); -#else - object_getstate = __Pyx_PyObject_GetAttrStrNoError((PyObject*)&PyBaseObject_Type, __pyx_n_s_getstate); - if (!object_getstate && PyErr_Occurred()) { - goto __PYX_BAD; - } -#endif - if (object_getstate != getstate) { - goto __PYX_GOOD; - } - } -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; -#else - object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD; -#endif - reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD; - if (reduce_ex == object_reduce_ex) { -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; -#else - object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD; -#endif - reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD; - if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython); - if (likely(reduce_cython)) { - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD; - } else if (reduce == object_reduce || PyErr_Occurred()) { - goto __PYX_BAD; - } - setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); - if (!setstate) PyErr_Clear(); - if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython); - if (likely(setstate_cython)) { - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD; - } else if (!setstate || PyErr_Occurred()) { - goto __PYX_BAD; - } - } - PyType_Modified((PyTypeObject*)type_obj); - } - } - goto __PYX_GOOD; -__PYX_BAD: - if (!PyErr_Occurred()) - PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); - ret = -1; -__PYX_GOOD: -#if !CYTHON_USE_PYTYPE_LOOKUP - Py_XDECREF(object_reduce); - Py_XDECREF(object_reduce_ex); - Py_XDECREF(object_getstate); - Py_XDECREF(getstate); -#endif - Py_XDECREF(reduce); - Py_XDECREF(reduce_ex); - Py_XDECREF(reduce_cython); - Py_XDECREF(setstate); - Py_XDECREF(setstate_cython); - return ret; -} - -/* TypeImport */ -#ifndef __PYX_HAVE_RT_ImportType -#define __PYX_HAVE_RT_ImportType -static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name, - size_t size, enum __Pyx_ImportType_CheckSize check_size) -{ - PyObject *result = 0; - char warning[200]; - Py_ssize_t basicsize; -#ifdef Py_LIMITED_API - PyObject *py_basicsize; -#endif - result = PyObject_GetAttrString(module, class_name); - if (!result) - goto bad; - if (!PyType_Check(result)) { - PyErr_Format(PyExc_TypeError, - "%.200s.%.200s is not a type object", - module_name, class_name); - goto bad; - } -#ifndef Py_LIMITED_API - basicsize = ((PyTypeObject *)result)->tp_basicsize; -#else - py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); - if (!py_basicsize) - goto bad; - basicsize = PyLong_AsSsize_t(py_basicsize); - Py_DECREF(py_basicsize); - py_basicsize = 0; - if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) - goto bad; -#endif - if ((size_t)basicsize < size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) { - PyErr_Format(PyExc_ValueError, - "%.200s.%.200s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - goto bad; - } - else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) { - PyOS_snprintf(warning, sizeof(warning), - "%s.%s size changed, may indicate binary incompatibility. " - "Expected %zd from C header, got %zd from PyObject", - module_name, class_name, size, basicsize); - if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; - } - return (PyTypeObject *)result; -bad: - Py_XDECREF(result); - return NULL; -} -#endif - -/* GetVTable */ -static void* __Pyx_GetVtable(PyObject *dict) { - void* ptr; - PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable); - if (!ob) - goto bad; -#if PY_VERSION_HEX >= 0x02070000 - ptr = PyCapsule_GetPointer(ob, 0); -#else - ptr = PyCObject_AsVoidPtr(ob); -#endif - if (!ptr && !PyErr_Occurred()) - PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type"); - Py_DECREF(ob); - return ptr; -bad: - Py_XDECREF(ob); - return NULL; -} - -/* CLineInTraceback */ -#ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - if (unlikely(!__pyx_cython_runtime)) { - return c_line; - } - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - __PYX_PY_DICT_LOOKUP_IF_MODIFIED( - use_cline, *cython_runtime_dict, - __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback)) - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - (void) PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) { - c_line = 0; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - return c_line; -} -#endif - -/* CodeObjectCache */ -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { - int start = 0, mid = 0, end = count - 1; - if (end >= 0 && code_line > entries[end].code_line) { - return count; - } - while (start < end) { - mid = start + (end - start) / 2; - if (code_line < entries[mid].code_line) { - end = mid; - } else if (code_line > entries[mid].code_line) { - start = mid + 1; - } else { - return mid; - } - } - if (code_line <= entries[mid].code_line) { - return mid; - } else { - return mid + 1; - } -} -static PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_code_cache.count = 1; - entries[0].code_line = code_line; - entries[0].code_object = code_object; - Py_INCREF(code_object); - } - return; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ -#include "compile.h" -#include "frameobject.h" -#include "traceback.h" -#if PY_VERSION_HEX >= 0x030b00a6 - #ifndef Py_BUILD_CORE - #define Py_BUILD_CORE 1 - #endif - #include "internal/pycore_frame.h" -#endif -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = NULL; - PyObject *py_funcname = NULL; - #if PY_MAJOR_VERSION < 3 - PyObject *py_srcfile = NULL; - py_srcfile = PyString_FromString(filename); - if (!py_srcfile) goto bad; - #endif - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - if (!py_funcname) goto bad; - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - if (!py_funcname) goto bad; - funcname = PyUnicode_AsUTF8(py_funcname); - if (!funcname) goto bad; - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - if (!py_funcname) goto bad; - #endif - } - #if PY_MAJOR_VERSION < 3 - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - #else - py_code = PyCode_NewEmpty(filename, funcname, py_line); - #endif - Py_XDECREF(py_funcname); // XDECREF since it's only set on Py3 if cline - return py_code; -bad: - Py_XDECREF(py_funcname); - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_srcfile); - #endif - return NULL; -} -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject *ptype, *pvalue, *ptraceback; - if (c_line) { - c_line = __Pyx_CLineForTraceback(tstate, c_line); - } - py_code = __pyx_find_code_object(c_line ? -c_line : py_line); - if (!py_code) { - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) { - /* If the code object creation fails, then we should clear the - fetched exception references and propagate the new exception */ - Py_XDECREF(ptype); - Py_XDECREF(pvalue); - Py_XDECREF(ptraceback); - goto bad; - } - __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - __Pyx_PyFrame_SetLineNumber(py_frame, py_line); - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} - -/* CIntFromPyVerify */ -#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) -#define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ - __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) -#define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\ - {\ - func_type value = func_value;\ - if (sizeof(target_type) < sizeof(func_type)) {\ - if (unlikely(value != (func_type) (target_type) value)) {\ - func_type zero = 0;\ - if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\ - return (target_type) -1;\ - if (is_unsigned && unlikely(value < zero))\ - goto raise_neg_overflow;\ - else\ - goto raise_overflow;\ - }\ - }\ - return (target_type) value;\ - } - -#if PY_MAJOR_VERSION < 3 -static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { - if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); - if (__Pyx_TypeCheck(obj, __pyx_array_type)) return __pyx_array_getbuffer(obj, view, flags); - if (__Pyx_TypeCheck(obj, __pyx_memoryview_type)) return __pyx_memoryview_getbuffer(obj, view, flags); - PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); - return -1; -} -static void __Pyx_ReleaseBuffer(Py_buffer *view) { - PyObject *obj = view->obj; - if (!obj) return; - if (PyObject_CheckBuffer(obj)) { - PyBuffer_Release(view); - return; - } - if ((0)) {} - view->obj = NULL; - Py_DECREF(obj); -} -#endif - - -/* MemviewSliceIsContig */ -static int -__pyx_memviewslice_is_contig(const __Pyx_memviewslice mvs, char order, int ndim) -{ - int i, index, step, start; - Py_ssize_t itemsize = mvs.memview->view.itemsize; - if (order == 'F') { - step = 1; - start = 0; - } else { - step = -1; - start = ndim - 1; - } - for (i = 0; i < ndim; i++) { - index = start + step * i; - if (mvs.suboffsets[index] >= 0 || mvs.strides[index] != itemsize) - return 0; - itemsize *= mvs.shape[index]; - } - return 1; -} - -/* OverlappingSlices */ -static void -__pyx_get_array_memory_extents(__Pyx_memviewslice *slice, - void **out_start, void **out_end, - int ndim, size_t itemsize) -{ - char *start, *end; - int i; - start = end = slice->data; - for (i = 0; i < ndim; i++) { - Py_ssize_t stride = slice->strides[i]; - Py_ssize_t extent = slice->shape[i]; - if (extent == 0) { - *out_start = *out_end = start; - return; - } else { - if (stride > 0) - end += stride * (extent - 1); - else - start += stride * (extent - 1); - } - } - *out_start = start; - *out_end = end + itemsize; -} -static int -__pyx_slices_overlap(__Pyx_memviewslice *slice1, - __Pyx_memviewslice *slice2, - int ndim, size_t itemsize) -{ - void *start1, *end1, *start2, *end2; - __pyx_get_array_memory_extents(slice1, &start1, &end1, ndim, itemsize); - __pyx_get_array_memory_extents(slice2, &start2, &end2, ndim, itemsize); - return (start1 < end2) && (start2 < end1); -} - -/* Capsule */ -static CYTHON_INLINE PyObject * -__pyx_capsule_create(void *p, CYTHON_UNUSED const char *sig) -{ - PyObject *cobj; -#if PY_VERSION_HEX >= 0x02070000 - cobj = PyCapsule_New(p, sig, NULL); -#else - cobj = PyCObject_FromVoidPtr(p, NULL); -#endif - return cobj; -} - -/* CIntToPy */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(long) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPy */ -static CYTHON_INLINE int32_t __Pyx_PyInt_As_int32_t(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int32_t neg_one = (int32_t) -1, const_zero = (int32_t) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int32_t) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int32_t, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int32_t) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int32_t) 0; - case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, digits[0]) - case 2: - if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) >= 2 * PyLong_SHIFT) { - return (int32_t) (((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) >= 3 * PyLong_SHIFT) { - return (int32_t) (((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) >= 4 * PyLong_SHIFT) { - return (int32_t) (((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int32_t) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int32_t) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int32_t) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int32_t, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int32_t) 0; - case -1: __PYX_VERIFY_RETURN_INT(int32_t, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int32_t, digit, +digits[0]) - case -2: - if (8 * sizeof(int32_t) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) { - return (int32_t) (((int32_t)-1)*(((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int32_t) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) { - return (int32_t) ((((((int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int32_t) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) { - return (int32_t) (((int32_t)-1)*(((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int32_t) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) { - return (int32_t) ((((((((int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int32_t) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) { - return (int32_t) (((int32_t)-1)*(((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int32_t) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int32_t, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int32_t) - 1 > 4 * PyLong_SHIFT) { - return (int32_t) ((((((((((int32_t)digits[3]) << PyLong_SHIFT) | (int32_t)digits[2]) << PyLong_SHIFT) | (int32_t)digits[1]) << PyLong_SHIFT) | (int32_t)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int32_t) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int32_t, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int32_t) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int32_t, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int32_t val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int32_t) -1; - } - } else { - int32_t val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int32_t) -1; - val = __Pyx_PyInt_As_int32_t(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int32_t"); - return (int32_t) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int32_t"); - return (int32_t) -1; -} - -/* MemviewSliceCopyTemplate */ -static __Pyx_memviewslice -__pyx_memoryview_copy_new_contig(const __Pyx_memviewslice *from_mvs, - const char *mode, int ndim, - size_t sizeof_dtype, int contig_flag, - int dtype_is_object) -{ - __Pyx_RefNannyDeclarations - int i; - __Pyx_memviewslice new_mvs = { 0, 0, { 0 }, { 0 }, { 0 } }; - struct __pyx_memoryview_obj *from_memview = from_mvs->memview; - Py_buffer *buf = &from_memview->view; - PyObject *shape_tuple = NULL; - PyObject *temp_int = NULL; - struct __pyx_array_obj *array_obj = NULL; - struct __pyx_memoryview_obj *memview_obj = NULL; - __Pyx_RefNannySetupContext("__pyx_memoryview_copy_new_contig", 0); - for (i = 0; i < ndim; i++) { - if (unlikely(from_mvs->suboffsets[i] >= 0)) { - PyErr_Format(PyExc_ValueError, "Cannot copy memoryview slice with " - "indirect dimensions (axis %d)", i); - goto fail; - } - } - shape_tuple = PyTuple_New(ndim); - if (unlikely(!shape_tuple)) { - goto fail; - } - __Pyx_GOTREF(shape_tuple); - for(i = 0; i < ndim; i++) { - temp_int = PyInt_FromSsize_t(from_mvs->shape[i]); - if(unlikely(!temp_int)) { - goto fail; - } else { - PyTuple_SET_ITEM(shape_tuple, i, temp_int); - temp_int = NULL; - } - } - array_obj = __pyx_array_new(shape_tuple, sizeof_dtype, buf->format, (char *) mode, NULL); - if (unlikely(!array_obj)) { - goto fail; - } - __Pyx_GOTREF(array_obj); - memview_obj = (struct __pyx_memoryview_obj *) __pyx_memoryview_new( - (PyObject *) array_obj, contig_flag, - dtype_is_object, - from_mvs->memview->typeinfo); - if (unlikely(!memview_obj)) - goto fail; - if (unlikely(__Pyx_init_memviewslice(memview_obj, ndim, &new_mvs, 1) < 0)) - goto fail; - if (unlikely(__pyx_memoryview_copy_contents(*from_mvs, new_mvs, ndim, ndim, - dtype_is_object) < 0)) - goto fail; - goto no_fail; -fail: - __Pyx_XDECREF(new_mvs.memview); - new_mvs.memview = NULL; - new_mvs.data = NULL; -no_fail: - __Pyx_XDECREF(shape_tuple); - __Pyx_XDECREF(temp_int); - __Pyx_XDECREF(array_obj); - __Pyx_RefNannyFinishContext(); - return new_mvs; -} - -/* MemviewSliceInit */ -static int -__Pyx_init_memviewslice(struct __pyx_memoryview_obj *memview, - int ndim, - __Pyx_memviewslice *memviewslice, - int memview_is_new_reference) -{ - __Pyx_RefNannyDeclarations - int i, retval=-1; - Py_buffer *buf = &memview->view; - __Pyx_RefNannySetupContext("init_memviewslice", 0); - if (unlikely(memviewslice->memview || memviewslice->data)) { - PyErr_SetString(PyExc_ValueError, - "memviewslice is already initialized!"); - goto fail; - } - if (buf->strides) { - for (i = 0; i < ndim; i++) { - memviewslice->strides[i] = buf->strides[i]; - } - } else { - Py_ssize_t stride = buf->itemsize; - for (i = ndim - 1; i >= 0; i--) { - memviewslice->strides[i] = stride; - stride *= buf->shape[i]; - } - } - for (i = 0; i < ndim; i++) { - memviewslice->shape[i] = buf->shape[i]; - if (buf->suboffsets) { - memviewslice->suboffsets[i] = buf->suboffsets[i]; - } else { - memviewslice->suboffsets[i] = -1; - } - } - memviewslice->memview = memview; - memviewslice->data = (char *)buf->buf; - if (__pyx_add_acquisition_count(memview) == 0 && !memview_is_new_reference) { - Py_INCREF(memview); - } - retval = 0; - goto no_fail; -fail: - memviewslice->memview = 0; - memviewslice->data = 0; - retval = -1; -no_fail: - __Pyx_RefNannyFinishContext(); - return retval; -} -#ifndef Py_NO_RETURN -#define Py_NO_RETURN -#endif -static void __pyx_fatalerror(const char *fmt, ...) Py_NO_RETURN { - va_list vargs; - char msg[200]; -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, fmt); -#else - va_start(vargs); -#endif - vsnprintf(msg, 200, fmt, vargs); - va_end(vargs); - Py_FatalError(msg); -} -static CYTHON_INLINE int -__pyx_add_acquisition_count_locked(__pyx_atomic_int *acquisition_count, - PyThread_type_lock lock) -{ - int result; - PyThread_acquire_lock(lock, 1); - result = (*acquisition_count)++; - PyThread_release_lock(lock); - return result; -} -static CYTHON_INLINE int -__pyx_sub_acquisition_count_locked(__pyx_atomic_int *acquisition_count, - PyThread_type_lock lock) -{ - int result; - PyThread_acquire_lock(lock, 1); - result = (*acquisition_count)--; - PyThread_release_lock(lock); - return result; -} -static CYTHON_INLINE void -__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno) -{ - int first_time; - struct __pyx_memoryview_obj *memview = memslice->memview; - if (unlikely(!memview || (PyObject *) memview == Py_None)) - return; - if (unlikely(__pyx_get_slice_count(memview) < 0)) - __pyx_fatalerror("Acquisition count is %d (line %d)", - __pyx_get_slice_count(memview), lineno); - first_time = __pyx_add_acquisition_count(memview) == 0; - if (unlikely(first_time)) { - if (have_gil) { - Py_INCREF((PyObject *) memview); - } else { - PyGILState_STATE _gilstate = PyGILState_Ensure(); - Py_INCREF((PyObject *) memview); - PyGILState_Release(_gilstate); - } - } -} -static CYTHON_INLINE void __Pyx_XDEC_MEMVIEW(__Pyx_memviewslice *memslice, - int have_gil, int lineno) { - int last_time; - struct __pyx_memoryview_obj *memview = memslice->memview; - if (unlikely(!memview || (PyObject *) memview == Py_None)) { - memslice->memview = NULL; - return; - } - if (unlikely(__pyx_get_slice_count(memview) <= 0)) - __pyx_fatalerror("Acquisition count is %d (line %d)", - __pyx_get_slice_count(memview), lineno); - last_time = __pyx_sub_acquisition_count(memview) == 1; - memslice->data = NULL; - if (unlikely(last_time)) { - if (have_gil) { - Py_CLEAR(memslice->memview); - } else { - PyGILState_STATE _gilstate = PyGILState_Ensure(); - Py_CLEAR(memslice->memview); - PyGILState_Release(_gilstate); - } - } else { - memslice->memview = NULL; - } -} - -/* CIntFromPy */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (int) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(int) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - case -2: - if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(int) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(int) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(int) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); - } - } - break; - } -#endif - if (sizeof(int) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to int"); - return (int) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to int"); - return (int) -1; -} - -/* CIntFromPy */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const long neg_one = (long) -1, const_zero = (long) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (long) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(long) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - case -2: - if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(long) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(long) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(long) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); - } - } - break; - } -#endif - if (sizeof(long) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to long"); - return (long) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to long"); - return (long) -1; -} - -/* CIntToPy */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const int neg_one = (int) -1, const_zero = (int) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntFromPy */ -static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - const char neg_one = (char) -1, const_zero = (char) 0; -#ifdef __Pyx_HAS_GCC_DIAGNOSTIC -#pragma GCC diagnostic pop -#endif - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(char) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(char, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (char) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (char) 0; - case 1: __PYX_VERIFY_RETURN_INT(char, digit, digits[0]) - case 2: - if (8 * sizeof(char) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) { - return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); - } - } - break; - case 3: - if (8 * sizeof(char) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) { - return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); - } - } - break; - case 4: - if (8 * sizeof(char) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) { - return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); - } - } - break; - } -#endif -#if CYTHON_COMPILING_IN_CPYTHON - if (unlikely(Py_SIZE(x) < 0)) { - goto raise_neg_overflow; - } -#else - { - int result = PyObject_RichCompareBool(x, Py_False, Py_LT); - if (unlikely(result < 0)) - return (char) -1; - if (unlikely(result == 1)) - goto raise_neg_overflow; - } -#endif - if (sizeof(char) <= sizeof(unsigned long)) { - __PYX_VERIFY_RETURN_INT_EXC(char, unsigned long, PyLong_AsUnsignedLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(char) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (char) 0; - case -1: __PYX_VERIFY_RETURN_INT(char, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(char, digit, +digits[0]) - case -2: - if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); - } - } - break; - case 2: - if (8 * sizeof(char) > 1 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); - } - } - break; - case -3: - if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); - } - } - break; - case 3: - if (8 * sizeof(char) > 2 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); - } - } - break; - case -4: - if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { - return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); - } - } - break; - case 4: - if (8 * sizeof(char) > 3 * PyLong_SHIFT) { - if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) - } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { - return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); - } - } - break; - } -#endif - if (sizeof(char) <= sizeof(long)) { - __PYX_VERIFY_RETURN_INT_EXC(char, long, PyLong_AsLong(x)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(char) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(char, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - char val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (char) -1; - } - } else { - char val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (char) -1; - val = __Pyx_PyInt_As_char(tmp); - Py_DECREF(tmp); - return val; - } -raise_overflow: - PyErr_SetString(PyExc_OverflowError, - "value too large to convert to char"); - return (char) -1; -raise_neg_overflow: - PyErr_SetString(PyExc_OverflowError, - "can't convert negative value to char"); - return (char) -1; -} - -/* CheckBinaryVersion */ -static int __Pyx_check_binary_version(void) { - char ctversion[5]; - int same=1, i, found_dot; - const char* rt_from_call = Py_GetVersion(); - PyOS_snprintf(ctversion, 5, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - found_dot = 0; - for (i = 0; i < 4; i++) { - if (!ctversion[i]) { - same = (rt_from_call[i] < '0' || rt_from_call[i] > '9'); - break; - } - if (rt_from_call[i] != ctversion[i]) { - same = 0; - break; - } - } - if (!same) { - char rtversion[5] = {'\0'}; - char message[200]; - for (i=0; i<4; ++i) { - if (rt_from_call[i] == '.') { - if (found_dot) break; - found_dot = 1; - } else if (rt_from_call[i] < '0' || rt_from_call[i] > '9') { - break; - } - rtversion[i] = rt_from_call[i]; - } - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - return PyErr_WarnEx(NULL, message, 1); - } - return 0; -} - -/* InitStrings */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - return -1; - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { - Py_ssize_t ignore; - return __Pyx_PyObject_AsStringAndSize(o, &ignore); -} -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (likely(PyUnicode_IS_ASCII(o))) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } -#else - return PyUnicode_AsUTF8AndSize(o, length); -#endif -} -#endif -#endif -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - char* result; - int r = PyBytes_AsStringAndSize(o, &result, length); - if (unlikely(r < 0)) { - return NULL; - } else { - return result; - } - } -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { - int is_true = x == Py_True; - if (is_true | (x == Py_False) | (x == Py_None)) return is_true; - else return PyObject_IsTrue(x); -} -static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) { - int retval; - if (unlikely(!x)) return -1; - retval = __Pyx_PyObject_IsTrue(x); - Py_DECREF(x); - return retval; -} -static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, - "an integer is required"); - } - return res; -} -static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { - Py_ssize_t ival; - PyObject *x; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(b); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - switch (size) { - case 2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -2: - if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -3: - if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case 4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - case -4: - if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); - } - break; - } - } - #endif - return PyLong_AsSsize_t(b); - } - x = PyNumber_Index(b); - if (!x) return -1; - ival = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) { - if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) { - return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o); -#if PY_MAJOR_VERSION < 3 - } else if (likely(PyInt_CheckExact(o))) { - return PyInt_AS_LONG(o); -#endif - } else { - Py_ssize_t ival; - PyObject *x; - x = PyNumber_Index(o); - if (!x) return -1; - ival = PyInt_AsLong(x); - Py_DECREF(x); - return ival; - } -} -static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { - return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ From cc661b31a68de9d74cf94d49f030dd8a80f32dec Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 20 Jul 2022 19:37:23 -0700 Subject: [PATCH 043/212] strings_udf lowering shall not import cudf, and functions shall be attrs of string_view --- python/cudf/cudf/core/udf/masked_typing.py | 6 - .../strings_udf/_lib/cudf_jit_udf.pyx | 7 - .../strings_udf/strings_udf/_lib/tables.pyx | 13 + python/strings_udf/strings_udf/_typing.py | 332 +++++++++--------- python/strings_udf/strings_udf/lowering.py | 62 ++-- .../strings_udf/strings_udf/tests/__init__.py | 6 - .../strings_udf/tests/test_count.py | 3 +- .../strings_udf/tests/test_endswith.py | 3 +- .../strings_udf/tests/test_find.py | 3 +- .../strings_udf/tests/test_isalnum.py | 3 +- .../strings_udf/tests/test_isalpha.py | 3 +- .../strings_udf/tests/test_isdecimal.py | 3 +- .../strings_udf/tests/test_isdigit.py | 3 +- .../strings_udf/tests/test_islower.py | 3 +- .../strings_udf/tests/test_isnumeric.py | 3 +- .../strings_udf/tests/test_isspace.py | 3 +- .../strings_udf/tests/test_isupper.py | 3 +- .../strings_udf/tests/test_rfind.py | 3 +- .../strings_udf/tests/test_startswith.py | 3 +- 19 files changed, 229 insertions(+), 236 deletions(-) create mode 100644 python/strings_udf/strings_udf/_lib/tables.pyx diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 60feea74aa7..aa2ef8f8df6 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -54,12 +54,6 @@ def __init__(self, value): if isinstance(value, (types.PyObject, StringView)): self.value_type = string_view - from strings_udf import lowering - from strings_udf._lib.cudf_jit_udf import get_character_flags_table_ptr - - character_flags_table_ptr = get_character_flags_table_ptr() - lowering.character_flags_table_ptr = character_flags_table_ptr - elif isinstance(value, SUPPORTED_NUMBA_TYPES): self.value_type = value else: diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 8e86abbe7f4..a721fa9d93d 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -25,11 +25,8 @@ from strings_udf._lib.cpp.strings_udf cimport ( from_dstring_array as cpp_from_dstring_array, to_string_view_array as cpp_to_string_view_array, udf_module as cpp_udf_module, - get_character_flags_table as cpp_get_character_flags_table ) -from libc.stdint cimport uintptr_t, uint8_t - import numpy as np def process_udf( udf, name, cols ): @@ -86,7 +83,3 @@ def from_dstring_array(DeviceBuffer d_buffer): c_result = move(cpp_from_dstring_array(data, size)) return Column.from_unique_ptr(move(c_result)) - -def get_character_flags_table_ptr(): - cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() - return np.int64(tbl_ptr) diff --git a/python/strings_udf/strings_udf/_lib/tables.pyx b/python/strings_udf/strings_udf/_lib/tables.pyx new file mode 100644 index 00000000000..f78faeef1ea --- /dev/null +++ b/python/strings_udf/strings_udf/_lib/tables.pyx @@ -0,0 +1,13 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# distutils: language = c++ +# cython: c_string_type=unicode, c_string_encoding=utf8 + +from strings_udf._lib.cpp.strings_udf cimport get_character_flags_table as cpp_get_character_flags_table +from libc.stdint cimport uintptr_t, uint8_t +import numpy as np + + +def get_character_flags_table_ptr(): + cdef const uint8_t* tbl_ptr = cpp_get_character_flags_table() + return np.int64(tbl_ptr) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index 7b04915e43f..38fc30b41b9 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -3,7 +3,7 @@ from numba import cuda, types from numba.core.extending import models, register_model from numba.core.typing import signature as nb_signature -from numba.core.typing.templates import AbstractTemplate +from numba.core.typing.templates import AbstractTemplate, AttributeTemplate from numba.cuda.cudadecl import registry as cuda_decl_registry import operator @@ -259,239 +259,245 @@ def generic(self, args, kws): "lt", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) ) +class StringViewStartsWith(AbstractTemplate): + key = "StringView.startswith" -def starts_with(st, substr): - return st.startswith(substr) + def generic(self, args, kws): + return nb_signature( + types.boolean, string_view, recvr=self.this + ) +class StringViewEndsWith(AbstractTemplate): + key = "StringView.endswith" -@cuda_decl_registry.register_global(starts_with) -class StringViewStartsWith(AbstractTemplate): - """ - return True if a stringview starts with a substring - """ + def generic(self, args, kws): + return nb_signature( + types.boolean, string_view, recvr=self.this + ) + +class StringViewFind(AbstractTemplate): + key = "StringView.find" def generic(self, args, kws): - if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): - return nb_signature(types.boolean, string_view, string_view) + return nb_signature( + types.int32, string_view, recvr=self.this + ) +class StringViewRFind(AbstractTemplate): + key = "StringView.rfind" -_string_view_startswith = cuda.declare_device( - "startswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) + def generic(self, args, kws): + return nb_signature( + types.int32, string_view, recvr=self.this + ) + +class StringViewIsAlnum(AbstractTemplate): + key = "StringView.isalnum" + def generic(self, args, kws): + return nb_signature( + types.boolean, recvr=self.this + ) -def ends_with(st, substr): - return st.endswith(substr) + +class StringViewIsAlpha(AbstractTemplate): + key = "StringView.isalpha" + def generic(self, args, kws): + return nb_signature( + types.boolean, recvr=self.this + ) -@cuda_decl_registry.register_global(ends_with) -class StringViewEndsWith(AbstractTemplate): - """ - return True if a stringview ends with a substring - """ + +class StringViewIsDecimal(AbstractTemplate): + key = "StringView.isdecimal" def generic(self, args, kws): - if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): - return nb_signature(types.boolean, string_view, string_view) + return nb_signature( + types.boolean, recvr=self.this + ) + +class StringViewIsDigit(AbstractTemplate): + key = "StringView.isdigit" -_string_view_endswith = cuda.declare_device( - "endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) -) + def generic(self, args, kws): + return nb_signature( + types.boolean, recvr=self.this + ) -def find(st, substr): - return st.find(substr) +class StringViewIsNumeric(AbstractTemplate): + key = "StringView.isnumeric" -@cuda_decl_registry.register_global(find) -class StringViewFind(AbstractTemplate): - """ - Return the index of a substring within a stringview - """ + def generic(self, args, kws): + return nb_signature( + types.boolean, recvr=self.this + ) + +class StringViewIsUpper(AbstractTemplate): + key = "StringView.isupper" def generic(self, args, kws): - if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): - return nb_signature(types.int32, string_view, string_view) + return nb_signature( + types.boolean, recvr=self.this + ) -_string_view_find = cuda.declare_device( - "find", - types.int32(types.CPointer(string_view), types.CPointer(string_view)) -) + +class StringViewIsLower(AbstractTemplate): + key = "StringView.islower" -def rfind(st, substr): - return st.rfind(substr) + def generic(self, args, kws): + return nb_signature( + types.boolean, recvr=self.this + ) -@cuda_decl_registry.register_global(rfind) -class StringViewFind(AbstractTemplate): - """ - Return the index of a substring within a stringview - """ + +class StringViewIsSpace(AbstractTemplate): + key = "StringView.isspace" def generic(self, args, kws): - if isinstance(args[0], (any_string_ty)) and isinstance(args[1], any_string_ty): - return nb_signature(types.int32, string_view, string_view) + return nb_signature( + types.boolean, recvr=self.this + ) -_string_view_rfind = cuda.declare_device( - "rfind", - types.int32(types.CPointer(string_view), types.CPointer(string_view)) +class StringViewCount(AbstractTemplate): + key = "StringView.count" + + def generic(self, args, kws): + return nb_signature( + types.int32, string_view, recvr=self.this + ) + + +@cuda_decl_registry.register_attr +class StringViewAttrs(AttributeTemplate): + key = string_view + + def resolve_startswith(self, mod): + return types.BoundFunction( + StringViewStartsWith, string_view + ) + + def resolve_endswith(self, mod): + return types.BoundFunction( + StringViewEndsWith, string_view + ) + + def resolve_find(self, mod): + return types.BoundFunction( + StringViewFind, string_view + ) + + def resolve_rfind(self, mod): + return types.BoundFunction( + StringViewRFind, string_view + ) + + def resolve_isalnum(self, mod): + return types.BoundFunction( + StringViewIsAlnum, string_view + ) + + def resolve_isalpha(self, mod): + return types.BoundFunction( + StringViewIsAlpha, string_view + ) + + def resolve_isdecimal(self, mod): + return types.BoundFunction( + StringViewIsDecimal, string_view + ) + + def resolve_isdigit(self, mod): + return types.BoundFunction( + StringViewIsDigit, string_view + ) + + def resolve_isnumeric(self, mod): + return types.BoundFunction( + StringViewIsNumeric, string_view + ) + + def resolve_islower(self, mod): + return types.BoundFunction( + StringViewIsLower, string_view + ) + + def resolve_isupper(self, mod): + return types.BoundFunction( + StringViewIsUpper, string_view + ) + + def resolve_isspace(self, mod): + return types.BoundFunction( + StringViewIsSpace, string_view + ) + + def resolve_count(self, mod): + return types.BoundFunction( + StringViewCount, string_view + ) + +_string_view_startswith = cuda.declare_device( + "startswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) -def isdigit(st): - return st.isdigit() +_string_view_endswith = cuda.declare_device( + "endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) +) -@cuda_decl_registry.register_global(isdigit) -class StringViewIsdigit(AbstractTemplate): - """ - Return True if the string is all numeric characters else false - """ +_string_view_find = cuda.declare_device( + "find", + types.int32(types.CPointer(string_view), types.CPointer(string_view)) +) - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) +_string_view_rfind = cuda.declare_device( + "rfind", + types.int32(types.CPointer(string_view), types.CPointer(string_view)) +) _string_view_isdigit = cuda.declare_device( "pyisdigit", types.boolean(types.CPointer(string_view), types.int64) ) -def isalnum(st): - return st.isalnum() - -@cuda_decl_registry.register_global(isalnum) -class StringViewIsAlnum(AbstractTemplate): - """ - Return True if the string is all alphanumeric characters else false - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) _string_view_isalnum = cuda.declare_device( "pyisalnum", types.boolean(types.CPointer(string_view), types.int64) ) -def isalpha(st): - return st.isalpha() - -@cuda_decl_registry.register_global(isalpha) -class StringViewIsAlpha(AbstractTemplate): - """ - Return True if the string is all alphabetical characters else false - """ - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) - _string_view_isalpha = cuda.declare_device( "pyisalpha", types.boolean(types.CPointer(string_view), types.int64) ) -def isdecimal(st): - return st.isdecimal() - -@cuda_decl_registry.register_global(isdecimal) -class StringViewIsdecimal(AbstractTemplate): - """ - Return True if the string is all decimal characters else false - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) - _string_view_isdecimal = cuda.declare_device( "pyisdecimal", types.boolean(types.CPointer(string_view), types.int64) ) -def isnumeric(st): - return st.isnumeric() - -@cuda_decl_registry.register_global(isnumeric) -class StringViewIsnumeric(AbstractTemplate): - """ - Return True if the string represents a valid number else false - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) - _string_view_isnumeric = cuda.declare_device( "pyisnumeric", types.boolean(types.CPointer(string_view), types.int64) ) -def isspace(st): - return st.isspace() - -@cuda_decl_registry.register_global(isspace) -class StringViewIsspace(AbstractTemplate): - """ - Return True if the string is all white space else false - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) - _string_view_isspace = cuda.declare_device( "pyisspace", types.boolean(types.CPointer(string_view), types.int64) ) -def isupper(st): - return st.isupper() - -@cuda_decl_registry.register_global(isupper) -class StringViewIsupper(AbstractTemplate): - """ - Return True if the string's alphabetic characters are all uppercase else false - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) - _string_view_isupper = cuda.declare_device( "pyisupper", types.boolean(types.CPointer(string_view), types.int64) ) -def islower(st): - return st.islower() - -@cuda_decl_registry.register_global(islower) -class StringViewIslower(AbstractTemplate): - """ - Return True if the string's alphabetic characters are all lowercase else false - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and len(args) == 1: - return nb_signature(types.boolean, string_view) - _string_view_islower = cuda.declare_device( "pyislower", types.boolean(types.CPointer(string_view), types.int64) ) - -def count(st, substr): - return st.count(substr) - -@cuda_decl_registry.register_global(count) -class StringViewCount(AbstractTemplate): - """ - Return the number of non-overlapping occurences of a substring within a string - """ - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and isinstance(args[1], any_string_ty): - return nb_signature(types.int32, string_view, string_view) - _string_view_count = cuda.declare_device( "pycount", types.int32(types.CPointer(string_view), types.CPointer(string_view)) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index f8a6df3b201..3f82f48fb15 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -8,6 +8,7 @@ from numba.cuda.cudaimpl import registry as cuda_lowering_registry from strings_udf._typing import ( StringView, + string_view, _string_view_endswith, _string_view_len, _string_view_startswith, @@ -29,25 +30,13 @@ _string_view_isupper, _string_view_islower, _string_view_count, - isdigit, - isalnum, - isalpha, - isnumeric, - isdecimal, - isspace, - isupper, - islower, - ends_with, - starts_with, - string_view, - find, - rfind, - count, ) import operator -character_flags_table_ptr = None +from strings_udf._lib.tables import get_character_flags_table_ptr + +character_flags_table_ptr = get_character_flags_table_ptr() # String function implementations def call_len_string_view(st): @@ -265,7 +254,7 @@ def call_string_view_startswith(sv, substr): return _string_view_startswith(sv, substr) -@cuda_lower(starts_with, string_view, string_view) +@cuda_lower("StringView.startswith", string_view, string_view) def string_view_startswith_impl(context, builder, sig, args): sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) @@ -288,7 +277,7 @@ def call_string_view_endswith(sv, substr): return _string_view_endswith(sv, substr) -@cuda_lower(ends_with, string_view, string_view) +@cuda_lower("StringView.endswith", string_view, string_view) def string_view_endswith_impl(context, builder, sig, args): sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) @@ -310,7 +299,7 @@ def string_view_endswith_impl(context, builder, sig, args): def call_string_view_count(st, substr): return _string_view_count(st, substr) -@cuda_lower(count, string_view, string_view) +@cuda_lower("StringView.count", string_view, string_view) def string_view_coount_impl(context, builder, sig, args): sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) @@ -332,7 +321,7 @@ def string_view_coount_impl(context, builder, sig, args): def call_string_view_find(sv, substr): return _string_view_find(sv, substr) -@cuda_lower(find, string_view, string_view) +@cuda_lower("StringView.find", string_view, string_view) def string_view_find_impl(context, builder, sig, args): sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) @@ -353,7 +342,7 @@ def string_view_find_impl(context, builder, sig, args): def call_string_view_rfind(sv, substr): return _string_view_rfind(sv, substr) -@cuda_lower(rfind, string_view, string_view) +@cuda_lower("StringView.rfind", string_view, string_view) def string_view_rfind_impl(context, builder, sig, args): sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) @@ -375,7 +364,7 @@ def call_string_view_isdigit(st, tbl): return _string_view_isdigit(st, tbl) -@cuda_lower(isdigit, string_view) +@cuda_lower("StringView.isdigit", string_view) def string_view_isdigit_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -396,7 +385,7 @@ def call_string_view_isalnum(st, tbl): return _string_view_isalnum(st, tbl) -@cuda_lower(isalnum, string_view) +@cuda_lower("StringView.isalnum", string_view) def string_view_isalnum_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -417,7 +406,7 @@ def call_string_view_isalpha(st, tbl): return _string_view_isalpha(st, tbl) -@cuda_lower(isalpha, string_view) +@cuda_lower("StringView.isalpha", string_view) def string_view_isalpha_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -438,7 +427,7 @@ def call_string_view_isnumeric(st, tbl): return _string_view_isnumeric(st, tbl) -@cuda_lower(isnumeric, string_view) +@cuda_lower("StringView.isnumeric", string_view) def string_view_isnumeric_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -459,7 +448,7 @@ def call_string_view_isdecimal(st, tbl): return _string_view_isdecimal(st, tbl) -@cuda_lower(isdecimal, string_view) +@cuda_lower("StringView.isdecimal", string_view) def string_view_isdecimal_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -480,7 +469,7 @@ def call_string_view_isspace(st, tbl): return _string_view_isspace(st, tbl) -@cuda_lower(isspace, string_view) +@cuda_lower("StringView.isspace", string_view) def string_view_isspace_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -501,7 +490,7 @@ def call_string_view_isupper(st, tbl): return _string_view_isupper(st, tbl) -@cuda_lower(isupper, string_view) +@cuda_lower("StringView.isupper", string_view) def string_view_isupper_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -523,7 +512,7 @@ def call_string_view_islower(st, tbl): return _string_view_islower(st, tbl) -@cuda_lower(islower, string_view) +@cuda_lower("StringView.islower", string_view) def string_view_islower_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) @@ -539,3 +528,20 @@ def string_view_islower_impl(context, builder, sig, args): ) return result + +@cuda_lower("StringView.isnumeric", string_view) +def string_view_isnumeric_impl(context, builder, sig, args): + sv_ptr = builder.alloca(args[0].type) + builder.store(args[0], sv_ptr) + tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) + + result = context.compile_internal( + builder, + call_string_view_isnumeric, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (sv_ptr, tbl_ptr), + ) + + return result diff --git a/python/strings_udf/strings_udf/tests/__init__.py b/python/strings_udf/strings_udf/tests/__init__.py index c7efe5c838e..e69de29bb2d 100644 --- a/python/strings_udf/strings_udf/tests/__init__.py +++ b/python/strings_udf/strings_udf/tests/__init__.py @@ -1,6 +0,0 @@ -from strings_udf import lowering -from strings_udf._lib.cudf_jit_udf import get_character_flags_table_ptr - -character_flags_table_ptr = get_character_flags_table_ptr() -lowering.character_flags_table_ptr = character_flags_table_ptr - diff --git a/python/strings_udf/strings_udf/tests/test_count.py b/python/strings_udf/strings_udf/tests/test_count.py index b30dd29332b..0b9b284d9cd 100644 --- a/python/strings_udf/strings_udf/tests/test_count.py +++ b/python/strings_udf/strings_udf/tests/test_count.py @@ -2,7 +2,6 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import count @pytest.mark.parametrize( "data", [ @@ -14,6 +13,6 @@ def test_string_udf_count(data, substr): # tests the `count` function in string udfs def func(st): - return count(st, substr) + return st.count(substr) run_udf_test(data, func, 'int32') diff --git a/python/strings_udf/strings_udf/tests/test_endswith.py b/python/strings_udf/strings_udf/tests/test_endswith.py index 8b72ea561a2..0601429b1bf 100644 --- a/python/strings_udf/strings_udf/tests/test_endswith.py +++ b/python/strings_udf/strings_udf/tests/test_endswith.py @@ -2,7 +2,6 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import ends_with @pytest.mark.parametrize( "data", [ @@ -14,6 +13,6 @@ def test_string_udf_endswith(data, substr): # tests the `endswith` function in string udfs def func(st): - return ends_with(st, substr) + return st.endswith(substr) run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_find.py b/python/strings_udf/strings_udf/tests/test_find.py index e287a7b2943..6744def0993 100644 --- a/python/strings_udf/strings_udf/tests/test_find.py +++ b/python/strings_udf/strings_udf/tests/test_find.py @@ -2,7 +2,6 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import find @pytest.mark.parametrize( "data", [ @@ -14,6 +13,6 @@ def test_string_udf_find(data, substr): # tests the `find` function in string udfs def func(st): - return find(st, substr) + return st.find(substr) run_udf_test(data, func, 'int32') diff --git a/python/strings_udf/strings_udf/tests/test_isalnum.py b/python/strings_udf/strings_udf/tests/test_isalnum.py index 9bbc959582e..a722def6313 100644 --- a/python/strings_udf/strings_udf/tests/test_isalnum.py +++ b/python/strings_udf/strings_udf/tests/test_isalnum.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isalnum @pytest.mark.parametrize("data", [["1", "1@2", "123abc", "2.1", "", "0003"]]) def test_string_udf_isalnum(data): # tests the `rfind` function in string udfs def func(st): - return isalnum(st) + return st.isalnum() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isalpha.py b/python/strings_udf/strings_udf/tests/test_isalpha.py index b2f54f5c273..5faf918afff 100644 --- a/python/strings_udf/strings_udf/tests/test_isalpha.py +++ b/python/strings_udf/strings_udf/tests/test_isalpha.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isalpha @pytest.mark.parametrize("data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]]) def test_string_udf_isalpha(data): # tests the `isalpha` function in string udfs def func(st): - return isalpha(st) + return st.isalpha() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isdecimal.py b/python/strings_udf/strings_udf/tests/test_isdecimal.py index e4053ac52df..53adb3601d7 100644 --- a/python/strings_udf/strings_udf/tests/test_isdecimal.py +++ b/python/strings_udf/strings_udf/tests/test_isdecimal.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isdecimal @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) def test_string_udf_isdecimal(data): # tests the `isdecimal` function in string udfs def func(st): - return isdecimal(st) + return st.isdecimal() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isdigit.py b/python/strings_udf/strings_udf/tests/test_isdigit.py index 59e2a467433..0a13ba365ff 100644 --- a/python/strings_udf/strings_udf/tests/test_isdigit.py +++ b/python/strings_udf/strings_udf/tests/test_isdigit.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isdigit @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) def test_string_udf_isdigit(data): # tests the `isdigit` function in string udfs def func(st): - return isdigit(st) + return st.isdigit() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_islower.py b/python/strings_udf/strings_udf/tests/test_islower.py index 23e732185d4..e37771a8adf 100644 --- a/python/strings_udf/strings_udf/tests/test_islower.py +++ b/python/strings_udf/strings_udf/tests/test_islower.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import islower @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003", 'abc', 'b a', 'AbC']]) def test_string_udf_islower(data): # tests the `islower` function in string udfs def func(st): - return islower(st) + return st.islower() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isnumeric.py b/python/strings_udf/strings_udf/tests/test_isnumeric.py index 6e0d9ad4d9b..8480740f1c3 100644 --- a/python/strings_udf/strings_udf/tests/test_isnumeric.py +++ b/python/strings_udf/strings_udf/tests/test_isnumeric.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isnumeric @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) def test_string_udf_isnumeric(data): # tests the `isnumeric` function in string udfs def func(st): - return isnumeric(st) + return st.isnumeric() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isspace.py b/python/strings_udf/strings_udf/tests/test_isspace.py index 556ed1b4b87..db5571c6f8a 100644 --- a/python/strings_udf/strings_udf/tests/test_isspace.py +++ b/python/strings_udf/strings_udf/tests/test_isspace.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isspace @pytest.mark.parametrize("data", [["1", " x ", " ", "2.1", "", "0003"]]) def test_string_udf_isspace(data): # tests the `isspace` function in string udfs def func(st): - return isspace(st) + return st.isspace() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_isupper.py b/python/strings_udf/strings_udf/tests/test_isupper.py index 08fbc3163da..ad4940a6bf1 100644 --- a/python/strings_udf/strings_udf/tests/test_isupper.py +++ b/python/strings_udf/strings_udf/tests/test_isupper.py @@ -2,13 +2,12 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import isupper @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]]) def test_string_udf_isupper(data): # tests the `isupper` function in string udfs def func(st): - return isupper(st) + return st.isupper() run_udf_test(data, func, 'bool') diff --git a/python/strings_udf/strings_udf/tests/test_rfind.py b/python/strings_udf/strings_udf/tests/test_rfind.py index 369826bfa5c..72e529f274c 100644 --- a/python/strings_udf/strings_udf/tests/test_rfind.py +++ b/python/strings_udf/strings_udf/tests/test_rfind.py @@ -2,7 +2,6 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import rfind @pytest.mark.parametrize( "data", [ @@ -14,6 +13,6 @@ def test_string_udf_rfind(data, substr): # tests the `rfind` function in string udfs def func(st): - return rfind(st, substr) + return st.rfind(substr) run_udf_test(data, func, 'int32') diff --git a/python/strings_udf/strings_udf/tests/test_startswith.py b/python/strings_udf/strings_udf/tests/test_startswith.py index 1550b11476e..1822bd78239 100644 --- a/python/strings_udf/strings_udf/tests/test_startswith.py +++ b/python/strings_udf/strings_udf/tests/test_startswith.py @@ -2,7 +2,6 @@ from .utils import run_udf_test import pytest -from strings_udf._typing import starts_with @pytest.mark.parametrize( "data", [ @@ -14,6 +13,6 @@ def test_string_udf_startswith(data, substr): # tests the `startswith` function in string udfs def func(st): - return starts_with(st, substr) + return st.startswith(substr) run_udf_test(data, func, 'bool') From 3710d9b7597fb37892b0e1b2c3d4226aad39845b Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 21 Jul 2022 16:13:14 -0500 Subject: [PATCH 044/212] Fix style checks for string_udfs. --- .../cudf/_lib/cpp/column/column_factories.pxd | 1 + python/cudf/cudf/core/indexed_frame.py | 10 +- python/cudf/cudf/core/udf/masked_lowering.py | 14 +- python/cudf/cudf/core/udf/masked_typing.py | 10 +- python/cudf/cudf/core/udf/row_function.py | 9 +- python/cudf/cudf/core/udf/scalar_function.py | 2 +- python/cudf/cudf/core/udf/strings_lowering.py | 170 ++++++++------- python/cudf/cudf/core/udf/strings_typing.py | 100 +++++---- python/cudf/cudf/core/udf/utils.py | 44 ++-- python/cudf/cudf/tests/test_udf_masked_ops.py | 30 +-- python/cudf/setup.cfg | 3 +- python/strings_udf/cpp/tests/run_tests.sh | 2 + .../strings_udf/_lib/cpp/strings_udf.pxd | 19 +- .../strings_udf/_lib/cudf_jit_udf.pyx | 22 +- .../strings_udf/strings_udf/_lib/tables.pyx | 8 +- python/strings_udf/strings_udf/_typing.py | 197 +++++++----------- python/strings_udf/strings_udf/lowering.py | 182 ++++++++-------- .../strings_udf/tests/test_cmpops.py | 28 ++- .../strings_udf/tests/test_contains.py | 7 +- .../strings_udf/tests/test_count.py | 12 +- .../strings_udf/tests/test_endswith.py | 12 +- .../strings_udf/tests/test_find.py | 12 +- .../strings_udf/tests/test_isalnum.py | 6 +- .../strings_udf/tests/test_isalpha.py | 10 +- .../strings_udf/tests/test_isdecimal.py | 6 +- .../strings_udf/tests/test_isdigit.py | 6 +- .../strings_udf/tests/test_islower.py | 10 +- .../strings_udf/tests/test_isnumeric.py | 6 +- .../strings_udf/tests/test_isspace.py | 6 +- .../strings_udf/tests/test_isupper.py | 10 +- .../strings_udf/tests/test_rfind.py | 12 +- .../strings_udf/tests/test_startswith.py | 12 +- python/strings_udf/strings_udf/tests/utils.py | 5 +- 33 files changed, 512 insertions(+), 471 deletions(-) diff --git a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd index d3148dd28cc..0f22e788bd7 100644 --- a/python/cudf/cudf/_lib/cpp/column/column_factories.pxd +++ b/python/cudf/cudf/_lib/cpp/column/column_factories.pxd @@ -6,6 +6,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.scalar.scalar cimport scalar from cudf._lib.cpp.types cimport data_type, mask_state, size_type + cdef extern from "cudf/column/column_factories.hpp" namespace "cudf" nogil: cdef unique_ptr[column] make_numeric_column(data_type type, size_type size, diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 4fa2a1b13fa..3ef86598e49 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -49,7 +49,13 @@ from cudf.core.index import Index, RangeIndex, _index_from_columns from cudf.core.missing import NA from cudf.core.multiindex import MultiIndex -from cudf.core.udf.utils import _compile_or_get, _launch_arg_from_col, _supported_cols_from_frame, _return_col_from_dtype, _post_process_output_col +from cudf.core.udf.utils import ( + _compile_or_get, + _launch_arg_from_col, + _post_process_output_col, + _return_col_from_dtype, + _supported_cols_from_frame, +) from cudf.utils import docutils from cudf.utils.utils import _cudf_nvtx_annotate @@ -1809,7 +1815,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): offsets.append(col.offset) launch_args += offsets launch_args += list(args) - + try: kernel.forall(len(self))(*launch_args) except Exception as e: diff --git a/python/cudf/cudf/core/udf/masked_lowering.py b/python/cudf/cudf/core/udf/masked_lowering.py index 26f4040a56a..e1ef5f8e61d 100644 --- a/python/cudf/cudf/core/udf/masked_lowering.py +++ b/python/cudf/cudf/core/udf/masked_lowering.py @@ -5,13 +5,14 @@ from llvmlite import ir from numba.core import cgutils from numba.core.typing import signature as nb_signature -from numba.cuda.cudadrv import nvvm from numba.cuda.cudaimpl import ( lower as cuda_lower, registry as cuda_lowering_registry, ) from numba.extending import lower_builtin, types +from strings_udf._typing import string_view + from cudf.core.udf import api from cudf.core.udf._ops import ( arith_ops, @@ -19,16 +20,9 @@ comparison_ops, unary_ops, ) -from cudf.core.udf.masked_typing import ( - MaskedType, - NAType, -) - -import operator +from cudf.core.udf.masked_typing import MaskedType, NAType -from strings_udf._typing import string_view - @cuda_lowering_registry.lower_constant(NAType) def constant_na(context, builder, ty, pyval): # This handles None, etc. @@ -295,6 +289,7 @@ def pack_return_scalar_impl(context, builder, sig, args): return outdata._getvalue() + @cuda_lower(operator.truth, MaskedType) def masked_scalar_truth_impl(context, builder, sig, args): indata = cgutils.create_struct_proxy(MaskedType(types.boolean))( @@ -368,7 +363,6 @@ def masked_constructor(context, builder, sig, args): return masked._getvalue() - # Allows us to make an instance of MaskedType a global variable # and properly use it inside functions we will later compile @cuda_lowering_registry.lower_constant(MaskedType) diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index aa2ef8f8df6..18bf5e3cd50 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -2,7 +2,7 @@ import operator -from numba import cuda, types +from numba import types from numba.core.extending import ( make_attribute_wrapper, models, @@ -18,6 +18,8 @@ from numba.core.typing.typeof import typeof from numba.cuda.cudadecl import registry as cuda_decl_registry +from strings_udf._typing import StringView, string_view + from cudf.core.missing import NA from cudf.core.udf import api from cudf.core.udf._ops import ( @@ -35,9 +37,6 @@ types.PyObject, ) -import operator - -from strings_udf._typing import string_view, StringView # Masked scalars of all types class MaskedType(types.Type): @@ -131,6 +130,7 @@ def __eq__(self, other): # Require a cast for another masked with a different value type return self.value_type == other.value_type + # For typing a Masked constant value defined outside a kernel (e.g. captured in # a closure). @typeof_impl.register(api.Masked) @@ -163,6 +163,7 @@ class MaskedConstructor(ConcreteTemplate): make_attribute_wrapper(MaskedType, "value", "value") make_attribute_wrapper(MaskedType, "valid", "valid") + # Typing for `api.Masked` @cuda_decl_registry.register_attr class ClassesTemplate(AttributeTemplate): @@ -365,7 +366,6 @@ def generic(self, args, kws): return nb_signature(return_type, args[0]) - for binary_op in arith_ops + bitwise_ops + comparison_ops: # Every op shares the same typing class cuda_decl_registry.register_global(binary_op)(MaskedScalarArithOp) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index fb9e9690ce0..028d8bcb5a7 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -6,14 +6,16 @@ from numba.np import numpy_support from numba.types import Record +from strings_udf._typing import DString + from cudf.core.udf.api import Masked, pack_return +from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.templates import ( masked_input_initializer_template, row_initializer_template, row_kernel_template, unmasked_input_initializer_template, ) -from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.utils import ( _all_dtypes_from_frame, _construct_signature, @@ -24,7 +26,6 @@ _supported_dtypes_from_frame, ) -from strings_udf._typing import DString dstring = DString() @@ -50,7 +51,7 @@ def _get_frame_row_type(dtype): sizes = [] for field in dtype.fields.values(): - if field[0] == np.dtype('object'): + if field[0] == np.dtype("object"): sizes.append(dstring.size_bytes) else: sizes.append(field[0].itemsize) @@ -71,7 +72,7 @@ def _get_frame_row_type(dtype): fields.append((name, infos)) # increment offset by itemsize plus one byte for validity - if elemdtype == np.dtype('object'): + if elemdtype == np.dtype("object"): itemsize = dstring.size_bytes else: itemsize = elemdtype.itemsize diff --git a/python/cudf/cudf/core/udf/scalar_function.py b/python/cudf/cudf/core/udf/scalar_function.py index 26d88fca7a5..31599f4151e 100644 --- a/python/cudf/cudf/core/udf/scalar_function.py +++ b/python/cudf/cudf/core/udf/scalar_function.py @@ -4,12 +4,12 @@ from numba.np import numpy_support from cudf.core.udf.api import Masked, pack_return +from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.templates import ( masked_input_initializer_template, scalar_kernel_template, unmasked_input_initializer_template, ) -from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.utils import ( _construct_signature, _get_kernel, diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index 77fb5f90dde..02850dae2b2 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -1,33 +1,30 @@ # Copyright (c) 2022, NVIDIA CORPORATION. +import operator + +from numba import types +from numba.core import cgutils +from numba.cuda.cudaimpl import lower as cuda_lower + from strings_udf._typing import string_view from strings_udf.lowering import ( - string_view_len_impl, - string_view_startswith_impl, - string_view_endswith_impl, - string_view_find_impl, - string_view_rfind_impl, string_view_contains_impl, + string_view_endswith_impl, + string_view_find_impl, string_view_isalnum_impl, string_view_isalpha_impl, string_view_isdecimal_impl, string_view_isdigit_impl, - string_view_isupper_impl, string_view_islower_impl, - string_view_isspace_impl + string_view_isspace_impl, + string_view_isupper_impl, + string_view_len_impl, + string_view_rfind_impl, + string_view_startswith_impl, ) -from numba import types from cudf.core.udf.masked_typing import MaskedType -from numba.cuda.cudaimpl import ( - lower as cuda_lower, - registry as cuda_lowering_registry, -) - -from numba.core import cgutils -import operator - @cuda_lower(len, MaskedType(string_view)) def masked_string_view_len_impl(context, builder, sig, args): @@ -36,7 +33,9 @@ def masked_string_view_len_impl(context, builder, sig, args): masked_sv = cgutils.create_struct_proxy(masked_sv_ty)( context, builder, value=args[0] ) - result = string_view_len_impl(context, builder, types.int32(string_view), (masked_sv.value,)) + result = string_view_len_impl( + context, builder, types.int32(string_view), (masked_sv.value,) + ) ret.value = result ret.valid = masked_sv.valid @@ -56,10 +55,10 @@ def masked_string_view_startswith_impl(context, builder, sig, args): context, builder, value=args[1] ) result = string_view_startswith_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value), ) ret.value = result @@ -80,16 +79,17 @@ def masked_string_view_endswith_impl(context, builder, sig, args): context, builder, value=args[1] ) result = string_view_endswith_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value), ) ret.value = result ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) return ret._getvalue() + @cuda_lower( "MaskedType.find", MaskedType(string_view), MaskedType(string_view) ) @@ -103,16 +103,17 @@ def masked_string_view_find_impl(context, builder, sig, args): context, builder, value=args[1] ) result = string_view_find_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value), ) ret.value = result ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) return ret._getvalue() + @cuda_lower( "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) ) @@ -126,17 +127,20 @@ def masked_string_view_rfind_impl(context, builder, sig, args): context, builder, value=args[1] ) result = string_view_rfind_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value), ) ret.value = result ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) return ret._getvalue() -@cuda_lower(operator.contains, MaskedType(string_view), MaskedType(string_view)) + +@cuda_lower( + operator.contains, MaskedType(string_view), MaskedType(string_view) +) def masked_string_view_contains_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -147,19 +151,18 @@ def masked_string_view_contains_impl(context, builder, sig, args): context, builder, value=args[1] ) result = string_view_contains_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value), ) ret.value = result ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) return ret._getvalue() -@cuda_lower( - "MaskedType.isalnum", MaskedType(string_view) -) + +@cuda_lower("MaskedType.isalnum", MaskedType(string_view)) def masked_string_view_isalnum_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -168,19 +171,18 @@ def masked_string_view_isalnum_impl(context, builder, sig, args): ) result = string_view_isalnum_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result ret.valid = masked_sv_str.valid return ret._getvalue() -@cuda_lower( - "MaskedType.isalpha", MaskedType(string_view) -) + +@cuda_lower("MaskedType.isalpha", MaskedType(string_view)) def masked_string_view_isalpha_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -189,19 +191,18 @@ def masked_string_view_isalpha_impl(context, builder, sig, args): ) result = string_view_isalpha_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result ret.valid = masked_sv_str.valid return ret._getvalue() -@cuda_lower( - "MaskedType.isdigit", MaskedType(string_view) -) + +@cuda_lower("MaskedType.isdigit", MaskedType(string_view)) def masked_string_view_isdigit_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -210,19 +211,18 @@ def masked_string_view_isdigit_impl(context, builder, sig, args): ) result = string_view_isdigit_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result ret.valid = masked_sv_str.valid return ret._getvalue() -@cuda_lower( - "MaskedType.isdecimal", MaskedType(string_view) -) + +@cuda_lower("MaskedType.isdecimal", MaskedType(string_view)) def masked_string_view_isdecimal_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -231,19 +231,18 @@ def masked_string_view_isdecimal_impl(context, builder, sig, args): ) result = string_view_isdecimal_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result ret.valid = masked_sv_str.valid return ret._getvalue() -@cuda_lower( - "MaskedType.isupper", MaskedType(string_view) -) + +@cuda_lower("MaskedType.isupper", MaskedType(string_view)) def masked_string_view_isupper_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -252,19 +251,18 @@ def masked_string_view_isupper_impl(context, builder, sig, args): ) result = string_view_isupper_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result ret.valid = masked_sv_str.valid return ret._getvalue() -@cuda_lower( - "MaskedType.islower", MaskedType(string_view) -) + +@cuda_lower("MaskedType.islower", MaskedType(string_view)) def masked_string_view_islower_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -273,10 +271,10 @@ def masked_string_view_islower_impl(context, builder, sig, args): ) result = string_view_islower_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result @@ -284,9 +282,7 @@ def masked_string_view_islower_impl(context, builder, sig, args): return ret._getvalue() -@cuda_lower( - "MaskedType.isspace", MaskedType(string_view) -) +@cuda_lower("MaskedType.isspace", MaskedType(string_view)) def masked_string_view_isspace_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] @@ -295,10 +291,10 @@ def masked_string_view_isspace_impl(context, builder, sig, args): ) result = string_view_isspace_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,) + context, + builder, + types.boolean(string_view, string_view), + (masked_sv_str.value,), ) ret.value = result diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index f27b8d36622..69236259641 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -1,22 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -#make_attribute_wrapper(StringView, "data", "data") -from numba.core.typing.templates import ( - AbstractTemplate, - AttributeTemplate, -) - import operator -from cudf.core.udf.masked_typing import MaskedType - -from strings_udf._typing import StringView, string_view -from numba.cuda.cudadecl import registry as cuda_decl_registry from numba import types from numba.core.typing import signature as nb_signature +from numba.core.typing.templates import AbstractTemplate, AttributeTemplate +from numba.cuda.cudadecl import registry as cuda_decl_registry + +from strings_udf._typing import StringView, string_view from cudf.core.udf._ops import comparison_ops +from cudf.core.udf.masked_typing import MaskedType + # String functions @cuda_decl_registry.register_global(len) @@ -31,6 +27,7 @@ def generic(self, args, kws): ): return nb_signature(MaskedType(types.int32), args[0]) + @cuda_decl_registry.register_global(operator.contains) class MaskedStringViewContains(AbstractTemplate): """ @@ -38,12 +35,21 @@ class MaskedStringViewContains(AbstractTemplate): """ def generic(self, args, kws): - if (isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView - ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( - args[1].value_type, StringView - ) or isinstance(args[1], types.StringLiteral)): - return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) + if ( + isinstance(args[0], MaskedType) + and isinstance(args[0].value_type, StringView) + or isinstance(args[0], types.StringLiteral) + ) and ( + isinstance(args[1], MaskedType) + and isinstance(args[1].value_type, StringView) + or isinstance(args[1], types.StringLiteral) + ): + return nb_signature( + MaskedType(types.boolean), + MaskedType(string_view), + MaskedType(string_view), + ) + class MaskedStringViewCmpOp(AbstractTemplate): """ @@ -53,12 +59,21 @@ class MaskedStringViewCmpOp(AbstractTemplate): """ def generic(self, args, kws): - if (isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView - ) or isinstance(args[0], types.StringLiteral)) and (isinstance(args[1], MaskedType) and isinstance( - args[1].value_type, StringView - ) or isinstance(args[1], types.StringLiteral)): - return nb_signature(MaskedType(types.boolean), MaskedType(string_view), MaskedType(string_view)) + if ( + isinstance(args[0], MaskedType) + and isinstance(args[0].value_type, StringView) + or isinstance(args[0], types.StringLiteral) + ) and ( + isinstance(args[1], MaskedType) + and isinstance(args[1].value_type, StringView) + or isinstance(args[1], types.StringLiteral) + ): + return nb_signature( + MaskedType(types.boolean), + MaskedType(string_view), + MaskedType(string_view), + ) + @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): @@ -71,6 +86,7 @@ def generic(self, args, kws): if isinstance(args[0], types.StringLiteral) and len(args) == 1: return nb_signature(types.int32, args[0]) + class MaskedStringViewStartsWith(AbstractTemplate): key = "MaskedType.startswith" @@ -79,6 +95,7 @@ def generic(self, args, kws): MaskedType(types.boolean), MaskedType(string_view), recvr=self.this ) + class MaskedStringViewEndsWith(AbstractTemplate): key = "MaskedType.endswith" @@ -87,6 +104,7 @@ def generic(self, args, kws): MaskedType(types.boolean), MaskedType(string_view), recvr=self.this ) + class MaskedStringViewFind(AbstractTemplate): key = "MaskedType.find" @@ -95,6 +113,7 @@ def generic(self, args, kws): MaskedType(types.int32), MaskedType(string_view), recvr=self.this ) + class MaskedStringViewRFind(AbstractTemplate): key = "MaskedType.rfind" @@ -103,61 +122,54 @@ def generic(self, args, kws): MaskedType(types.int32), MaskedType(string_view), recvr=self.this ) + class MaskedStringViewIsAlnum(AbstractTemplate): key = "MaskedType.isalnum" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) + class MaskedStringViewIsAlpha(AbstractTemplate): key = "MaskedType.isalpha" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) + class MaskedStringViewIsDecimal(AbstractTemplate): key = "MaskedType.isdecimal" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) + class MaskedStringViewIsDigit(AbstractTemplate): key = "MaskedType.isdigit" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) + class MaskedStringViewIsLower(AbstractTemplate): key = "MaskedType.islower" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) + class MaskedStringViewIsUpper(AbstractTemplate): key = "MaskedType.isupper" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) + class MaskedStringViewIsSpace(AbstractTemplate): key = "MaskedType.isspace" def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), recvr=self.this - ) + return nb_signature(MaskedType(types.boolean), recvr=self.this) @cuda_decl_registry.register_attr @@ -219,12 +231,12 @@ def resolve_isspace(self, mod): MaskedStringViewIsSpace, MaskedType(string_view) ) - def resolve_value(self, mod): return string_view def resolve_valid(self, mod): return types.boolean + for op in comparison_ops: cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 936c638fcb0..223a26de401 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -3,34 +3,36 @@ from typing import Callable import cachetools +import cupy as cp import numpy as np from numba import cuda, typeof from numba.core.errors import TypingError from numba.np import numpy_support -from numba.types import Poison, Tuple, boolean, int64, void, CPointer +from numba.types import CPointer, Poison, Tuple, boolean, int64, void -import cupy as cp +from strings_udf import ptxpath +from strings_udf._typing import str_view_arg_handler, string_view + +from cudf.api.types import is_string_dtype +from cudf.core.column.column import as_column from cudf.core.dtypes import CategoricalDtype from cudf.core.udf.masked_typing import MaskedType -from cudf.core.column.column import as_column from cudf.utils import cudautils from cudf.utils.dtypes import ( BOOL_TYPES, DATETIME_TYPES, NUMERIC_TYPES, - TIMEDELTA_TYPES, STRING_TYPES, + TIMEDELTA_TYPES, ) -from cudf.api.types import is_string_dtype -from strings_udf._typing import str_view_arg_handler, string_view -from strings_udf import ptxpath - from cudf.utils.utils import _cudf_nvtx_annotate -import rmm - JIT_SUPPORTED_TYPES = ( - NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES + NUMERIC_TYPES + | BOOL_TYPES + | DATETIME_TYPES + | TIMEDELTA_TYPES + | STRING_TYPES ) libcudf_bitmask_type = numpy_support.from_dtype(np.dtype("int32")) MASK_BITSIZE = np.dtype("int32").itemsize * 8 @@ -134,12 +136,7 @@ def _masked_array_type_from_col(col): if col.mask is None: return col_type else: - return Tuple( - ( - col_type, - libcudf_bitmask_type[::1] - ) - ) + return Tuple((col_type, libcudf_bitmask_type[::1])) def _construct_signature(frame, return_type, args): @@ -231,22 +228,31 @@ def _get_kernel(kernel_string, globals_, sig, func): globals_["f_"] = f_ exec(kernel_string, globals_) _kernel = globals_["_kernel"] - kernel = cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler])(_kernel) + kernel = cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler])( + _kernel + ) return kernel + def _launch_arg_from_col(col): from strings_udf._lib.cudf_jit_udf import to_string_view_array - data = col.data if not is_string_dtype(col.dtype) else to_string_view_array(col) + data = ( + col.data + if not is_string_dtype(col.dtype) + else to_string_view_array(col) + ) mask = col.mask if mask is None: return data else: return data, mask + def _return_col_from_dtype(dt, size): return cp.empty(size, dtype=dt) + def _post_process_output_col(col, retty): return as_column(col, retty) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index b599114202c..2650c989ecd 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -786,6 +786,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) + @pytest.mark.parametrize( "data", [ @@ -808,7 +809,7 @@ def test_string_udf_contains(data, substr): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return substr in st run_masked_udf_test(func, data, check_dtype=False) @@ -836,11 +837,12 @@ def test_string_udf_cmpops(data, other, cmpop): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return cmpop(st, other) run_masked_udf_test(func, data, check_dtype=False) + @pytest.mark.parametrize( "data", [ @@ -861,11 +863,12 @@ def test_string_udf_isalnum(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.isalnum() run_masked_udf_test(func, data, check_dtype=False) + @pytest.mark.parametrize( "data", [ @@ -886,11 +889,12 @@ def test_string_udf_isalpha(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.isalpha() run_masked_udf_test(func, data, check_dtype=False) + @pytest.mark.parametrize( "data", [ @@ -911,11 +915,12 @@ def test_string_udf_isdigit(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.isdigit() run_masked_udf_test(func, data, check_dtype=False) + @pytest.mark.parametrize( "data", [ @@ -930,8 +935,7 @@ def func(row): "@2a", "12.34", "0.123", - ".123" - ".12abc" + ".123" ".12abc", ] } ], @@ -940,7 +944,7 @@ def test_string_udf_isdecimal(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.isdecimal() run_masked_udf_test(func, data, check_dtype=False) @@ -959,7 +963,7 @@ def func(row): "12 ab", "@2a", "12.34", - "ABC DEF" + "ABC DEF", ] } ], @@ -968,7 +972,7 @@ def test_string_udf_isupper(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.isupper() run_masked_udf_test(func, data, check_dtype=False) @@ -987,7 +991,7 @@ def func(row): "12 ab", "@2a", "12.34", - "abc def" + "abc def", ] } ], @@ -996,7 +1000,7 @@ def test_string_udf_islower(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.islower() run_masked_udf_test(func, data, check_dtype=False) @@ -1021,7 +1025,7 @@ def test_string_udf_isspace(data): data = cudf.DataFrame(data) def func(row): - st = row['str_col'] + st = row["str_col"] return st.isspace() run_masked_udf_test(func, data, check_dtype=False) diff --git a/python/cudf/setup.cfg b/python/cudf/setup.cfg index 1f7cfeb49ae..8a648097ac8 100644 --- a/python/cudf/setup.cfg +++ b/python/cudf/setup.cfg @@ -25,6 +25,7 @@ known_dask= dask_cuda known_rapids= rmm + strings_udf known_first_party= cudf default_section=THIRDPARTY @@ -41,4 +42,4 @@ skip= buck-out build dist - __init__.py \ No newline at end of file + __init__.py diff --git a/python/strings_udf/cpp/tests/run_tests.sh b/python/strings_udf/cpp/tests/run_tests.sh index ab8ebaca6c1..4af1217c58a 100755 --- a/python/strings_udf/cpp/tests/run_tests.sh +++ b/python/strings_udf/cpp/tests/run_tests.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Copyright (c) 2022, NVIDIA CORPORATION. + ./udf_cli -u ../tests/ctors.udf -t ../tests/done.txt ./udf_cli -u ../tests/append.udf -t ../tests/done.txt ./udf_cli -u ../tests/insert.udf -t ../tests/done.txt diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index 4b3c6de4b2d..35ed54bd4c3 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -1,24 +1,25 @@ # Copyright (c) 2021-2022, NVIDIA CORPORATION. -from libcpp.vector cimport vector -from libcpp.string cimport string -from libcpp.memory cimport unique_ptr from libc.stdint cimport uint8_t +from libcpp.memory cimport unique_ptr +from libcpp.string cimport string +from libcpp.vector cimport vector + +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -from cudf._lib.cpp.types cimport size_type from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -# cdef extern from "cudf/strings/udf/udf_apis.hpp": cdef cppclass udf_module - # cdef unique_ptr[udf_module] create_udf_module(string, vector[string]) - cdef unique_ptr[column] call_udf(udf_module, string, size_type, vector[column_view]) + cdef unique_ptr[column] call_udf( + udf_module, string, size_type, vector[column_view]) cdef unique_ptr[device_buffer] to_string_view_array(column_view) cdef unique_ptr[column] from_dstring_array(void*, size_t) -cdef extern from "cudf/strings/detail/char_tables.hpp" namespace "cudf::strings::detail": +cdef extern from "cudf/strings/detail/char_tables.hpp" namespace \ + "cudf::strings::detail": cdef const uint8_t* get_character_flags_table() except + diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index a721fa9d93d..cb0a8424a13 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -5,20 +5,19 @@ import os -from libcpp.string cimport string -from libcpp.vector cimport vector from libcpp.memory cimport unique_ptr +from libcpp.string cimport string from libcpp.utility cimport move +from libcpp.vector cimport vector from cudf.core.buffer import Buffer +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + +from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type -from cudf._lib.column cimport Column - -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer - from strings_udf._lib.cpp.strings_udf cimport ( call_udf as cpp_call_udf, create_udf_module as cpp_create_udf_module, @@ -29,7 +28,8 @@ from strings_udf._lib.cpp.strings_udf cimport ( import numpy as np -def process_udf( udf, name, cols ): + +def process_udf(udf, name, cols): cdef string c_udf cdef string c_name cdef size_type c_size @@ -52,11 +52,11 @@ def process_udf( udf, name, cols ): include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" c_options.push_back(str(include_path).encode('UTF-8')) - #with nogil: + # with nogil: c_module = move(cpp_create_udf_module(c_udf, c_options)) # c_module will be nullptr if there is a compile error - #with nogil: + # with nogil: c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) return Column.from_unique_ptr(move(c_result)) @@ -65,7 +65,7 @@ def process_udf( udf, name, cols ): def to_string_view_array(Column strings_col): cdef unique_ptr[device_buffer] c_buffer - #with nogil: + # with nogil: c_buffer = move(cpp_to_string_view_array(strings_col.view())) buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) @@ -79,7 +79,7 @@ def from_dstring_array(DeviceBuffer d_buffer): cdef unique_ptr[column] c_result # data = - #with nogil: + # with nogil: c_result = move(cpp_from_dstring_array(data, size)) return Column.from_unique_ptr(move(c_result)) diff --git a/python/strings_udf/strings_udf/_lib/tables.pyx b/python/strings_udf/strings_udf/_lib/tables.pyx index f78faeef1ea..b24aa19155d 100644 --- a/python/strings_udf/strings_udf/_lib/tables.pyx +++ b/python/strings_udf/strings_udf/_lib/tables.pyx @@ -3,8 +3,12 @@ # distutils: language = c++ # cython: c_string_type=unicode, c_string_encoding=utf8 -from strings_udf._lib.cpp.strings_udf cimport get_character_flags_table as cpp_get_character_flags_table -from libc.stdint cimport uintptr_t, uint8_t +from libc.stdint cimport uint8_t, uintptr_t + +from strings_udf._lib.cpp.strings_udf cimport ( + get_character_flags_table as cpp_get_character_flags_table, +) + import numpy as np diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index 38fc30b41b9..f4ab69cf880 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -1,18 +1,15 @@ # Copyright (c) 2022, NVIDIA CORPORATION. +import operator + +import llvmlite.binding as ll from numba import cuda, types +from numba.core.datamodel import default_manager from numba.core.extending import models, register_model from numba.core.typing import signature as nb_signature from numba.core.typing.templates import AbstractTemplate, AttributeTemplate from numba.cuda.cudadecl import registry as cuda_decl_registry - -import operator - -import llvmlite.binding as ll from numba.cuda.cudadrv import nvvm -from numba.core.datamodel import default_manager - -import operator data_layout = nvvm.data_layout @@ -21,6 +18,7 @@ data_layout = data_layout[64] target_data = ll.create_target_data(data_layout) + # String object definitions class DString(types.Type): def __init__(self): @@ -121,7 +119,10 @@ def generic(self, args, kws): return nb_signature(types.int32, args[0]) -_string_view_len = cuda.declare_device("len", types.int32(types.CPointer(string_view))) +_string_view_len = cuda.declare_device( + "len", types.int32(types.CPointer(string_view)) +) + @cuda_decl_registry.register_global(operator.contains) class StringViewContains(AbstractTemplate): @@ -137,9 +138,11 @@ def generic(self, args, kws): _string_view_contains = cuda.declare_device( - "contains", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "contains", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) + @cuda_decl_registry.register_global(operator.eq) class StringViewEq(AbstractTemplate): """ @@ -156,7 +159,8 @@ def generic(self, args, kws): _string_view_eq = cuda.declare_device( - "eq", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "eq", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) @@ -176,7 +180,8 @@ def generic(self, args, kws): _string_view_ne = cuda.declare_device( - "ne", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "ne", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) @@ -196,7 +201,8 @@ def generic(self, args, kws): _string_view_ge = cuda.declare_device( - "ge", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "ge", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) @@ -216,7 +222,8 @@ def generic(self, args, kws): _string_view_le = cuda.declare_device( - "le", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "le", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) @@ -236,7 +243,8 @@ def generic(self, args, kws): _string_view_gt = cuda.declare_device( - "gt", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "gt", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) @@ -256,117 +264,100 @@ def generic(self, args, kws): _string_view_lt = cuda.declare_device( - "lt", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "lt", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) + class StringViewStartsWith(AbstractTemplate): key = "StringView.startswith" def generic(self, args, kws): - return nb_signature( - types.boolean, string_view, recvr=self.this - ) + return nb_signature(types.boolean, string_view, recvr=self.this) + class StringViewEndsWith(AbstractTemplate): key = "StringView.endswith" def generic(self, args, kws): - return nb_signature( - types.boolean, string_view, recvr=self.this - ) + return nb_signature(types.boolean, string_view, recvr=self.this) + class StringViewFind(AbstractTemplate): key = "StringView.find" def generic(self, args, kws): - return nb_signature( - types.int32, string_view, recvr=self.this - ) + return nb_signature(types.int32, string_view, recvr=self.this) + class StringViewRFind(AbstractTemplate): key = "StringView.rfind" def generic(self, args, kws): - return nb_signature( - types.int32, string_view, recvr=self.this - ) - + return nb_signature(types.int32, string_view, recvr=self.this) + + class StringViewIsAlnum(AbstractTemplate): key = "StringView.isalnum" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + - class StringViewIsAlpha(AbstractTemplate): key = "StringView.isalpha" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + - class StringViewIsDecimal(AbstractTemplate): key = "StringView.isdecimal" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + - class StringViewIsDigit(AbstractTemplate): key = "StringView.isdigit" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + class StringViewIsNumeric(AbstractTemplate): key = "StringView.isnumeric" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + class StringViewIsUpper(AbstractTemplate): key = "StringView.isupper" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + - class StringViewIsLower(AbstractTemplate): key = "StringView.islower" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + - class StringViewIsSpace(AbstractTemplate): key = "StringView.isspace" def generic(self, args, kws): - return nb_signature( - types.boolean, recvr=self.this - ) + return nb_signature(types.boolean, recvr=self.this) + class StringViewCount(AbstractTemplate): key = "StringView.count" def generic(self, args, kws): - return nb_signature( - types.int32, string_view, recvr=self.this - ) + return nb_signature(types.int32, string_view, recvr=self.this) @cuda_decl_registry.register_attr @@ -374,69 +365,44 @@ class StringViewAttrs(AttributeTemplate): key = string_view def resolve_startswith(self, mod): - return types.BoundFunction( - StringViewStartsWith, string_view - ) + return types.BoundFunction(StringViewStartsWith, string_view) def resolve_endswith(self, mod): - return types.BoundFunction( - StringViewEndsWith, string_view - ) + return types.BoundFunction(StringViewEndsWith, string_view) def resolve_find(self, mod): - return types.BoundFunction( - StringViewFind, string_view - ) + return types.BoundFunction(StringViewFind, string_view) def resolve_rfind(self, mod): - return types.BoundFunction( - StringViewRFind, string_view - ) + return types.BoundFunction(StringViewRFind, string_view) def resolve_isalnum(self, mod): - return types.BoundFunction( - StringViewIsAlnum, string_view - ) + return types.BoundFunction(StringViewIsAlnum, string_view) def resolve_isalpha(self, mod): - return types.BoundFunction( - StringViewIsAlpha, string_view - ) + return types.BoundFunction(StringViewIsAlpha, string_view) def resolve_isdecimal(self, mod): - return types.BoundFunction( - StringViewIsDecimal, string_view - ) + return types.BoundFunction(StringViewIsDecimal, string_view) def resolve_isdigit(self, mod): - return types.BoundFunction( - StringViewIsDigit, string_view - ) + return types.BoundFunction(StringViewIsDigit, string_view) def resolve_isnumeric(self, mod): - return types.BoundFunction( - StringViewIsNumeric, string_view - ) + return types.BoundFunction(StringViewIsNumeric, string_view) def resolve_islower(self, mod): - return types.BoundFunction( - StringViewIsLower, string_view - ) + return types.BoundFunction(StringViewIsLower, string_view) def resolve_isupper(self, mod): - return types.BoundFunction( - StringViewIsUpper, string_view - ) + return types.BoundFunction(StringViewIsUpper, string_view) def resolve_isspace(self, mod): - return types.BoundFunction( - StringViewIsSpace, string_view - ) + return types.BoundFunction(StringViewIsSpace, string_view) def resolve_count(self, mod): - return types.BoundFunction( - StringViewCount, string_view - ) + return types.BoundFunction(StringViewCount, string_view) + _string_view_startswith = cuda.declare_device( "startswith", @@ -444,61 +410,54 @@ def resolve_count(self, mod): ) _string_view_endswith = cuda.declare_device( - "endswith", types.boolean(types.CPointer(string_view), types.CPointer(string_view)) + "endswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) _string_view_find = cuda.declare_device( "find", - types.int32(types.CPointer(string_view), types.CPointer(string_view)) + types.int32(types.CPointer(string_view), types.CPointer(string_view)), ) _string_view_rfind = cuda.declare_device( "rfind", - types.int32(types.CPointer(string_view), types.CPointer(string_view)) + types.int32(types.CPointer(string_view), types.CPointer(string_view)), ) _string_view_isdigit = cuda.declare_device( - "pyisdigit", - types.boolean(types.CPointer(string_view), types.int64) + "pyisdigit", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_isalnum = cuda.declare_device( - "pyisalnum", - types.boolean(types.CPointer(string_view), types.int64) + "pyisalnum", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_isalpha = cuda.declare_device( - "pyisalpha", - types.boolean(types.CPointer(string_view), types.int64) + "pyisalpha", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_isdecimal = cuda.declare_device( - "pyisdecimal", - types.boolean(types.CPointer(string_view), types.int64) + "pyisdecimal", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_isnumeric = cuda.declare_device( - "pyisnumeric", - types.boolean(types.CPointer(string_view), types.int64) + "pyisnumeric", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_isspace = cuda.declare_device( - "pyisspace", - types.boolean(types.CPointer(string_view), types.int64) + "pyisspace", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_isupper = cuda.declare_device( - "pyisupper", - types.boolean(types.CPointer(string_view), types.int64) + "pyisupper", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_islower = cuda.declare_device( - "pyislower", - types.boolean(types.CPointer(string_view), types.int64) + "pyislower", types.boolean(types.CPointer(string_view), types.int64) ) _string_view_count = cuda.declare_device( "pycount", - types.int32(types.CPointer(string_view), types.CPointer(string_view)) + types.int32(types.CPointer(string_view), types.CPointer(string_view)), ) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 3f82f48fb15..c3f0c35f5d7 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -1,43 +1,45 @@ # Copyright (c) 2022, NVIDIA CORPORATION. +import operator + from numba import types from numba.core import cgutils from numba.core.typing import signature as nb_signature from numba.cuda.cudadrv import nvvm -from numba.cuda.cudaimpl import lower as cuda_lower -from numba.cuda.cudaimpl import registry as cuda_lowering_registry +from numba.cuda.cudaimpl import ( + lower as cuda_lower, + registry as cuda_lowering_registry, +) + +from strings_udf._lib.tables import get_character_flags_table_ptr from strings_udf._typing import ( - StringView, - string_view, - _string_view_endswith, - _string_view_len, - _string_view_startswith, _string_view_contains, + _string_view_count, + _string_view_endswith, _string_view_eq, - _string_view_ne, + _string_view_find, _string_view_ge, - _string_view_le, _string_view_gt, - _string_view_lt, - _string_view_find, - _string_view_rfind, - _string_view_isdigit, _string_view_isalnum, _string_view_isalpha, - _string_view_isnumeric, _string_view_isdecimal, + _string_view_isdigit, + _string_view_islower, + _string_view_isnumeric, _string_view_isspace, _string_view_isupper, - _string_view_islower, - _string_view_count, + _string_view_le, + _string_view_len, + _string_view_lt, + _string_view_ne, + _string_view_rfind, + _string_view_startswith, + string_view, ) -import operator - -from strings_udf._lib.tables import get_character_flags_table_ptr - character_flags_table_ptr = get_character_flags_table_ptr() + # String function implementations def call_len_string_view(st): return _string_view_len(st) @@ -72,7 +74,9 @@ def string_view_contains_impl(context, builder, sig, args): builder, call_string_view_contains, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, substr_ptr), ) @@ -96,7 +100,9 @@ def string_view_eq_impl(context, builder, sig, args): builder, call_string_view_eq, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, rhs_ptr), ) @@ -120,7 +126,9 @@ def string_view_ne_impl(context, builder, sig, args): builder, call_string_view_ne, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, rhs_ptr), ) @@ -144,7 +152,9 @@ def string_view_ge_impl(context, builder, sig, args): builder, call_string_view_ge, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, rhs_ptr), ) @@ -168,7 +178,9 @@ def string_view_le_impl(context, builder, sig, args): builder, call_string_view_le, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, rhs_ptr), ) @@ -192,7 +204,9 @@ def string_view_gt_impl(context, builder, sig, args): builder, call_string_view_gt, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, rhs_ptr), ) @@ -216,7 +230,9 @@ def string_view_lt_impl(context, builder, sig, args): builder, call_string_view_lt, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, rhs_ptr), ) @@ -225,10 +241,10 @@ def string_view_lt_impl(context, builder, sig, args): # read-only functions -# We will provide only one overload for this set of functions, which will expect a -# string_view. When a literal is encountered, numba will promote it to a string_view -# whereas when a dstring is encountered, numba will convert it to a view via its native -# view() method +# We will provide only one overload for this set of functions, which will +# expect a string_view. When a literal is encountered, numba will promote it to +# a string_view whereas when a dstring is encountered, numba will convert it to +# a view via its native view() method. # casts @cuda_lowering_registry.lower_cast(types.StringLiteral, string_view) @@ -241,7 +257,9 @@ def cast_string_literal_to_string_view(context, builder, fromty, toty, val): # set the empty strview data pointer to point to the literal value s = context.insert_const_string(builder.module, fromty.literal_value) - sv.data = context.insert_addrspace_conv(builder, s, nvvm.ADDRSPACE_CONSTANT) + sv.data = context.insert_addrspace_conv( + builder, s, nvvm.ADDRSPACE_CONSTANT + ) sv.length = context.get_constant(types.int32, len(fromty.literal_value)) sv.bytes = context.get_constant( types.int32, len(fromty.literal_value.encode("UTF-8")) @@ -256,7 +274,9 @@ def call_string_view_startswith(sv, substr): @cuda_lower("StringView.startswith", string_view, string_view) def string_view_startswith_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( + args[1].type + ) builder.store(args[0], sv_ptr) builder.store(args[1], substr_ptr) @@ -265,7 +285,9 @@ def string_view_startswith_impl(context, builder, sig, args): builder, call_string_view_startswith, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, substr_ptr), ) @@ -279,7 +301,9 @@ def call_string_view_endswith(sv, substr): @cuda_lower("StringView.endswith", string_view, string_view) def string_view_endswith_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( + args[1].type + ) builder.store(args[0], sv_ptr) builder.store(args[1], substr_ptr) @@ -288,7 +312,9 @@ def string_view_endswith_impl(context, builder, sig, args): builder, call_string_view_endswith, nb_signature( - types.boolean, types.CPointer(string_view), types.CPointer(string_view) + types.boolean, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, substr_ptr), ) @@ -299,9 +325,12 @@ def string_view_endswith_impl(context, builder, sig, args): def call_string_view_count(st, substr): return _string_view_count(st, substr) + @cuda_lower("StringView.count", string_view, string_view) def string_view_coount_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( + args[1].type + ) builder.store(args[0], sv_ptr) builder.store(args[1], substr_ptr) @@ -310,7 +339,9 @@ def string_view_coount_impl(context, builder, sig, args): builder, call_string_view_count, nb_signature( - types.int32, types.CPointer(string_view), types.CPointer(string_view) + types.int32, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, substr_ptr), ) @@ -321,9 +352,12 @@ def string_view_coount_impl(context, builder, sig, args): def call_string_view_find(sv, substr): return _string_view_find(sv, substr) + @cuda_lower("StringView.find", string_view, string_view) def string_view_find_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( + args[1].type + ) builder.store(args[0], sv_ptr) builder.store(args[1], substr_ptr) @@ -332,19 +366,25 @@ def string_view_find_impl(context, builder, sig, args): builder, call_string_view_find, nb_signature( - types.int32, types.CPointer(string_view), types.CPointer(string_view) + types.int32, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, substr_ptr), ) return result + def call_string_view_rfind(sv, substr): return _string_view_rfind(sv, substr) + @cuda_lower("StringView.rfind", string_view, string_view) def string_view_rfind_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca(args[1].type) + sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( + args[1].type + ) builder.store(args[0], sv_ptr) builder.store(args[1], substr_ptr) @@ -353,13 +393,16 @@ def string_view_rfind_impl(context, builder, sig, args): builder, call_string_view_rfind, nb_signature( - types.int32, types.CPointer(string_view), types.CPointer(string_view) + types.int32, + types.CPointer(string_view), + types.CPointer(string_view), ), (sv_ptr, substr_ptr), ) return result + def call_string_view_isdigit(st, tbl): return _string_view_isdigit(st, tbl) @@ -373,14 +416,13 @@ def string_view_isdigit_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isdigit, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) return result + def call_string_view_isalnum(st, tbl): return _string_view_isalnum(st, tbl) @@ -394,14 +436,13 @@ def string_view_isalnum_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isalnum, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) return result + def call_string_view_isalpha(st, tbl): return _string_view_isalpha(st, tbl) @@ -415,14 +456,13 @@ def string_view_isalpha_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isalpha, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) return result + def call_string_view_isnumeric(st, tbl): return _string_view_isnumeric(st, tbl) @@ -436,14 +476,13 @@ def string_view_isnumeric_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isnumeric, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) return result + def call_string_view_isdecimal(st, tbl): return _string_view_isdecimal(st, tbl) @@ -457,14 +496,13 @@ def string_view_isdecimal_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isdecimal, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) return result + def call_string_view_isspace(st, tbl): return _string_view_isspace(st, tbl) @@ -478,14 +516,13 @@ def string_view_isspace_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isspace, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) return result + def call_string_view_isupper(st, tbl): return _string_view_isupper(st, tbl) @@ -499,9 +536,7 @@ def string_view_isupper_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_isupper, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) @@ -521,26 +556,7 @@ def string_view_islower_impl(context, builder, sig, args): result = context.compile_internal( builder, call_string_view_islower, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), - (sv_ptr, tbl_ptr), - ) - - return result - -@cuda_lower("StringView.isnumeric", string_view) -def string_view_isnumeric_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isnumeric, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, types.CPointer(string_view), types.int64), (sv_ptr, tbl_ptr), ) diff --git a/python/strings_udf/strings_udf/tests/test_cmpops.py b/python/strings_udf/strings_udf/tests/test_cmpops.py index 95e4a9cc66a..b82adb5fbe8 100644 --- a/python/strings_udf/strings_udf/tests/test_cmpops.py +++ b/python/strings_udf/strings_udf/tests/test_cmpops.py @@ -1,11 +1,13 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest -import strings_udf.lowering + +from .utils import run_udf_test -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_eq(data, rhs): # tests the `==` operator in string udfs @@ -16,7 +18,9 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ne(data, rhs): # tests the `!=` operator in string udfs @@ -27,7 +31,9 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ge(data, rhs): # tests the `>=` operator in string udfs @@ -38,7 +44,9 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_le(data, rhs): # tests the `<=` operator in string udfs @@ -49,7 +57,9 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_gt(data, rhs): # tests the `>` operator in string udfs @@ -60,7 +70,9 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_lt(data, rhs): # tests the `<` operator in string udfs diff --git a/python/strings_udf/strings_udf/tests/test_contains.py b/python/strings_udf/strings_udf/tests/test_contains.py index ca397209c88..562a4d2535f 100644 --- a/python/strings_udf/strings_udf/tests/test_contains.py +++ b/python/strings_udf/strings_udf/tests/test_contains.py @@ -1,10 +1,13 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]]) +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) @pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) def test_string_udf_contains(data, substr): # Tests contains for string UDFs diff --git a/python/strings_udf/strings_udf/tests/test_count.py b/python/strings_udf/strings_udf/tests/test_count.py index 0b9b284d9cd..faa70b43450 100644 --- a/python/strings_udf/strings_udf/tests/test_count.py +++ b/python/strings_udf/strings_udf/tests/test_count.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize( - "data", [ - ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] - ] + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] ) -@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc", ""]) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(data, substr): # tests the `count` function in string udfs def func(st): return st.count(substr) - run_udf_test(data, func, 'int32') + run_udf_test(data, func, "int32") diff --git a/python/strings_udf/strings_udf/tests/test_endswith.py b/python/strings_udf/strings_udf/tests/test_endswith.py index 0601429b1bf..5a09077d5f7 100644 --- a/python/strings_udf/strings_udf/tests/test_endswith.py +++ b/python/strings_udf/strings_udf/tests/test_endswith.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize( - "data", [ - ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] - ] + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] ) -@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc"]) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_endswith(data, substr): # tests the `endswith` function in string udfs def func(st): return st.endswith(substr) - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_find.py b/python/strings_udf/strings_udf/tests/test_find.py index 6744def0993..59c03a74f28 100644 --- a/python/strings_udf/strings_udf/tests/test_find.py +++ b/python/strings_udf/strings_udf/tests/test_find.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize( - "data", [ - ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] - ] + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] ) -@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc", "", "gpu"]) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_find(data, substr): # tests the `find` function in string udfs def func(st): return st.find(substr) - run_udf_test(data, func, 'int32') + run_udf_test(data, func, "int32") diff --git a/python/strings_udf/strings_udf/tests/test_isalnum.py b/python/strings_udf/strings_udf/tests/test_isalnum.py index a722def6313..38059eeb1f4 100644 --- a/python/strings_udf/strings_udf/tests/test_isalnum.py +++ b/python/strings_udf/strings_udf/tests/test_isalnum.py @@ -1,8 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize("data", [["1", "1@2", "123abc", "2.1", "", "0003"]]) def test_string_udf_isalnum(data): # tests the `rfind` function in string udfs @@ -10,4 +12,4 @@ def test_string_udf_isalnum(data): def func(st): return st.isalnum() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isalpha.py b/python/strings_udf/strings_udf/tests/test_isalpha.py index 5faf918afff..222beb1cf4c 100644 --- a/python/strings_udf/strings_udf/tests/test_isalpha.py +++ b/python/strings_udf/strings_udf/tests/test_isalpha.py @@ -1,13 +1,17 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest -@pytest.mark.parametrize("data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]]) +from .utils import run_udf_test + + +@pytest.mark.parametrize( + "data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]] +) def test_string_udf_isalpha(data): # tests the `isalpha` function in string udfs def func(st): return st.isalpha() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isdecimal.py b/python/strings_udf/strings_udf/tests/test_isdecimal.py index 53adb3601d7..a1f6ad55376 100644 --- a/python/strings_udf/strings_udf/tests/test_isdecimal.py +++ b/python/strings_udf/strings_udf/tests/test_isdecimal.py @@ -1,8 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) def test_string_udf_isdecimal(data): # tests the `isdecimal` function in string udfs @@ -10,4 +12,4 @@ def test_string_udf_isdecimal(data): def func(st): return st.isdecimal() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isdigit.py b/python/strings_udf/strings_udf/tests/test_isdigit.py index 0a13ba365ff..5c32b9570de 100644 --- a/python/strings_udf/strings_udf/tests/test_isdigit.py +++ b/python/strings_udf/strings_udf/tests/test_isdigit.py @@ -1,8 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) def test_string_udf_isdigit(data): # tests the `isdigit` function in string udfs @@ -10,4 +12,4 @@ def test_string_udf_isdigit(data): def func(st): return st.isdigit() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_islower.py b/python/strings_udf/strings_udf/tests/test_islower.py index e37771a8adf..993cd73e51f 100644 --- a/python/strings_udf/strings_udf/tests/test_islower.py +++ b/python/strings_udf/strings_udf/tests/test_islower.py @@ -1,13 +1,17 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003", 'abc', 'b a', 'AbC']]) +from .utils import run_udf_test + + +@pytest.mark.parametrize( + "data", [["1", "12", "123abc", "2.1", "", "0003", "abc", "b a", "AbC"]] +) def test_string_udf_islower(data): # tests the `islower` function in string udfs def func(st): return st.islower() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isnumeric.py b/python/strings_udf/strings_udf/tests/test_isnumeric.py index 8480740f1c3..b4df15180a9 100644 --- a/python/strings_udf/strings_udf/tests/test_isnumeric.py +++ b/python/strings_udf/strings_udf/tests/test_isnumeric.py @@ -1,8 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) def test_string_udf_isnumeric(data): # tests the `isnumeric` function in string udfs @@ -10,4 +12,4 @@ def test_string_udf_isnumeric(data): def func(st): return st.isnumeric() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isspace.py b/python/strings_udf/strings_udf/tests/test_isspace.py index db5571c6f8a..3d9a52b081b 100644 --- a/python/strings_udf/strings_udf/tests/test_isspace.py +++ b/python/strings_udf/strings_udf/tests/test_isspace.py @@ -1,8 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize("data", [["1", " x ", " ", "2.1", "", "0003"]]) def test_string_udf_isspace(data): # tests the `isspace` function in string udfs @@ -10,4 +12,4 @@ def test_string_udf_isspace(data): def func(st): return st.isspace() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isupper.py b/python/strings_udf/strings_udf/tests/test_isupper.py index ad4940a6bf1..bdc2283521b 100644 --- a/python/strings_udf/strings_udf/tests/test_isupper.py +++ b/python/strings_udf/strings_udf/tests/test_isupper.py @@ -1,13 +1,17 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]]) +from .utils import run_udf_test + + +@pytest.mark.parametrize( + "data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]] +) def test_string_udf_isupper(data): # tests the `isupper` function in string udfs def func(st): return st.isupper() - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_rfind.py b/python/strings_udf/strings_udf/tests/test_rfind.py index 72e529f274c..8aeb59edd9e 100644 --- a/python/strings_udf/strings_udf/tests/test_rfind.py +++ b/python/strings_udf/strings_udf/tests/test_rfind.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize( - "data", [ - ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] - ] + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] ) -@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc", "", "gpu"]) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_rfind(data, substr): # tests the `rfind` function in string udfs def func(st): return st.rfind(substr) - run_udf_test(data, func, 'int32') + run_udf_test(data, func, "int32") diff --git a/python/strings_udf/strings_udf/tests/test_startswith.py b/python/strings_udf/strings_udf/tests/test_startswith.py index 1822bd78239..6193f81bab8 100644 --- a/python/strings_udf/strings_udf/tests/test_startswith.py +++ b/python/strings_udf/strings_udf/tests/test_startswith.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from .utils import run_udf_test import pytest +from .utils import run_udf_test + + @pytest.mark.parametrize( - "data", [ - ["cudf", "rapids", "AI", "gpu", "2022", "cuda"] - ] + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] ) -@pytest.mark.parametrize('substr', ['c', 'cu', "2", "abc"]) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_startswith(data, substr): # tests the `startswith` function in string udfs def func(st): return st.startswith(substr) - run_udf_test(data, func, 'bool') + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index cecfe10bb1c..657287d6d8b 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -1,13 +1,14 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -import cudf import numba import numpy as np import pandas as pd -from cudf.testing._utils import assert_eq from numba import cuda from numba.core.typing import signature as nb_signature from numba.types import CPointer, void + +import cudf +from cudf.testing._utils import assert_eq from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view From 2442bf2f7b353bb99849a3bfcf3cf7b0498d8e49 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 27 Jul 2022 09:31:30 -0700 Subject: [PATCH 045/212] configure strings_udf to be optional based on a runtime check --- python/cudf/cudf/core/udf/__init__.py | 46 +++++++- python/cudf/cudf/core/udf/masked_lowering.py | 4 - python/cudf/cudf/core/udf/masked_typing.py | 114 ++++++++++--------- python/cudf/cudf/core/udf/strings_typing.py | 4 + 4 files changed, 111 insertions(+), 57 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 0977238935d..34059c1e9e4 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -1,2 +1,46 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from . import masked_typing, masked_lowering, strings_typing, strings_lowering +from . import masked_typing, masked_lowering +from numba import cuda +from numba import types +from numba.cuda.cudaimpl import ( + lower as cuda_lower, + registry as cuda_lowering_registry, +) +from cudf.core.udf import api + +driver_maj, driver_min = cuda.cudadrv.driver.get_version() +runtime_maj, runtime_min = cuda.cudadrv.runtime.runtime.get_version() + +units = ["ns", "ms", "us", "s"] +datetime_cases = {types.NPDatetime(u) for u in units} +timedelta_cases = {types.NPTimedelta(u) for u in units} + + +supported_masked_types = ( + types.integer_domain + | types.real_domain + | datetime_cases + | timedelta_cases + | {types.boolean} +) + +_STRING_UDFS_ENABLED = False +if driver_maj >= runtime_maj and driver_min >= runtime_min: + from . import strings_typing + from . import strings_lowering + + # add an overload of MaskedType.__init__(string_view, bool) + cuda_lower(api.Masked, strings_typing.string_view, types.boolean)( + masked_lowering.masked_constructor + ) + + # add an overload of pack_return(string_view) + cuda_lower(api.pack_return, strings_typing.string_view)( + masked_lowering.pack_return_scalar_impl + ) + + supported_masked_types |= {strings_typing.string_view} + _STRING_UDFS_ENABLED = True + + +masked_typing.register_masked_constructor(supported_masked_types) diff --git a/python/cudf/cudf/core/udf/masked_lowering.py b/python/cudf/cudf/core/udf/masked_lowering.py index e1ef5f8e61d..16c9b9ec655 100644 --- a/python/cudf/cudf/core/udf/masked_lowering.py +++ b/python/cudf/cudf/core/udf/masked_lowering.py @@ -11,8 +11,6 @@ ) from numba.extending import lower_builtin, types -from strings_udf._typing import string_view - from cudf.core.udf import api from cudf.core.udf._ops import ( arith_ops, @@ -281,7 +279,6 @@ def pack_return_masked_impl(context, builder, sig, args): @cuda_lower(api.pack_return, types.Number) @cuda_lower(api.pack_return, types.NPDatetime) @cuda_lower(api.pack_return, types.NPTimedelta) -@cuda_lower(api.pack_return, string_view) def pack_return_scalar_impl(context, builder, sig, args): outdata = cgutils.create_struct_proxy(sig.return_type)(context, builder) outdata.value = args[0] @@ -353,7 +350,6 @@ def cast_masked_to_masked(context, builder, fromty, toty, val): @lower_builtin(api.Masked, types.Number, types.boolean) @lower_builtin(api.Masked, types.NPDatetime, types.boolean) @lower_builtin(api.Masked, types.NPTimedelta, types.boolean) -@lower_builtin(api.Masked, string_view, types.boolean) def masked_constructor(context, builder, sig, args): ty = sig.return_type value, valid = args diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 18bf5e3cd50..229683592ce 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -1,6 +1,7 @@ # Copyright (c) 2020-2022, NVIDIA CORPORATION. import operator +from typing import Any, Dict from numba import types from numba.core.extending import ( @@ -18,8 +19,6 @@ from numba.core.typing.typeof import typeof from numba.cuda.cudadecl import registry as cuda_decl_registry -from strings_udf._typing import StringView, string_view - from cudf.core.missing import NA from cudf.core.udf import api from cudf.core.udf._ops import ( @@ -28,15 +27,47 @@ comparison_ops, unary_ops, ) +from cudf.utils.dtypes import ( + DATETIME_TYPES, + NUMERIC_TYPES, + STRING_TYPES, + TIMEDELTA_TYPES, +) SUPPORTED_NUMBA_TYPES = ( types.Number, types.Boolean, types.NPDatetime, types.NPTimedelta, - types.PyObject, ) +SUPPORTED_NUMPY_TYPES = ( + NUMERIC_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES +) +supported_type_str = "\n".join(sorted(list(SUPPORTED_NUMPY_TYPES) + ["bool"])) + +MASKED_INIT_MAP: Dict[Any, Any] = {} + + +def _type_to_masked_type(t): + result = MASKED_INIT_MAP.get(t) + if result is None: + if isinstance(t, SUPPORTED_NUMBA_TYPES): + return t + else: + breakpoint() + return types.Poison( + # Unsupported Dtype. Numba tends to print out the type info + # for whatever operands and operation failed to type and then + # output its own error message. Putting the message in the repr + # then is one way of getting the true cause to the user + "\nUnsupported MaskedType. This is usually caused by " + "attempting to use a column of unsupported dtype in a UDF. " + f"Supported dtypes are:\n{supported_type_str}" + ) + else: + return result + # Masked scalars of all types class MaskedType(types.Type): @@ -48,23 +79,7 @@ class MaskedType(types.Type): def __init__(self, value): # MaskedType in Numba shall be parameterized # with a value type - - # TODO - replace object with stringview immediately - if isinstance(value, (types.PyObject, StringView)): - self.value_type = string_view - - elif isinstance(value, SUPPORTED_NUMBA_TYPES): - self.value_type = value - else: - # Unsupported Dtype. Numba tends to print out the type info - # for whatever operands and operation failed to type and then - # output its own error message. Putting the message in the repr - # then is one way of getting the true cause to the user - self.value_type = types.Poison( - "\n\n\n Unsupported MaskedType. This is usually caused by " - "attempting to use a column of unsupported dtype in a UDF. " - f"Supported dtypes are {SUPPORTED_NUMBA_TYPES}\n\n\n" - ) + self.value_type = _type_to_masked_type(value) super().__init__(name=f"Masked({self.value_type})") def __hash__(self): @@ -140,45 +155,40 @@ def typeof_masked(val, c): # Implemented typing for Masked(value, valid) - the construction of a Masked # type in a kernel. -@cuda_decl_registry.register -class MaskedConstructor(ConcreteTemplate): - key = api.Masked - units = ["ns", "ms", "us", "s"] - datetime_cases = {types.NPDatetime(u) for u in units} - timedelta_cases = {types.NPTimedelta(u) for u in units} - cases = [ - nb_signature(MaskedType(t), t, types.boolean) - for t in ( - types.integer_domain - | types.real_domain - | datetime_cases - | timedelta_cases - | {types.boolean} - | {string_view} - ) - ] +def register_masked_constructor(supported_masked_types): + class MaskedConstructor(ConcreteTemplate): + from cudf.core.udf.strings_typing import string_view + key = api.Masked + units = ["ns", "ms", "us", "s"] + datetime_cases = {types.NPDatetime(u) for u in units} + timedelta_cases = {types.NPTimedelta(u) for u in units} + cases = [ + nb_signature(MaskedType(t), t, types.boolean) + for t in supported_masked_types + ] -# Provide access to `m.value` and `m.valid` in a kernel for a Masked `m`. -make_attribute_wrapper(MaskedType, "value", "value") -make_attribute_wrapper(MaskedType, "valid", "valid") + cuda_decl_registry.register(MaskedConstructor) + # Typing for `api.Masked` + @cuda_decl_registry.register_attr + class ClassesTemplate(AttributeTemplate): + key = types.Module(api) -# Typing for `api.Masked` -@cuda_decl_registry.register_attr -class ClassesTemplate(AttributeTemplate): - key = types.Module(api) + def resolve_Masked(self, mod): + return types.Function(MaskedConstructor) - def resolve_Masked(self, mod): - return types.Function(MaskedConstructor) + # Registration of the global is also needed for Numba to type api.Masked + cuda_decl_registry.register_global(api, types.Module(api)) + # For typing bare Masked (as in `from .api import Masked` + cuda_decl_registry.register_global( + api.Masked, types.Function(MaskedConstructor) + ) -# Registration of the global is also needed for Numba to type api.Masked -cuda_decl_registry.register_global(api, types.Module(api)) -# For typing bare Masked (as in `from .api import Masked` -cuda_decl_registry.register_global( - api.Masked, types.Function(MaskedConstructor) -) +# Provide access to `m.value` and `m.valid` in a kernel for a Masked `m`. +make_attribute_wrapper(MaskedType, "value", "value") +make_attribute_wrapper(MaskedType, "valid", "valid") # Tell numba how `MaskedType` is constructed on the backend in terms diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 69236259641..91e38cb99ad 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -10,9 +10,13 @@ from strings_udf._typing import StringView, string_view +from cudf.core.udf import masked_typing from cudf.core.udf._ops import comparison_ops from cudf.core.udf.masked_typing import MaskedType +masked_typing.MASKED_INIT_MAP[types.pyobject] = string_view +masked_typing.MASKED_INIT_MAP[string_view] = string_view + # String functions @cuda_decl_registry.register_global(len) From 0b35e16f57b54479e0234a9eff8d88821062779c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 27 Jul 2022 09:32:41 -0700 Subject: [PATCH 046/212] remove stake breakpoint --- python/cudf/cudf/core/udf/masked_typing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 229683592ce..8414a5782b2 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -55,7 +55,6 @@ def _type_to_masked_type(t): if isinstance(t, SUPPORTED_NUMBA_TYPES): return t else: - breakpoint() return types.Poison( # Unsupported Dtype. Numba tends to print out the type info # for whatever operands and operation failed to type and then From 2a010f4cc40c4313816e737fb992019a374f5176 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 1 Aug 2022 09:42:21 -0700 Subject: [PATCH 047/212] skip string tests if not enabled --- python/cudf/cudf/tests/test_udf_masked_ops.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 2650c989ecd..6d4fbaf10ac 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -8,6 +8,7 @@ import cudf from cudf.core.missing import NA +from cudf.core.udf import _STRING_UDFS_ENABLED from cudf.core.udf._ops import ( arith_ops, bitwise_ops, @@ -22,6 +23,14 @@ ) +# only run string udf tests if library exists and is enabled +def string_udf_test(f): + if _STRING_UDFS_ENABLED: + return f + else: + return pytest.mark.skip(reason="String UDFs not enabled")(f) + + def run_masked_udf_test(func, data, args=(), **kwargs): gdf = data pdf = data.to_pandas(nullable=True) @@ -674,6 +683,7 @@ def f(x): assert precompiled.currsize == 1 +@string_udf_test @pytest.mark.parametrize( "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022"]}] ) @@ -688,6 +698,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022", "cuDF"]}] ) @@ -703,6 +714,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -731,6 +743,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -759,6 +772,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -787,6 +801,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -815,6 +830,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -843,6 +859,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -869,6 +886,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -895,6 +913,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -921,6 +940,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -950,6 +970,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -978,6 +999,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ @@ -1006,6 +1028,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@string_udf_test @pytest.mark.parametrize( "data", [ From 8bd77735e86c6aa2ceea8a40b02f6efee6eff259 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 1 Aug 2022 12:41:20 -0700 Subject: [PATCH 048/212] add a build script --- python/strings_udf/build.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 python/strings_udf/build.sh diff --git a/python/strings_udf/build.sh b/python/strings_udf/build.sh new file mode 100644 index 00000000000..9069baf6fa4 --- /dev/null +++ b/python/strings_udf/build.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Copyright (c) 2022, NVIDIA CORPORATION. + +REPODIR=`git rev-parse --show-toplevel` + +BUILD_DIR=${REPODIR}/python/strings_udf/cpp/build + +mkdir ${BUILD_DIR} +cd ${BUILD_DIR} + +cmake .. -DCONDA_PREFIX=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX}/ +make +make install + +cd $REPODIR/python/strings_udf/ +python setup.py install From 92229b7af03e283ce1089055fd18ebe13d74087f Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 1 Aug 2022 12:43:04 -0700 Subject: [PATCH 049/212] add build script to main build script --- build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index eee3ee512fa..1619ac089e6 100755 --- a/build.sh +++ b/build.sh @@ -17,7 +17,7 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libcudf cudf cudfjar dask_cudf benchmarks tests libcudf_kafka cudf_kafka custreamz -v -g -n -l --allgpuarch --disable_nvtx --opensource_nvcomp --show_depr_warn --ptds -h --build_metrics --incl_cache_stats" +VALIDARGS="clean libcudf cudf cudfjar dask_cudf benchmarks tests libcudf_kafka cudf_kafka custreamz strings_udf -v -g -n -l --allgpuarch --disable_nvtx --opensource_nvcomp --show_depr_warn --ptds -h --build_metrics --incl_cache_stats" HELP="$0 [clean] [libcudf] [cudf] [cudfjar] [dask_cudf] [benchmarks] [tests] [libcudf_kafka] [cudf_kafka] [custreamz] [-v] [-g] [-n] [-h] [--cmake-args=\\\"\\\"] clean - remove all existing build artifacts and configuration (start over) @@ -389,3 +389,8 @@ if hasArg custreamz; then PARALLEL_LEVEL=${PARALLEL_LEVEL} python setup.py build_ext --inplace -j${PARALLEL_LEVEL} --library-dir=${LIBCUDF_BUILD_DIR} fi fi + +if hasArg strings_udf; then + cd ${REPODIR}/python/strings_udf + bash build.sh +fi From 1d868b4592337a60517e74d6fbb96b2d373b1800 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 2 Aug 2022 09:24:42 -0700 Subject: [PATCH 050/212] pass style checks, move functions to lowering --- .gitignore | 1 + .pre-commit-config.yaml | 2 +- python/strings_udf/cpp/CMakeLists.txt | 74 +++------- .../cpp/cmake/thirdparty/get_jitify.cmake | 1 - .../strings_udf/_lib/cpp/strings_udf.pxd | 1 - .../strings_udf/_lib/cudf_jit_udf.pyx | 15 +- .../strings_udf/strings_udf/_lib/tables.pyx | 7 +- python/strings_udf/strings_udf/_typing.py | 108 +-------------- python/strings_udf/strings_udf/lowering.py | 129 ++++++++++++++---- python/strings_udf/strings_udf/tests/utils.py | 6 +- 10 files changed, 139 insertions(+), 205 deletions(-) diff --git a/.gitignore b/.gitignore index df266677373..c8f02da027d 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ python/cudf_kafka/*/_lib/**/*\.cpp python/cudf_kafka/*/_lib/**/*.h python/custreamz/*/_lib/**/*\.cpp python/custreamz/*/_lib/**/*.h +python/strings_udf/strings_udf/_lib/*.cpp .Python env/ develop-eggs/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4051ff822be..154c911eb04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: isort # Use the config file specific to each subproject so that each # project can specify its own first/third-party packages. - args: ["--config-root=python/", "--resolve-all-configs"] + args: ["--config-root=python/", "--resolve-all-configs", "--profile", "black", "--filter-files"] files: python/.* exclude: (__init__.py|setup.py)$ types_or: [python, cython, pyi] diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index afb9c383b0e..51098ea1543 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -30,8 +30,8 @@ include(cmake/thirdparty/get_jitify.cmake) # set the project name and version project( - cudf_strings_udf - VERSION 0.1 + cudf_strings_udf + VERSION 0.1 DESCRIPTION "cudf strings-udf library" LANGUAGES C CXX CUDA ) @@ -40,7 +40,7 @@ if(NOT CONDA_PREFIX) message(FATAL_ERROR " CONDA_PREFIX must be set") endif() -message(STATUS "CONDA_PREFIX=${CONDA_PREFIX}" ) +message(STATUS "CONDA_PREFIX=${CONDA_PREFIX}") find_package(CUDAToolkit REQUIRED) @@ -58,15 +58,9 @@ set(SHIM_CUDA_FLAGS "") list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true -keep) -add_library( - cudf_strings_udf SHARED - src/strings/udf/udf_apis.cu -) +add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) -add_library( - shim OBJECT - src/strings/udf/shim.cu -) +add_library(shim OBJECT src/strings/udf/shim.cu) set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) @@ -82,64 +76,40 @@ target_include_directories( PUBLIC ${CONDA_PREFIX}/include ) - set_target_properties( - cudf_strings_udf - PROPERTIES - BUILD_RPATH "\$ORIGIN" - INSTALL_RPATH "\$ORIGIN" - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON - POSITION_INDEPENDENT_CODE ON - INTERFACE_POSITION_INDEPENDENT_CODE ON + cudf_strings_udf + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON ) target_compile_options( - cudf_strings_udf PRIVATE - "$<$:${UDF_CXX_FLAGS}>" - "$<$:${UDF_CUDA_FLAGS}>" + cudf_strings_udf PRIVATE "$<$:${UDF_CXX_FLAGS}>" + "$<$:${UDF_CUDA_FLAGS}>" ) -target_compile_options( - shim PRIVATE - "$<$:${SHIM_CUDA_FLAGS}>" -) +target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") target_include_directories( cudf_strings_udf PRIVATE include PUBLIC ${UDF_INCLUDES} ) -target_link_libraries( - cudf_strings_udf - PUBLIC ${UDF_LIBS} -) +target_link_libraries(cudf_strings_udf PUBLIC ${UDF_LIBS}) -add_executable( - udf_cli - src/strings/udf/udf_cli.cpp -) +add_executable(udf_cli src/strings/udf/udf_cli.cpp) target_include_directories( udf_cli PRIVATE include - PUBLIC ${UDF_INCLUDES} - CUDA::cudart + PUBLIC ${UDF_INCLUDES} CUDA::cudart ) -target_link_libraries( - udf_cli - PUBLIC cudf_strings_udf - PUBLIC ${UDF_LIBS} - CUDA::cudart -) -set_target_properties( - udf_cli - PROPERTIES - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON -) - +target_link_libraries(udf_cli PUBLIC cudf_strings_udf ${UDF_LIBS} CUDA::cudart) +set_target_properties(udf_cli PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) install(TARGETS cudf_strings_udf) install(TARGETS udf_cli) diff --git a/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake b/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake index ad334caee3b..08ff9124293 100644 --- a/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake +++ b/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake @@ -1,4 +1,3 @@ - # ============================================================================= # Copyright (c) 2022, NVIDIA CORPORATION. # diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index 35ed54bd4c3..f6f9a02f3e8 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -4,7 +4,6 @@ from libc.stdint cimport uint8_t from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector - from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from cudf._lib.cpp.column.column cimport column diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index cb0a8424a13..6f7f17129ab 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -13,18 +13,19 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer +from strings_udf._lib.cpp.strings_udf cimport call_udf as cpp_call_udf +from strings_udf._lib.cpp.\ + strings_udf cimport create_udf_module as cpp_create_udf_module +from strings_udf._lib.cpp.\ + strings_udf cimport from_dstring_array as cpp_from_dstring_array +from strings_udf._lib.cpp.\ + strings_udf cimport to_string_view_array as cpp_to_string_view_array +from strings_udf._lib.cpp.strings_udf cimport udf_module as cpp_udf_module from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type -from strings_udf._lib.cpp.strings_udf cimport ( - call_udf as cpp_call_udf, - create_udf_module as cpp_create_udf_module, - from_dstring_array as cpp_from_dstring_array, - to_string_view_array as cpp_to_string_view_array, - udf_module as cpp_udf_module, -) import numpy as np diff --git a/python/strings_udf/strings_udf/_lib/tables.pyx b/python/strings_udf/strings_udf/_lib/tables.pyx index b24aa19155d..536583be4d8 100644 --- a/python/strings_udf/strings_udf/_lib/tables.pyx +++ b/python/strings_udf/strings_udf/_lib/tables.pyx @@ -4,10 +4,9 @@ # cython: c_string_type=unicode, c_string_encoding=utf8 from libc.stdint cimport uint8_t, uintptr_t - -from strings_udf._lib.cpp.strings_udf cimport ( - get_character_flags_table as cpp_get_character_flags_table, -) +from strings_udf._lib.cpp.\ + strings_udf cimport get_character_flags_table as \ + cpp_get_character_flags_table import numpy as np diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index f4ab69cf880..c067a15a5f6 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -3,7 +3,7 @@ import operator import llvmlite.binding as ll -from numba import cuda, types +from numba import types from numba.core.datamodel import default_manager from numba.core.extending import models, register_model from numba.core.typing import signature as nb_signature @@ -119,11 +119,6 @@ def generic(self, args, kws): return nb_signature(types.int32, args[0]) -_string_view_len = cuda.declare_device( - "len", types.int32(types.CPointer(string_view)) -) - - @cuda_decl_registry.register_global(operator.contains) class StringViewContains(AbstractTemplate): """ @@ -137,12 +132,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_contains = cuda.declare_device( - "contains", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - @cuda_decl_registry.register_global(operator.eq) class StringViewEq(AbstractTemplate): """ @@ -158,12 +147,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_eq = cuda.declare_device( - "eq", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - @cuda_decl_registry.register_global(operator.ne) class StringViewNe(AbstractTemplate): """ @@ -179,12 +162,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_ne = cuda.declare_device( - "ne", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - @cuda_decl_registry.register_global(operator.ge) class StringViewGe(AbstractTemplate): """ @@ -200,12 +177,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_ge = cuda.declare_device( - "ge", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - @cuda_decl_registry.register_global(operator.le) class StringViewLe(AbstractTemplate): """ @@ -221,12 +192,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_le = cuda.declare_device( - "le", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - @cuda_decl_registry.register_global(operator.gt) class StringViewGt(AbstractTemplate): """ @@ -242,12 +207,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_gt = cuda.declare_device( - "gt", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - @cuda_decl_registry.register_global(operator.lt) class StringViewLt(AbstractTemplate): """ @@ -263,12 +222,6 @@ def generic(self, args, kws): return nb_signature(types.boolean, string_view, string_view) -_string_view_lt = cuda.declare_device( - "lt", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - - class StringViewStartsWith(AbstractTemplate): key = "StringView.startswith" @@ -402,62 +355,3 @@ def resolve_isspace(self, mod): def resolve_count(self, mod): return types.BoundFunction(StringViewCount, string_view) - - -_string_view_startswith = cuda.declare_device( - "startswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - -_string_view_endswith = cuda.declare_device( - "endswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), -) - -_string_view_find = cuda.declare_device( - "find", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), -) - -_string_view_rfind = cuda.declare_device( - "rfind", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), -) - -_string_view_isdigit = cuda.declare_device( - "pyisdigit", types.boolean(types.CPointer(string_view), types.int64) -) - - -_string_view_isalnum = cuda.declare_device( - "pyisalnum", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_isalpha = cuda.declare_device( - "pyisalpha", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_isdecimal = cuda.declare_device( - "pyisdecimal", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_isnumeric = cuda.declare_device( - "pyisnumeric", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_isspace = cuda.declare_device( - "pyisspace", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_isupper = cuda.declare_device( - "pyisupper", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_islower = cuda.declare_device( - "pyislower", types.boolean(types.CPointer(string_view), types.int64) -) - -_string_view_count = cuda.declare_device( - "pycount", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), -) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index c3f0c35f5d7..d315fd8a666 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -2,42 +2,113 @@ import operator -from numba import types +from numba import cuda, types from numba.core import cgutils from numba.core.typing import signature as nb_signature from numba.cuda.cudadrv import nvvm -from numba.cuda.cudaimpl import ( - lower as cuda_lower, - registry as cuda_lowering_registry, +from numba.cuda.cudaimpl import lower as cuda_lower +from numba.cuda.cudaimpl import registry as cuda_lowering_registry +from strings_udf._lib.tables import get_character_flags_table_ptr +from strings_udf._typing import string_view + +character_flags_table_ptr = get_character_flags_table_ptr() + + +_string_view_len = cuda.declare_device( + "len", types.int32(types.CPointer(string_view)) ) -from strings_udf._lib.tables import get_character_flags_table_ptr -from strings_udf._typing import ( - _string_view_contains, - _string_view_count, - _string_view_endswith, - _string_view_eq, - _string_view_find, - _string_view_ge, - _string_view_gt, - _string_view_isalnum, - _string_view_isalpha, - _string_view_isdecimal, - _string_view_isdigit, - _string_view_islower, - _string_view_isnumeric, - _string_view_isspace, - _string_view_isupper, - _string_view_le, - _string_view_len, - _string_view_lt, - _string_view_ne, - _string_view_rfind, - _string_view_startswith, - string_view, +_string_view_contains = cuda.declare_device( + "contains", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) -character_flags_table_ptr = get_character_flags_table_ptr() + +_string_view_eq = cuda.declare_device( + "eq", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) +_string_view_ne = cuda.declare_device( + "ne", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_ge = cuda.declare_device( + "ge", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_le = cuda.declare_device( + "le", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) +_string_view_gt = cuda.declare_device( + "gt", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_lt = cuda.declare_device( + "lt", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_startswith = cuda.declare_device( + "startswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_endswith = cuda.declare_device( + "endswith", + types.boolean(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_find = cuda.declare_device( + "find", + types.int32(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_rfind = cuda.declare_device( + "rfind", + types.int32(types.CPointer(string_view), types.CPointer(string_view)), +) + +_string_view_isdigit = cuda.declare_device( + "pyisdigit", types.boolean(types.CPointer(string_view), types.int64) +) + + +_string_view_isalnum = cuda.declare_device( + "pyisalnum", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_isalpha = cuda.declare_device( + "pyisalpha", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_isdecimal = cuda.declare_device( + "pyisdecimal", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_isnumeric = cuda.declare_device( + "pyisnumeric", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_isspace = cuda.declare_device( + "pyisspace", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_isupper = cuda.declare_device( + "pyisupper", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_islower = cuda.declare_device( + "pyislower", types.boolean(types.CPointer(string_view), types.int64) +) + +_string_view_count = cuda.declare_device( + "pycount", + types.int32(types.CPointer(string_view), types.CPointer(string_view)), +) # String function implementations diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 657287d6d8b..45eb3343271 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -6,13 +6,13 @@ from numba import cuda from numba.core.typing import signature as nb_signature from numba.types import CPointer, void - -import cudf -from cudf.testing._utils import assert_eq from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view +import cudf +from cudf.testing._utils import assert_eq + def run_udf_test(data, func, dtype): dtype = np.dtype(dtype) From c8aa6f873b474efcfce14371d40b672a31653280 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 08:37:04 -0700 Subject: [PATCH 051/212] more wrangling with style checks, somehow --- .../strings_udf/strings_udf/_lib/cpp/strings_udf.pxd | 7 +++---- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 10 +++++----- python/strings_udf/strings_udf/tests/utils.py | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index f6f9a02f3e8..10096af99cd 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -1,15 +1,14 @@ # Copyright (c) 2021-2022, NVIDIA CORPORATION. +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type from libc.stdint cimport uint8_t from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type - cdef extern from "cudf/strings/udf/udf_apis.hpp": cdef cppclass udf_module diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 6f7f17129ab..4668f3f7766 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -12,7 +12,12 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + from strings_udf._lib.cpp.strings_udf cimport call_udf as cpp_call_udf from strings_udf._lib.cpp.\ strings_udf cimport create_udf_module as cpp_create_udf_module @@ -22,11 +27,6 @@ from strings_udf._lib.cpp.\ strings_udf cimport to_string_view_array as cpp_to_string_view_array from strings_udf._lib.cpp.strings_udf cimport udf_module as cpp_udf_module -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type - import numpy as np diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 45eb3343271..b32b239afc8 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. +import cudf import numba import numpy as np import pandas as pd +from cudf.testing._utils import assert_eq from numba import cuda from numba.core.typing import signature as nb_signature from numba.types import CPointer, void + from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view -import cudf -from cudf.testing._utils import assert_eq - def run_udf_test(data, func, dtype): dtype = np.dtype(dtype) From 8635f28f9ca6012d97468b363fc5aa573be6f977 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 08:47:54 -0700 Subject: [PATCH 052/212] last try --- .../strings_udf/strings_udf/_lib/cpp/strings_udf.pxd | 7 ++++--- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 10 +++++----- python/strings_udf/strings_udf/tests/utils.py | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index 10096af99cd..f6f9a02f3e8 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -1,14 +1,15 @@ # Copyright (c) 2021-2022, NVIDIA CORPORATION. -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from libc.stdint cimport uint8_t from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + cdef extern from "cudf/strings/udf/udf_apis.hpp": cdef cppclass udf_module diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 4668f3f7766..6f7f17129ab 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -12,12 +12,7 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer - from strings_udf._lib.cpp.strings_udf cimport call_udf as cpp_call_udf from strings_udf._lib.cpp.\ strings_udf cimport create_udf_module as cpp_create_udf_module @@ -27,6 +22,11 @@ from strings_udf._lib.cpp.\ strings_udf cimport to_string_view_array as cpp_to_string_view_array from strings_udf._lib.cpp.strings_udf cimport udf_module as cpp_udf_module +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + import numpy as np diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index b32b239afc8..45eb3343271 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -1,18 +1,18 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -import cudf import numba import numpy as np import pandas as pd -from cudf.testing._utils import assert_eq from numba import cuda from numba.core.typing import signature as nb_signature from numba.types import CPointer, void - from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view +import cudf +from cudf.testing._utils import assert_eq + def run_udf_test(data, func, dtype): dtype = np.dtype(dtype) From d208c5bc5c7f5c9c6cbf367a74680cdee01c2b12 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 3 Aug 2022 11:25:27 -0500 Subject: [PATCH 053/212] Fix isort. --- .pre-commit-config.yaml | 2 +- python/strings_udf/setup.cfg | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 python/strings_udf/setup.cfg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 154c911eb04..4051ff822be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: isort # Use the config file specific to each subproject so that each # project can specify its own first/third-party packages. - args: ["--config-root=python/", "--resolve-all-configs", "--profile", "black", "--filter-files"] + args: ["--config-root=python/", "--resolve-all-configs"] files: python/.* exclude: (__init__.py|setup.py)$ types_or: [python, cython, pyi] diff --git a/python/strings_udf/setup.cfg b/python/strings_udf/setup.cfg new file mode 100644 index 00000000000..51e8aaaecae --- /dev/null +++ b/python/strings_udf/setup.cfg @@ -0,0 +1,33 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +[isort] +line_length=79 +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +order_by_type=True +known_dask= + dask + distributed + dask_cuda +known_rapids= + rmm + cudf +known_first_party= + strings_udf +default_section=THIRDPARTY +sections=FUTURE,STDLIB,THIRDPARTY,DASK,RAPIDS,FIRSTPARTY,LOCALFOLDER +skip= + thirdparty + .eggs + .git + .hg + .mypy_cache + .tox + .venv + _build + buck-out + build + dist + __init__.py From 60e60be697aebb8208fb9d50569f156a8a0ddcd8 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 3 Aug 2022 11:27:48 -0500 Subject: [PATCH 054/212] Proposed isort changes. --- .../strings_udf/_lib/cpp/strings_udf.pxd | 2 +- .../strings_udf/_lib/cudf_jit_udf.pyx | 19 +++++++++---------- .../strings_udf/strings_udf/_lib/tables.pyx | 7 ++++--- python/strings_udf/strings_udf/lowering.py | 7 +++++-- python/strings_udf/strings_udf/tests/utils.py | 7 ++++--- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index f6f9a02f3e8..653ddae4b29 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -4,11 +4,11 @@ from libc.stdint cimport uint8_t from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer cdef extern from "cudf/strings/udf/udf_apis.hpp": diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 6f7f17129ab..fe17c10f349 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -12,20 +12,19 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -from strings_udf._lib.cpp.strings_udf cimport call_udf as cpp_call_udf -from strings_udf._lib.cpp.\ - strings_udf cimport create_udf_module as cpp_create_udf_module -from strings_udf._lib.cpp.\ - strings_udf cimport from_dstring_array as cpp_from_dstring_array -from strings_udf._lib.cpp.\ - strings_udf cimport to_string_view_array as cpp_to_string_view_array -from strings_udf._lib.cpp.strings_udf cimport udf_module as cpp_udf_module - from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + +from strings_udf._lib.cpp.strings_udf cimport ( + call_udf as cpp_call_udf, + create_udf_module as cpp_create_udf_module, + from_dstring_array as cpp_from_dstring_array, + to_string_view_array as cpp_to_string_view_array, + udf_module as cpp_udf_module, +) import numpy as np diff --git a/python/strings_udf/strings_udf/_lib/tables.pyx b/python/strings_udf/strings_udf/_lib/tables.pyx index 536583be4d8..b24aa19155d 100644 --- a/python/strings_udf/strings_udf/_lib/tables.pyx +++ b/python/strings_udf/strings_udf/_lib/tables.pyx @@ -4,9 +4,10 @@ # cython: c_string_type=unicode, c_string_encoding=utf8 from libc.stdint cimport uint8_t, uintptr_t -from strings_udf._lib.cpp.\ - strings_udf cimport get_character_flags_table as \ - cpp_get_character_flags_table + +from strings_udf._lib.cpp.strings_udf cimport ( + get_character_flags_table as cpp_get_character_flags_table, +) import numpy as np diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index d315fd8a666..ca6df5b2ee5 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -6,8 +6,11 @@ from numba.core import cgutils from numba.core.typing import signature as nb_signature from numba.cuda.cudadrv import nvvm -from numba.cuda.cudaimpl import lower as cuda_lower -from numba.cuda.cudaimpl import registry as cuda_lowering_registry +from numba.cuda.cudaimpl import ( + lower as cuda_lower, + registry as cuda_lowering_registry, +) + from strings_udf._lib.tables import get_character_flags_table_ptr from strings_udf._typing import string_view diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 45eb3343271..01ed86eb497 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -6,13 +6,14 @@ from numba import cuda from numba.core.typing import signature as nb_signature from numba.types import CPointer, void -from strings_udf import ptxpath -from strings_udf._lib.cudf_jit_udf import to_string_view_array -from strings_udf._typing import str_view_arg_handler, string_view import cudf from cudf.testing._utils import assert_eq +from strings_udf import ptxpath +from strings_udf._lib.cudf_jit_udf import to_string_view_array +from strings_udf._typing import str_view_arg_handler, string_view + def run_udf_test(data, func, dtype): dtype = np.dtype(dtype) From fb3820fbba43e2b7e784cb73fb50975cd3f1f764 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 12:09:13 -0700 Subject: [PATCH 055/212] allow import on CPU only machine --- python/cudf/cudf/core/udf/__init__.py | 8 +++----- python/strings_udf/strings_udf/__init__.py | 24 +++++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 34059c1e9e4..05d6d6c2a6d 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -8,9 +8,6 @@ ) from cudf.core.udf import api -driver_maj, driver_min = cuda.cudadrv.driver.get_version() -runtime_maj, runtime_min = cuda.cudadrv.runtime.runtime.get_version() - units = ["ns", "ms", "us", "s"] datetime_cases = {types.NPDatetime(u) for u in units} timedelta_cases = {types.NPTimedelta(u) for u in units} @@ -25,7 +22,7 @@ ) _STRING_UDFS_ENABLED = False -if driver_maj >= runtime_maj and driver_min >= runtime_min: +try: from . import strings_typing from . import strings_lowering @@ -41,6 +38,7 @@ supported_masked_types |= {strings_typing.string_view} _STRING_UDFS_ENABLED = True - +except NotImplementedError: + pass masked_typing.register_masked_constructor(supported_masked_types) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index 5d7b2a89d17..f46719eb8c5 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,9 +1,23 @@ # Copyright (c) 2022, NVIDIA CORPORATION. +from numba import cuda -from strings_udf import lowering +try: + # allow import on CPU-only machine + driver_maj, driver_min = cuda.cudadrv.driver.get_version() + runtime_maj, runtime_min = cuda.cudadrv.runtime.runtime.get_version() -from pathlib import Path + if driver_maj >= runtime_maj and driver_min >= runtime_min: + from strings_udf import lowering + from pathlib import Path -here = str(Path(__file__).parent.absolute()) -relative = "/../cpp/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx" -ptxpath = here + relative + here = str(Path(__file__).parent.absolute()) + relative = "/../cpp/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx" + ptxpath = here + relative + else: + raise NotImplementedError( + "String UDFs require CUDA driver version >= CUDA runtime version" + ) + +except cuda.cudadrv.driver.CudaAPIError: + # no GPU found + pass From eed2a52ae818790e0b9d046223fdef2cb31085e7 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 13:35:45 -0700 Subject: [PATCH 056/212] catch importerror --- python/cudf/cudf/core/udf/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 05d6d6c2a6d..4bbe34fdd21 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -23,6 +23,7 @@ _STRING_UDFS_ENABLED = False try: + import strings_udf from . import strings_typing from . import strings_lowering @@ -38,7 +39,8 @@ supported_masked_types |= {strings_typing.string_view} _STRING_UDFS_ENABLED = True -except NotImplementedError: +except (NotImplementedError, ImportError): + # allow cuDF to work without strings_udf pass masked_typing.register_masked_constructor(supported_masked_types) From 8d4d10bd3c469c9c48e2efd73708d7cab5f13408 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 13:36:37 -0700 Subject: [PATCH 057/212] updates --- python/cudf/cudf/core/udf/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 4bbe34fdd21..bf15271b07f 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -23,7 +23,6 @@ _STRING_UDFS_ENABLED = False try: - import strings_udf from . import strings_typing from . import strings_lowering From 099a1fc23c7e9e54b9964e021e354aafbda6d808 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 16:19:44 -0700 Subject: [PATCH 058/212] do not import stringview in masked constructor --- python/cudf/cudf/core/udf/masked_typing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 8414a5782b2..b955d804fc7 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -156,7 +156,6 @@ def typeof_masked(val, c): # type in a kernel. def register_masked_constructor(supported_masked_types): class MaskedConstructor(ConcreteTemplate): - from cudf.core.udf.strings_typing import string_view key = api.Masked units = ["ns", "ms", "us", "s"] From 26be2a0e72714dfc0fa03676236b4f6bbb35c9a9 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 3 Aug 2022 16:24:55 -0700 Subject: [PATCH 059/212] start adding strings_udf to ci test scripts --- ci/gpu/build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 8f215d1bb54..06956c8dfce 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -243,6 +243,11 @@ cd "$WORKSPACE/python/custreamz" gpuci_logger "Python py.test for cuStreamz" py.test -n 8 --cache-clear --basetemp="$WORKSPACE/custreamz-cuda-tmp" --junitxml="$WORKSPACE/junit-custreamz.xml" -v --cov-config=.coveragerc --cov=custreamz --cov-report=xml:"$WORKSPACE/python/custreamz/custreamz-coverage.xml" --cov-report term custreamz +cd "$WORKSPACE/python/strings_udf" +gpuci_logger "Python py.test for strings_udf" +py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term strings_udf + + # Run benchmarks with both cudf and pandas to ensure compatibility is maintained. # Benchmarks are run in DEBUG_ONLY mode, meaning that only small data sizes are used. # Therefore, these runs only verify that benchmarks are valid. From 6df94b73cbddde126df9323a261b31e0addf19f8 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 4 Aug 2022 07:44:09 -0700 Subject: [PATCH 060/212] excize string udf imports in masked typing --- python/cudf/cudf/core/udf/__init__.py | 11 ++++++++ python/cudf/cudf/core/udf/utils.py | 36 ++++++++++++++------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index bf15271b07f..7012a22d978 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -7,6 +7,9 @@ registry as cuda_lowering_registry, ) from cudf.core.udf import api +from cudf.core.udf import utils +from cudf.core.dtypes import dtype +import numpy as np units = ["ns", "ms", "us", "s"] datetime_cases = {types.NPDatetime(u) for u in units} @@ -25,6 +28,9 @@ try: from . import strings_typing from . import strings_lowering + from strings_udf import ptxpath + from strings_udf._typing import string_view, str_view_arg_handler + from strings_udf._lib.cudf_jit_udf import to_string_view_array # add an overload of MaskedType.__init__(string_view, bool) cuda_lower(api.Masked, strings_typing.string_view, types.boolean)( @@ -37,6 +43,11 @@ ) supported_masked_types |= {strings_typing.string_view} + utils.launch_arg_getters[dtype("O")] = to_string_view_array + utils.masked_array_types[dtype("O")] = string_view + utils.files.append(ptxpath) + utils.arg_handlers.append(str_view_arg_handler) + _STRING_UDFS_ENABLED = True except (NotImplementedError, ImportError): # allow cuDF to work without strings_udf diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 223a26de401..06165de1e33 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -1,6 +1,6 @@ # Copyright (c) 2020-2022, NVIDIA CORPORATION. -from typing import Callable +from typing import Any, Callable, Dict, List import cachetools import cupy as cp @@ -10,10 +10,6 @@ from numba.np import numpy_support from numba.types import CPointer, Poison, Tuple, boolean, int64, void -from strings_udf import ptxpath -from strings_udf._typing import str_view_arg_handler, string_view - -from cudf.api.types import is_string_dtype from cudf.core.column.column import as_column from cudf.core.dtypes import CategoricalDtype from cudf.core.udf.masked_typing import MaskedType @@ -38,6 +34,8 @@ MASK_BITSIZE = np.dtype("int32").itemsize * 8 precompiled: cachetools.LRUCache = cachetools.LRUCache(maxsize=32) +arg_handlers: List[Any] = [] +files: List[Any] = [] @_cudf_nvtx_annotate @@ -119,6 +117,9 @@ def _supported_cols_from_frame(frame): } +masked_array_types: Dict[Any, Any] = {} + + def _masked_array_type_from_col(col): """ Return a type representing a tuple of arrays, @@ -126,9 +127,10 @@ def _masked_array_type_from_col(col): corresponding to `dtype`, and the second an array of bools representing a mask. """ - if is_string_dtype(col.dtype): - # strings_udf library provides a pointer directly to the data - col_type = CPointer(string_view) + + col_type = masked_array_types.get(col.dtype) + if col_type: + col_type = CPointer(col_type) else: nb_scalar_ty = numpy_support.from_dtype(col.dtype) col_type = nb_scalar_ty[::1] @@ -228,21 +230,21 @@ def _get_kernel(kernel_string, globals_, sig, func): globals_["f_"] = f_ exec(kernel_string, globals_) _kernel = globals_["_kernel"] - kernel = cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler])( - _kernel - ) + kernel = cuda.jit(sig, link=files, extensions=arg_handlers)(_kernel) return kernel +launch_arg_getters: Dict[Any, Any] = {} + + def _launch_arg_from_col(col): - from strings_udf._lib.cudf_jit_udf import to_string_view_array + getter = launch_arg_getters.get(col.dtype) + if getter: + data = getter(col) + else: + data = col.data - data = ( - col.data - if not is_string_dtype(col.dtype) - else to_string_view_array(col) - ) mask = col.mask if mask is None: return data From 8ac74557e114f595fe673d641896e3bd9f0f35fe Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 4 Aug 2022 12:06:45 -0700 Subject: [PATCH 061/212] excise string_udf imports from row_function.py --- python/cudf/cudf/core/udf/__init__.py | 2 ++ python/cudf/cudf/core/udf/row_function.py | 17 ++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 7012a22d978..e12673a74c5 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -8,6 +8,7 @@ ) from cudf.core.udf import api from cudf.core.udf import utils +from cudf.core.udf import row_function from cudf.core.dtypes import dtype import numpy as np @@ -47,6 +48,7 @@ utils.masked_array_types[dtype("O")] = string_view utils.files.append(ptxpath) utils.arg_handlers.append(str_view_arg_handler) + row_function.itemsizes[dtype("O")] = string_view.size_bytes _STRING_UDFS_ENABLED = True except (NotImplementedError, ImportError): diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 028d8bcb5a7..93f4f9cc243 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -1,13 +1,12 @@ # Copyright (c) 2021-2022, NVIDIA CORPORATION. import math +from typing import Any, Dict import numpy as np from numba import cuda from numba.np import numpy_support from numba.types import Record -from strings_udf._typing import DString - from cudf.core.udf.api import Masked, pack_return from cudf.core.udf.masked_typing import MaskedType from cudf.core.udf.templates import ( @@ -26,7 +25,7 @@ _supported_dtypes_from_frame, ) -dstring = DString() +itemsizes: Dict[Any, Any] = {} def _get_frame_row_type(dtype): @@ -50,12 +49,6 @@ def _get_frame_row_type(dtype): offset = 0 sizes = [] - for field in dtype.fields.values(): - if field[0] == np.dtype("object"): - sizes.append(dstring.size_bytes) - else: - sizes.append(field[0].itemsize) - for i, (name, info) in enumerate(dtype.fields.items()): # *info* consists of the element dtype, its offset from the beginning # of the record, and an optional "title" containing metadata. @@ -72,10 +65,8 @@ def _get_frame_row_type(dtype): fields.append((name, infos)) # increment offset by itemsize plus one byte for validity - if elemdtype == np.dtype("object"): - itemsize = dstring.size_bytes - else: - itemsize = elemdtype.itemsize + itemsize = itemsizes.get(elemdtype) or elemdtype.itemsize + sizes.append(itemsize) offset += itemsize + 1 # Align the next member of the struct to be a multiple of the From 77d19b14950a158ea7510d5e9783ccb908188ebb Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 5 Aug 2022 07:23:27 -0700 Subject: [PATCH 062/212] remove license --- python/strings_udf/LICENSE | 201 ------------------------------------- 1 file changed, 201 deletions(-) delete mode 100644 python/strings_udf/LICENSE diff --git a/python/strings_udf/LICENSE b/python/strings_udf/LICENSE deleted file mode 100644 index 18bcb4316e6..00000000000 --- a/python/strings_udf/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2018 NVIDIA Corporation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. From 938f0179a7287e9feaeaac4a405296ec32f4619a Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 8 Aug 2022 15:44:08 -0700 Subject: [PATCH 063/212] begin adding and testing conda package --- ci/cpu/build.sh | 4 +++ ci/gpu/build.sh | 6 ++-- conda/recipes/strings_udf/build.sh | 4 +++ conda/recipes/strings_udf/meta.yaml | 44 +++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 conda/recipes/strings_udf/build.sh create mode 100644 conda/recipes/strings_udf/meta.yaml diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index f5ea2c902ef..b43a8461acf 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -108,6 +108,10 @@ if [ "$BUILD_CUDF" == '1' ]; then gpuci_logger "Build conda pkg for custreamz" gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/custreamz --python=$PYTHON $CONDA_BUILD_ARGS $CONDA_CHANNEL + + gpuci_logger "Build conda pkg for strings_udf" + gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf --python=$PYTHON $CONDA_BUILD_ARGS $CONDA_CHANNEL + fi ################################################################################ # UPLOAD - Conda packages diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 06956c8dfce..00a373a535e 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -169,15 +169,15 @@ else # TODO: Move boa install to gpuci/rapidsai gpuci_mamba_retry install boa - gpuci_logger "Building cudf, dask-cudf, cudf_kafka and custreamz" + gpuci_logger "Building cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/dask-cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf_kafka --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/custreamz --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} - gpuci_logger "Installing cudf, dask-cudf, cudf_kafka and custreamz" - gpuci_mamba_retry install cudf dask-cudf cudf_kafka custreamz -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" + gpuci_logger "Installing cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" + gpuci_mamba_retry install cudf dask-cudf cudf_kafka custreamz strings_udf -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" gpuci_logger "GoogleTests" # Run libcudf and libcudf_kafka gtests from libcudf-tests package diff --git a/conda/recipes/strings_udf/build.sh b/conda/recipes/strings_udf/build.sh new file mode 100644 index 00000000000..2de1325347b --- /dev/null +++ b/conda/recipes/strings_udf/build.sh @@ -0,0 +1,4 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +# This assumes the script is executed from the root of the repo directory +./build.sh strings_udf diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml new file mode 100644 index 00000000000..d7d27856ad3 --- /dev/null +++ b/conda/recipes/strings_udf/meta.yaml @@ -0,0 +1,44 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +{% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} +{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} +{% set cuda_version = '.'.join(environ.get('CUDA', '11.5').split('.')[:2]) %} +{% set py_version = environ.get('PY_VER', '3.8') %} +{% set py_version_numeric = py_version.replace('.', '') %} + +package: + name: strings_udf + version: {{ version }} + +source: + git_url: ../../.. + +build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: cuda_{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + script_env: + - VERSION_SUFFIX + - PARALLEL_LEVEL + +requirements: + host: + - python + - cudf ={{ version }} + - cudatoolkit ={{ cuda_version }} + run: + - python + - cudf ={{ version }} + +test: # [linux64] + requires: # [linux64] + - cudatoolkit {{ cuda_version }}.* # [linux64] + imports: # [linux64] + - strings_udf # [linux64] + + +about: + home: https://rapids.ai/ + license: Apache-2.0 + license_family: APACHE + license_file: LICENSE + summary: strings_udf library From 4119b6d2d633ec7e88f9bf86752d5dc0b497bd2c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 8 Aug 2022 17:15:05 -0700 Subject: [PATCH 064/212] conda and build updates --- ci/gpu/build.sh | 2 ++ conda/recipes/strings_udf/meta.yaml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 00a373a535e..fa7b79da8d1 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -175,6 +175,8 @@ else gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/dask-cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf_kafka --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/custreamz --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} + gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} + gpuci_logger "Installing cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" gpuci_mamba_retry install cudf dask-cudf cudf_kafka custreamz strings_udf -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index d7d27856ad3..d579f18c52e 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -15,7 +15,7 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda_{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda_{{ cuda_version }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - VERSION_SUFFIX - PARALLEL_LEVEL From d6e043b38b864e6b53cf1d74dcc0d317dff27cd7 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 8 Aug 2022 18:27:13 -0700 Subject: [PATCH 065/212] add cython to meta.yaml --- conda/recipes/strings_udf/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index d579f18c52e..bfd59d68dea 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -24,6 +24,7 @@ requirements: host: - python - cudf ={{ version }} + - cython >=0.29,<0.30 - cudatoolkit ={{ cuda_version }} run: - python From 2cbf7501a15aaaa956d6fac7a507a73e547148bf Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 9 Aug 2022 11:30:27 -0700 Subject: [PATCH 066/212] try yaml from cudf --- conda/recipes/strings_udf/meta.yaml | 33 +++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index bfd59d68dea..93ed5a6e702 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -21,14 +21,43 @@ build: - PARALLEL_LEVEL requirements: + build: + - cmake {{ cmake_version }} + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('cuda') }} {{ cuda_version }} + - sysroot_{{ target_platform }} {{ sysroot_version }} host: + - protobuf>=3.20.1,<3.21.0a0 - python - - cudf ={{ version }} - cython >=0.29,<0.30 + - scikit-build>=0.13.1 + - setuptools + - numba >=0.54 + - dlpack>=0.5,<0.6.0a0 + - pyarrow =8 + - libcudf ={{ version }} + - rmm ={{ minor_version }} - cudatoolkit ={{ cuda_version }} run: + - protobuf>=3.20.1,<3.21.0a0 - python - - cudf ={{ version }} + - typing_extensions + - pandas >=1.0,<1.5.0dev0 + - cupy >=9.5.0,<11.0.0a0 + - numba >=0.54 + - numpy + - {{ pin_compatible('pyarrow', max_pin='x.x.x') }} + - libcudf {{ version }} + - fastavro >=0.22.0 + - {{ pin_compatible('rmm', max_pin='x.x') }} + - fsspec>=0.6.0 + - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + - nvtx >=0.2.1 + - packaging + - cachetools + - ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler + - cuda-python >=11.5,<11.7.1 test: # [linux64] requires: # [linux64] From 53dd3f6a190c6279a7d245de32231dcd36b4de2c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 9 Aug 2022 12:54:40 -0700 Subject: [PATCH 067/212] add conda_build_config.yaml --- conda/recipes/strings_udf/conda_build_config.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 conda/recipes/strings_udf/conda_build_config.yaml diff --git a/conda/recipes/strings_udf/conda_build_config.yaml b/conda/recipes/strings_udf/conda_build_config.yaml new file mode 100644 index 00000000000..d9c3f21448f --- /dev/null +++ b/conda/recipes/strings_udf/conda_build_config.yaml @@ -0,0 +1,14 @@ +c_compiler_version: + - 9 + +cxx_compiler_version: + - 9 + +sysroot_version: + - "2.17" + +cmake_version: + - ">=3.20.1,!=3.23.0" + +cuda_compiler: + - nvcc From 436f16f89b997208235ff1f8214152400fd83cc6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 10 Aug 2022 11:31:13 -0700 Subject: [PATCH 068/212] use skbuild --- build.sh | 20 +++++++++++++++----- python/strings_udf/setup.py | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 1619ac089e6..720c8ca19a5 100755 --- a/build.sh +++ b/build.sh @@ -335,6 +335,21 @@ if buildAll || hasArg cudf; then fi fi +if buildAll || hasArg strings_udf; then + cd ${REPODIR}/python/strings_udf/cpp + mkdir build + cd build + cmake .. -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ + make + cd ${REPODIR}/python/strings_udf + python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} + if [[ ${INSTALL_TARGET} != "" ]]; then + python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} + cd ${REPODIR}/python/strings_udf/cpp/build + make install + fi +fi + # Build and install the dask_cudf Python package if buildAll || hasArg dask_cudf; then @@ -389,8 +404,3 @@ if hasArg custreamz; then PARALLEL_LEVEL=${PARALLEL_LEVEL} python setup.py build_ext --inplace -j${PARALLEL_LEVEL} --library-dir=${LIBCUDF_BUILD_DIR} fi fi - -if hasArg strings_udf; then - cd ${REPODIR}/python/strings_udf - bash build.sh -fi diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index a3718590ee5..f9fd74952a3 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -4,7 +4,8 @@ from distutils.sysconfig import get_python_lib from Cython.Build import cythonize -from setuptools import find_packages, setup +from setuptools import find_packages +from skbuild import setup from setuptools.extension import Extension CUDA_HOME = "/usr/local/cuda" From 293652d70d0855383f1b6eaef295a0e357e35afd Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 10 Aug 2022 12:32:22 -0700 Subject: [PATCH 069/212] update meta.yaml --- conda/recipes/strings_udf/meta.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index 93ed5a6e702..58ae0754c92 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -1,10 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} -{% set cuda_version = '.'.join(environ.get('CUDA', '11.5').split('.')[:2]) %} -{% set py_version = environ.get('PY_VER', '3.8') %} -{% set py_version_numeric = py_version.replace('.', '') %} +{% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} +{% set py_version=environ.get('CONDA_PY', 36) %} +{% set cuda_version='.'.join(environ.get('CUDA', '11.5').split('.')[:2]) %} +{% set cuda_major=cuda_version.split('.')[0] %} package: name: strings_udf @@ -15,10 +15,15 @@ source: build: number: {{ GIT_DESCRIBE_NUMBER }} - string: cuda_{{ cuda_version }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + string: cuda_{{ cuda_major }}_py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} script_env: - VERSION_SUFFIX - PARALLEL_LEVEL + # libcudf's run_exports pinning is looser than we would like + ignore_run_exports: + - libcudf + ignore_run_exports_from: + - {{ compiler('cuda') }} requirements: build: @@ -37,6 +42,7 @@ requirements: - dlpack>=0.5,<0.6.0a0 - pyarrow =8 - libcudf ={{ version }} + - cudf ={{ version }} - rmm ={{ minor_version }} - cudatoolkit ={{ cuda_version }} run: @@ -49,6 +55,7 @@ requirements: - numpy - {{ pin_compatible('pyarrow', max_pin='x.x.x') }} - libcudf {{ version }} + - cudf ={{ version }} - fastavro >=0.22.0 - {{ pin_compatible('rmm', max_pin='x.x') }} - fsspec>=0.6.0 @@ -58,14 +65,12 @@ requirements: - cachetools - ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler - cuda-python >=11.5,<11.7.1 - test: # [linux64] requires: # [linux64] - cudatoolkit {{ cuda_version }}.* # [linux64] imports: # [linux64] - strings_udf # [linux64] - about: home: https://rapids.ai/ license: Apache-2.0 From 43a11aadad1cbdb22623d79aeaf9b880611a1e17 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 11 Aug 2022 12:38:37 -0700 Subject: [PATCH 070/212] build using build system independent commands --- build.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 720c8ca19a5..1d9606d29d2 100755 --- a/build.sh +++ b/build.sh @@ -337,16 +337,16 @@ fi if buildAll || hasArg strings_udf; then cd ${REPODIR}/python/strings_udf/cpp - mkdir build - cd build - cmake .. -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ - make + ls + cmake -S ./ -B build -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ + cmake --build build + ls cd ${REPODIR}/python/strings_udf python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} if [[ ${INSTALL_TARGET} != "" ]]; then python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} - cd ${REPODIR}/python/strings_udf/cpp/build - make install + cd ${REPODIR}/python/strings_udf/cpp/ + cmake --install ./build fi fi From 2733360095cc56d918ecf2924d9a72d4515ffe64 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 15 Aug 2022 12:53:40 -0700 Subject: [PATCH 071/212] change around cuda version constraints, adjust cmake to ship ptx hopefully --- python/cudf/cudf/core/udf/__init__.py | 53 ++++++++++++---------- python/strings_udf/cpp/CMakeLists.txt | 3 ++ python/strings_udf/strings_udf/__init__.py | 26 +++-------- 3 files changed, 38 insertions(+), 44 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index e12673a74c5..0b473375f08 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -27,31 +27,34 @@ _STRING_UDFS_ENABLED = False try: - from . import strings_typing - from . import strings_lowering - from strings_udf import ptxpath - from strings_udf._typing import string_view, str_view_arg_handler - from strings_udf._lib.cudf_jit_udf import to_string_view_array - - # add an overload of MaskedType.__init__(string_view, bool) - cuda_lower(api.Masked, strings_typing.string_view, types.boolean)( - masked_lowering.masked_constructor - ) - - # add an overload of pack_return(string_view) - cuda_lower(api.pack_return, strings_typing.string_view)( - masked_lowering.pack_return_scalar_impl - ) - - supported_masked_types |= {strings_typing.string_view} - utils.launch_arg_getters[dtype("O")] = to_string_view_array - utils.masked_array_types[dtype("O")] = string_view - utils.files.append(ptxpath) - utils.arg_handlers.append(str_view_arg_handler) - row_function.itemsizes[dtype("O")] = string_view.size_bytes - - _STRING_UDFS_ENABLED = True -except (NotImplementedError, ImportError): + import strings_udf + + if strings_udf.ENABLED: + from . import strings_typing + from . import strings_lowering + from strings_udf import ptxpath + from strings_udf._typing import string_view, str_view_arg_handler + from strings_udf._lib.cudf_jit_udf import to_string_view_array + + # add an overload of MaskedType.__init__(string_view, bool) + cuda_lower(api.Masked, strings_typing.string_view, types.boolean)( + masked_lowering.masked_constructor + ) + + # add an overload of pack_return(string_view) + cuda_lower(api.pack_return, strings_typing.string_view)( + masked_lowering.pack_return_scalar_impl + ) + + supported_masked_types |= {strings_typing.string_view} + utils.launch_arg_getters[dtype("O")] = to_string_view_array + utils.masked_array_types[dtype("O")] = string_view + utils.files.append(ptxpath) + utils.arg_handlers.append(str_view_arg_handler) + row_function.itemsizes[dtype("O")] = string_view.size_bytes + + _STRING_UDFS_ENABLED = True +except ImportError: # allow cuDF to work without strings_udf pass diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 51098ea1543..b8c0639696e 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -113,6 +113,9 @@ set_target_properties(udf_cli PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED O install(TARGETS cudf_strings_udf) install(TARGETS udf_cli) +install(FILES ${CMAKE_SOURCE_DIR}/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx + DESTINATION ${CMAKE_SOURCE_DIR}/../strings_udf/shim/ +) add_custom_command( OUTPUT dstring_test diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index f46719eb8c5..fe7e4187bdd 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,23 +1,11 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from numba import cuda +from ptxcompiler.patch import patch_needed -try: - # allow import on CPU-only machine - driver_maj, driver_min = cuda.cudadrv.driver.get_version() - runtime_maj, runtime_min = cuda.cudadrv.runtime.runtime.get_version() +breakpoint() +ENABLED = False if patch_needed() else True - if driver_maj >= runtime_maj and driver_min >= runtime_min: - from strings_udf import lowering - from pathlib import Path +from pathlib import Path - here = str(Path(__file__).parent.absolute()) - relative = "/../cpp/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx" - ptxpath = here + relative - else: - raise NotImplementedError( - "String UDFs require CUDA driver version >= CUDA runtime version" - ) - -except cuda.cudadrv.driver.CudaAPIError: - # no GPU found - pass +here = str(Path(__file__).parent.absolute()) +relative = "shim/shim.ptx" +ptxpath = here + relative From 427394908db606e6285f8c977245912fbd1f4437 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 16 Aug 2022 09:04:19 -0700 Subject: [PATCH 072/212] prune out dstring until phase 2 and CLI files for now --- python/strings_udf/cpp/CMakeLists.txt | 60 -- .../include/cudf/strings/udf/char_types.cuh | 1 - .../cpp/include/cudf/strings/udf/dstring.cuh | 460 ---------------- .../cpp/include/cudf/strings/udf/dstring.hpp | 521 ------------------ .../cpp/include/cudf/strings/udf/search.cuh | 19 - .../cpp/include/cudf/strings/udf/split.cuh | 188 ------- .../include/cudf/strings/udf/starts_with.cuh | 27 - .../cpp/include/cudf/strings/udf/udf_apis.hpp | 85 --- python/strings_udf/cpp/sample_udfs/copy.udf | 16 - .../strings_udf/cpp/sample_udfs/example.txt | 5 - .../strings_udf/cpp/sample_udfs/example.xml | 6 - python/strings_udf/cpp/sample_udfs/filter.udf | 42 -- .../strings_udf/cpp/sample_udfs/integers.udf | 19 - python/strings_udf/cpp/sample_udfs/join.udf | 34 -- python/strings_udf/cpp/sample_udfs/lower.udf | 49 -- python/strings_udf/cpp/sample_udfs/print.udf | 17 - python/strings_udf/cpp/sample_udfs/split.udf | 47 -- .../cpp/sample_udfs/starts_with.udf | 21 - python/strings_udf/cpp/sample_udfs/strip.udf | 18 - python/strings_udf/cpp/sample_udfs/xml.udf | 29 - .../strings_udf/cpp/src/strings/udf/shim.cu | 1 - .../cpp/src/strings/udf/udf_apis.cu | 275 --------- .../cpp/src/strings/udf/udf_cli.cpp | 192 ------- python/strings_udf/cpp/tests/append.udf | 45 -- python/strings_udf/cpp/tests/char_types.udf | 59 -- python/strings_udf/cpp/tests/ctors.udf | 61 -- python/strings_udf/cpp/tests/done.txt | 1 - python/strings_udf/cpp/tests/erase.udf | 33 -- python/strings_udf/cpp/tests/insert.udf | 40 -- python/strings_udf/cpp/tests/integers.udf | 34 -- python/strings_udf/cpp/tests/replace.udf | 73 --- python/strings_udf/cpp/tests/resize.udf | 35 -- python/strings_udf/cpp/tests/run_tests.sh | 18 - python/strings_udf/cpp/tests/search.udf | 30 - python/strings_udf/cpp/tests/split.udf | 32 -- python/strings_udf/cpp/tests/starts_ends.udf | 35 -- python/strings_udf/cpp/tests/strip.udf | 59 -- python/strings_udf/cpp/tests/substr.udf | 35 -- python/strings_udf/cpp/tests/utilities.cuh | 43 -- python/strings_udf/strings_udf/__init__.py | 3 +- 40 files changed, 1 insertion(+), 2767 deletions(-) delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/split.cuh delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp delete mode 100644 python/strings_udf/cpp/sample_udfs/copy.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/example.txt delete mode 100644 python/strings_udf/cpp/sample_udfs/example.xml delete mode 100644 python/strings_udf/cpp/sample_udfs/filter.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/integers.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/join.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/lower.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/print.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/split.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/starts_with.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/strip.udf delete mode 100644 python/strings_udf/cpp/sample_udfs/xml.udf delete mode 100644 python/strings_udf/cpp/src/strings/udf/udf_apis.cu delete mode 100644 python/strings_udf/cpp/src/strings/udf/udf_cli.cpp delete mode 100644 python/strings_udf/cpp/tests/append.udf delete mode 100644 python/strings_udf/cpp/tests/char_types.udf delete mode 100644 python/strings_udf/cpp/tests/ctors.udf delete mode 100644 python/strings_udf/cpp/tests/done.txt delete mode 100644 python/strings_udf/cpp/tests/erase.udf delete mode 100644 python/strings_udf/cpp/tests/insert.udf delete mode 100644 python/strings_udf/cpp/tests/integers.udf delete mode 100644 python/strings_udf/cpp/tests/replace.udf delete mode 100644 python/strings_udf/cpp/tests/resize.udf delete mode 100755 python/strings_udf/cpp/tests/run_tests.sh delete mode 100644 python/strings_udf/cpp/tests/search.udf delete mode 100644 python/strings_udf/cpp/tests/split.udf delete mode 100644 python/strings_udf/cpp/tests/starts_ends.udf delete mode 100644 python/strings_udf/cpp/tests/strip.udf delete mode 100644 python/strings_udf/cpp/tests/substr.udf delete mode 100644 python/strings_udf/cpp/tests/utilities.cuh diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index b8c0639696e..7b5791ced1f 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -44,22 +44,10 @@ message(STATUS "CONDA_PREFIX=${CONDA_PREFIX}") find_package(CUDAToolkit REQUIRED) -# depends on an installed cudf dev env -set(UDF_INCLUDES ${CONDA_PREFIX}/include) -list(APPEND UDF_INCLUDES ${CONDA_PREFIX}/include/rapids/libcudacxx) -list(APPEND UDF_INCLUDES ${CMAKE_SOURCE_DIR}/build/_deps/jitify-src) - -set(UDF_LIBS ${CONDA_PREFIX}/lib/libcudf.so nvrtc) - -set(UDF_CXX_FLAGS "") -set(UDF_CUDA_FLAGS "") set(SHIM_CUDA_FLAGS "") -list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true -keep) -add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) - add_library(shim OBJECT src/strings/udf/shim.cu) set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) @@ -76,56 +64,8 @@ target_include_directories( PUBLIC ${CONDA_PREFIX}/include ) -set_target_properties( - cudf_strings_udf - PROPERTIES BUILD_RPATH "\$ORIGIN" - INSTALL_RPATH "\$ORIGIN" - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED ON - CUDA_STANDARD 17 - CUDA_STANDARD_REQUIRED ON - POSITION_INDEPENDENT_CODE ON - INTERFACE_POSITION_INDEPENDENT_CODE ON -) - -target_compile_options( - cudf_strings_udf PRIVATE "$<$:${UDF_CXX_FLAGS}>" - "$<$:${UDF_CUDA_FLAGS}>" -) - target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") -target_include_directories( - cudf_strings_udf - PRIVATE include - PUBLIC ${UDF_INCLUDES} -) -target_link_libraries(cudf_strings_udf PUBLIC ${UDF_LIBS}) - -add_executable(udf_cli src/strings/udf/udf_cli.cpp) -target_include_directories( - udf_cli - PRIVATE include - PUBLIC ${UDF_INCLUDES} CUDA::cudart -) -target_link_libraries(udf_cli PUBLIC cudf_strings_udf ${UDF_LIBS} CUDA::cudart) -set_target_properties(udf_cli PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON) - -install(TARGETS cudf_strings_udf) -install(TARGETS udf_cli) install(FILES ${CMAKE_SOURCE_DIR}/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx DESTINATION ${CMAKE_SOURCE_DIR}/../strings_udf/shim/ ) - -add_custom_command( - OUTPUT dstring_test - COMMAND ../tests/run_tests.sh - VERBATIM - COMMENT "Running dstring tests." -) - -add_custom_target( - test - DEPENDS dstring_test - COMMENT "Run dstring tests." -) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh index efc778e156a..fcc18c02668 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh @@ -20,7 +20,6 @@ #include #include #include -#include "dstring.cuh" namespace cudf { namespace strings { diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh deleted file mode 100644 index 922dd68f108..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/dstring.cuh +++ /dev/null @@ -1,460 +0,0 @@ -/* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "dstring.hpp" - -#include -#include - -#include -#include -#include - -namespace cudf { -namespace strings { -namespace udf { -namespace detail { - -__device__ inline static cudf::size_type bytes_in_null_terminated_string(char const* str) -{ - if (!str) return 0; - cudf::size_type bytes = 0; - while (*str++) ++bytes; - return bytes; -} - -} // namespace detail - -__device__ inline char* dstring::allocate(cudf::size_type bytes) -{ - char* data = static_cast(malloc(bytes + 1)); - data[bytes] = 0; // add null-terminator so we can printf strings in device code - return data; -} - -__device__ inline void dstring::deallocate(char* data) -{ - if (data) free(data); -} - -__device__ void dstring::reallocate(cudf::size_type bytes) -{ - m_capacity = bytes; - auto new_data = allocate(m_capacity); - memcpy(new_data, m_data, std::min(m_bytes, bytes)); - deallocate(m_data); - m_data = new_data; -} - -__device__ inline dstring::dstring(char const* data, cudf::size_type bytes) - : m_bytes(bytes), m_capacity(bytes) -{ - m_data = allocate(m_capacity); - memcpy(m_data, data, bytes); -} - -__device__ dstring::dstring(cudf::size_type count, cudf::char_utf8 chr) -{ - if (count <= 0) { return; } - m_bytes = m_capacity = cudf::strings::detail::bytes_in_char_utf8(chr) * count; - m_data = allocate(m_capacity); - auto out_ptr = m_data; - for (auto idx = 0; idx < count; ++idx) { - out_ptr += cudf::strings::detail::from_char_utf8(chr, out_ptr); - } -} - -__device__ inline dstring::dstring(char const* data) -{ - m_bytes = m_capacity = detail::bytes_in_null_terminated_string(data); - m_data = allocate(m_capacity); - memcpy(m_data, data, m_bytes); -} - -__device__ inline dstring::dstring(dstring const& src) - : m_bytes(src.m_bytes), m_capacity(src.m_bytes) -{ - m_data = allocate(m_capacity); - memcpy(m_data, src.m_data, m_bytes); -} - -__device__ inline dstring::dstring(dstring&& src) - : m_data(src.m_data), m_bytes(src.m_bytes), m_capacity(src.m_capacity) -{ - src.m_data = nullptr; - src.m_bytes = 0; - src.m_capacity = 0; -} - -__device__ inline dstring::dstring(cudf::string_view const str) - : m_bytes(str.size_bytes()), m_capacity(str.size_bytes()) -{ - m_data = allocate(m_capacity); - memcpy(m_data, str.data(), m_bytes); -} - -__device__ inline dstring::~dstring() { deallocate(m_data); } - -__device__ inline dstring& dstring::operator=(dstring const& str) { return assign(str); } - -__device__ inline dstring& dstring::operator=(dstring&& str) { return assign(std::move(str)); } - -__device__ inline dstring& dstring::operator=(cudf::string_view const str) { return assign(str); } - -__device__ inline dstring& dstring::operator=(char const* str) { return assign(str); } - -__device__ dstring& dstring::assign(dstring&& str) -{ - if (this == &str) { return *this; } - m_data = str.m_data; - m_bytes = str.m_bytes; - m_capacity = str.m_capacity; - str.m_data = nullptr; - str.m_bytes = 0; - str.m_capacity = 0; - return *this; -} - -__device__ dstring& dstring::assign(cudf::string_view const str) -{ - return assign(str.data(), str.size_bytes()); -} - -__device__ dstring& dstring::assign(char const* str) -{ - return assign(str, detail::bytes_in_null_terminated_string(str)); -} - -__device__ dstring& dstring::assign(char const* str, cudf::size_type bytes) -{ - if (bytes >= m_capacity) { - deallocate(m_data); - m_capacity = bytes; - m_data = allocate(m_capacity); - } - m_bytes = bytes; - memcpy(m_data, str, bytes); - m_data[m_bytes] = 0; - return *this; -} - -__device__ inline cudf::size_type dstring::size_bytes() const { return m_bytes; } - -__device__ inline cudf::size_type dstring::length() const -{ - return cudf::strings::detail::characters_in_string(m_data, m_bytes); -} - -__device__ cudf::size_type dstring::max_size() const -{ - return std::numeric_limits::max() - 1; -} - -__device__ inline char* dstring::data() { return m_data; } - -__device__ inline char const* dstring::data() const { return m_data; } - -__device__ inline bool dstring::is_empty() const { return m_bytes == 0; } - -__device__ inline bool dstring::is_null() const { return m_data == nullptr; } - -__device__ inline cudf::string_view::const_iterator dstring::begin() const -{ - return cudf::string_view::const_iterator(cudf::string_view(m_data, m_bytes), 0); -} - -__device__ inline cudf::string_view::const_iterator dstring::end() const -{ - return cudf::string_view::const_iterator(cudf::string_view(m_data, m_bytes), length()); -} - -__device__ inline cudf::char_utf8 dstring::at(cudf::size_type pos) const -{ - auto const offset = byte_offset(pos); - auto chr = cudf::char_utf8{0}; - if (offset < m_bytes) { cudf::strings::detail::to_char_utf8(data() + offset, chr); } - return chr; -} - -__device__ inline cudf::char_utf8 dstring::operator[](cudf::size_type pos) const { return at(pos); } - -__device__ inline cudf::size_type dstring::byte_offset(cudf::size_type pos) const -{ - cudf::size_type offset = 0; - - auto sptr = m_data; - auto eptr = sptr + m_bytes; - while ((pos > 0) && (sptr < eptr)) { - auto const byte = static_cast(*sptr++); - auto const char_bytes = cudf::strings::detail::bytes_in_utf8_byte(byte); - if (char_bytes) { --pos; } - offset += char_bytes; - } - return offset; -} - -__device__ inline int dstring::compare(cudf::string_view const in) const -{ - return compare(in.data(), in.size_bytes()); -} - -__device__ inline int dstring::compare(char const* data, cudf::size_type bytes) const -{ - auto const view = static_cast(*this); - return view.compare(data, bytes); -} - -__device__ inline bool dstring::operator==(cudf::string_view const rhs) const -{ - return m_bytes == rhs.size_bytes() && compare(rhs) == 0; -} - -__device__ inline bool dstring::operator!=(cudf::string_view const rhs) const -{ - return compare(rhs) != 0; -} - -__device__ inline bool dstring::operator<(cudf::string_view const rhs) const -{ - return compare(rhs) < 0; -} - -__device__ inline bool dstring::operator>(cudf::string_view const rhs) const -{ - return compare(rhs) > 0; -} - -__device__ inline bool dstring::operator<=(cudf::string_view const rhs) const -{ - int rc = compare(rhs); - return (rc == 0) || (rc < 0); -} - -__device__ inline bool dstring::operator>=(cudf::string_view const rhs) const -{ - int rc = compare(rhs); - return (rc == 0) || (rc > 0); -} - -__device__ inline void dstring::clear() -{ - deallocate(m_data); - m_data = nullptr; - m_bytes = 0; - m_capacity = 0; -} - -__device__ inline void dstring::resize(cudf::size_type count) -{ - if (count > max_size()) { return; } - if (count > m_capacity) { reallocate(count); } - - // add padding if necessary (null chars) - if (count > m_bytes) { memset(m_data + m_bytes, 0, count - m_bytes); } - - m_bytes = count; - m_data[m_bytes] = 0; -} - -__device__ void dstring::reserve(cudf::size_type count) -{ - if (count < max_size() && count > m_capacity) { reallocate(count); } -} - -__device__ cudf::size_type dstring::capacity() const { return m_capacity; } - -__device__ void dstring::shrink_to_fit() -{ - if (m_bytes < m_capacity) { reallocate(m_bytes); } -} - -__device__ inline dstring& dstring::append(char const* str, cudf::size_type in_bytes) -{ - if (in_bytes <= 0) { return *this; } - auto const nbytes = m_bytes + in_bytes; - if (nbytes > m_capacity) { reallocate(2 * nbytes); } - memcpy(m_data + m_bytes, str, in_bytes); - m_bytes = nbytes; - m_data[m_bytes] = 0; - return *this; -} - -__device__ inline dstring& dstring::append(char const* str) -{ - return append(str, detail::bytes_in_null_terminated_string(str)); -} - -__device__ inline dstring& dstring::append(cudf::char_utf8 chr, cudf::size_type count) -{ - if (count <= 0) { return *this; } - auto const char_bytes = cudf::strings::detail::bytes_in_char_utf8(chr) * count; - auto const nbytes = m_bytes + char_bytes; - if (nbytes > m_capacity) { reallocate(2 * nbytes); } - auto out_ptr = m_data + m_bytes; - for (auto idx = 0; idx < count; ++idx) { - out_ptr += cudf::strings::detail::from_char_utf8(chr, out_ptr); - } - m_bytes = nbytes; - m_data[m_bytes] = 0; - return *this; -} - -__device__ inline dstring& dstring::append(cudf::string_view const in) -{ - return append(in.data(), in.size_bytes()); -} - -__device__ inline dstring& dstring::operator+=(cudf::string_view const in) { return append(in); } - -__device__ inline dstring& dstring::operator+=(cudf::char_utf8 chr) { return append(chr); } - -__device__ inline dstring& dstring::operator+=(char const* str) { return append(str); } - -__device__ inline dstring& dstring::insert(cudf::size_type pos, - char const* str, - cudf::size_type in_bytes) -{ - return replace(pos, 0, str, in_bytes); -} - -__device__ inline dstring& dstring::insert(cudf::size_type pos, char const* str) -{ - return insert(pos, str, detail::bytes_in_null_terminated_string(str)); -} - -__device__ inline dstring& dstring::insert(cudf::size_type pos, cudf::string_view const in) -{ - return insert(pos, in.data(), in.size_bytes()); -} - -__device__ inline dstring& dstring::insert(cudf::size_type pos, - cudf::size_type count, - cudf::char_utf8 chr) -{ - return replace(pos, 0, count, chr); -} - -__device__ inline dstring dstring::substr(cudf::size_type pos, cudf::size_type count) const -{ - if (pos < 0) { return dstring{"", 0}; } - auto const spos = byte_offset(pos); - if (spos >= m_bytes) { return dstring{"", 0}; } - auto const epos = count < 0 ? m_bytes : std::min(byte_offset(pos + count), m_bytes); - return dstring{data() + spos, epos - spos}; -} - -// utility for replace() -__device__ void dstring::shift_bytes(cudf::size_type spos, - cudf::size_type epos, - cudf::size_type nbytes) -{ - if (nbytes < m_bytes) { - // shift bytes to the left [...wxyz] -> [wxyzxyz] - auto src = epos; - auto tgt = spos; - while (tgt < nbytes) { m_data[tgt++] = m_data[src++]; } - } else if (nbytes > m_bytes) { - // shift bytes to the right [abcd...] -> [abcabcd] - auto src = m_bytes; - auto tgt = nbytes; - while (src > epos) { m_data[--tgt] = m_data[--src]; } - } -} - -__device__ inline dstring& dstring::replace(cudf::size_type pos, - cudf::size_type count, - char const* str, - cudf::size_type in_bytes) -{ - if (pos < 0 || in_bytes < 0) { return *this; } - auto const spos = byte_offset(pos); - if (spos > m_bytes) { return *this; } - auto const epos = count < 0 ? m_bytes : std::min(byte_offset(pos + count), m_bytes); - - // compute new size - auto const nbytes = m_bytes + in_bytes - (epos - spos); - if (nbytes > m_capacity) { reallocate(2 * nbytes); } - - // move bytes -- make room for replacement - shift_bytes(spos + in_bytes, epos, nbytes); - - // insert the replacement - memcpy(m_data + spos, str, in_bytes); - - m_bytes = nbytes; - m_data[m_bytes] = 0; - return *this; -} - -__device__ inline dstring& dstring::replace(cudf::size_type pos, - cudf::size_type count, - char const* str) -{ - return replace(pos, count, str, detail::bytes_in_null_terminated_string(str)); -} - -__device__ inline dstring& dstring::replace(cudf::size_type pos, - cudf::size_type count, - cudf::string_view const in) -{ - return replace(pos, count, in.data(), in.size_bytes()); -} - -__device__ inline dstring& dstring::replace(cudf::size_type pos, - cudf::size_type count, - cudf::size_type chr_count, - cudf::char_utf8 chr) -{ - if (pos < 0 || chr_count < 0) { return *this; } - auto const spos = byte_offset(pos); - if (spos > m_bytes) { return *this; } - auto const epos = count < 0 ? m_bytes : std::min(byte_offset(pos + count), m_bytes); - - // compute input size - auto const char_bytes = cudf::strings::detail::bytes_in_char_utf8(chr) * chr_count; - // compute new output size - auto const nbytes = m_bytes + char_bytes - (epos - spos); - if (nbytes > m_capacity) { reallocate(2 * nbytes); } - - // move bytes -- make room for the new character(s) - shift_bytes(spos + char_bytes, epos, nbytes); - - // copy chr chr_count times - auto out_ptr = m_data + spos; - for (auto idx = 0; idx < chr_count; ++idx) { - out_ptr += cudf::strings::detail::from_char_utf8(chr, out_ptr); - } - - m_bytes = nbytes; - m_data[m_bytes] = 0; - return *this; -} - -__device__ dstring& dstring::erase(cudf::size_type pos, cudf::size_type count) -{ - return replace(pos, count, nullptr, 0); -} - -__device__ inline cudf::size_type dstring::char_offset(cudf::size_type bytepos) const -{ - return cudf::strings::detail::characters_in_string(data(), bytepos); -} - -} // namespace udf -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp deleted file mode 100644 index 115bc6aca5c..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/dstring.hpp +++ /dev/null @@ -1,521 +0,0 @@ -/* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include - -namespace cudf { -namespace strings { -namespace udf { - -class dstring { - public: - /** - * @brief Represents unknown character position or length. - */ - static constexpr cudf::size_type npos = static_cast(-1); - - /** - * @brief Cast to cudf::string_view operator - */ - __device__ operator cudf::string_view() const { return cudf::string_view(m_data, m_bytes); } - - /** - * @brief Create an empty string. - */ - dstring() = default; - - /** - * @brief Create a string using existing device memory. - * - * The given memory is copied into the instance returned. - * - * @param data Device pointer to UTF-8 encoded string - * @param bytes Number of bytes in `data` - */ - __device__ dstring(char const* data, cudf::size_type bytes); - - /** - * @brief Create a string object from a null-terminated character array. - * - * The given memory is copied into the instance returned. - * - * @param data Device pointer to UTF-8 encoded null-terminated - * character array. - */ - __device__ dstring(char const* data); - - /** - * @brief Create a string object from a cudf::string_view. - * - * The input string data is copied into the instance returned. - * - * @param str String to copy - */ - __device__ dstring(cudf::string_view const str); - - /** - * @brief Create a string object with `count` copies of character `chr`. - * - * @param count Number of times to copy `chr` - * @param chr Character from which to create the string - */ - __device__ dstring(cudf::size_type count, cudf::char_utf8 chr); - - /** - * @brief Create a string object from another instance. - * - * The string data is copied from the `src` into the instance returned. - * - * @param src String to copy - */ - __device__ dstring(dstring const& src); - - /** - * @brief Create a string object from a move reference. - * - * The string data is moved from `src` into the instance returned. - * The `src` will have no content. - * - * @param src String to copy - */ - __device__ dstring(dstring&& src); - - __device__ ~dstring(); - - __device__ dstring& operator=(dstring const&); - __device__ dstring& operator=(dstring&&); - __device__ dstring& operator=(cudf::string_view const); - __device__ dstring& operator=(char const*); - - /** - * @brief Return the number of bytes in this string. - */ - __device__ cudf::size_type size_bytes() const; - - /** - * @brief Return the number of characters in this string. - */ - __device__ cudf::size_type length() const; - - /** - * @brief Return the maximum number of bytes a dstring can hold. - */ - __device__ cudf::size_type max_size() const; - - /** - * @brief Return the internal pointer to the character array for this object. - */ - __device__ char* data(); - __device__ char const* data() const; - - /** - * @brief Returns true if there are no characters in this string. - */ - __device__ bool is_empty() const; - - /** - * @brief Returns true if `data()==nullptr` - * - * This is experimental and may be removed in the futre. - */ - __device__ bool is_null() const; - - /** - * @brief Returns an iterator that can be used to navigate through - * the UTF-8 characters in this string. - * - * This returns a `cudf::string_view::const_iterator` which is read-only. - */ - __device__ cudf::string_view::const_iterator begin() const; - __device__ cudf::string_view::const_iterator end() const; - - /** - * @brief Returns the character at the specified position. - * - * This will return 0 if `pos >= length()`. - * - * @param pos Index position of character to return - * @return Character at position `pos` - */ - __device__ cudf::char_utf8 at(cudf::size_type pos) const; - - /** - * @brief Returns the character at the specified index. - * - * This will return 0 if `pos >= length()`. - * Note this is read-only. Use replace() to modify a character. - * - * @param pos Index position of character to return - * @return Character at position `pos` - */ - __device__ cudf::char_utf8 operator[](cudf::size_type pos) const; - - /** - * @brief Return the byte offset for a given character position. - * - * The byte offset for the character at `pos` such that - * `data() + byte_offset(pos)` points to the memory location - * the character at position `pos`. - * - * @param pos Index position of character to return byte offset. - * @return Byte offset for character at `pos` - */ - __device__ cudf::size_type byte_offset(cudf::size_type pos) const; - - /** - * @brief Comparing target string with this string - * - * @param str Target string to compare with this string - * @return 0 If they compare equal - * <0 Either the value of the first character of this string that does - * not match is ordered before the corresponding character in `str`, - * or all compared characters match but the `str` string is shorter. - * >0 Either the value of the first character of this string that does - * not match is ordered after the corresponding character in `str`, - * or all compared characters match but the `str` string is longer. - */ - __device__ int compare(cudf::string_view const str) const; - - /** - * @brief Comparing target character array with this string - * - * @param str Target array of UTF-8 characters. - * @param bytes Number of bytes in `str`. - * @return 0 If they compare equal - * <0 Either the value of the first character of this string that does - * not match is ordered before the corresponding character in `str`, - * or all compared characters match but `bytes < size_bytes()`. - * >0 Either the value of the first character of this string that does - * not match is ordered after the corresponding character in `str`, - * or all compared characters match but `bytes > size_bytes()`. - */ - __device__ int compare(char const* str, cudf::size_type bytes) const; - - /** - * @brief Returns true if `rhs` matches this string exactly - */ - __device__ bool operator==(cudf::string_view const rhs) const; - - /** - * @brief Returns true if `rhs` does not match this string - */ - __device__ bool operator!=(cudf::string_view const rhs) const; - - /** - * @brief Returns true if this string is ordered before `rhs` - */ - __device__ bool operator<(cudf::string_view const rhs) const; - - /** - * @brief Returns true if `rhs` is ordered before this string - */ - __device__ bool operator>(cudf::string_view const rhs) const; - - /** - * @brief Returns true if this string matches or is ordered before `rhs` - */ - __device__ bool operator<=(cudf::string_view const rhs) const; - - /** - * @brief Returns true if `rhs` matches or is ordered before this string - */ - __device__ bool operator>=(cudf::string_view const rhs) const; - - /** - * @brief Remove all bytes from this string. - * - * All pointers, references, and iterators are invalidated. - */ - __device__ void clear(); - - /** - * @brief Resizes string to contain `count` bytes. - * - * If `count > size_bytes()` then zero-padding is added. - * If `count < size_bytes()` then the string is truncated to size `count`. - * - * All pointers, references, and iterators may be invalidated. - * - * @param count Size in bytes of this string. - */ - __device__ void resize(cudf::size_type count); - - /** - * @brief Reserve `count` bytes in this string. - * - * If `count > capacity()`, new memory is allocated and `capacity()` will - * be greater than or equal to `count`. - * There is no effect if `count <= capacity()`. - * - * @param count Total number of bytes to reserve for this string - */ - __device__ void reserve(cudf::size_type count); - - /** - * @brief Returns the number of bytes that the string has allocated. - */ - __device__ cudf::size_type capacity() const; - - /** - * @brief Reduces internal allocation to just `size_bytes()`. - * - * All pointers, references, and iterators may be invalidated. - */ - __device__ void shrink_to_fit(); - - /** - * @brief Moves the contents of `str` into this string instance - * - * @param str String to move - * @return This string new contents - */ - __device__ dstring& assign(dstring&& str); - - /** - * @brief Replaces the contents of this string with contents of `str` - * - * @param str String to copy - * @return This string new contents - */ - __device__ dstring& assign(cudf::string_view const str); - - /** - * @brief Replaces the contents of this string with contents of `str` - * - * @param str Null-terminated UTF-8 character array - * @return This string new contents - */ - __device__ dstring& assign(char const* str); - - /** - * @brief Replaces the contents of this string with contents of `str` - * - * @param str UTF-8 character array - * @param bytes Number of bytes to copy from `str` - * @return This string new contents - */ - __device__ dstring& assign(char const* str, cudf::size_type bytes); - - /** - * @brief Append a string to the end of this string. - * - * @param str String to append - * @return This string with the appended argument - */ - __device__ dstring& operator+=(cudf::string_view const str); - - /** - * @brief Append a character to the end of this string. - * - * @param str Character to append - * @return This string with the appended argument - */ - __device__ dstring& operator+=(cudf::char_utf8 chr); - - /** - * @brief Append a null-terminated device memory character array - * to the end of this string. - * - * @param str String to append - * @return This string with the appended argument - */ - __device__ dstring& operator+=(char const* str); - - /** - * @brief Append a null-terminated character array to the end of this string. - * - * @param str String to append - * @return This string with the appended argument - */ - __device__ dstring& append(char const* str); - - /** - * @brief Append a character array to the end of this string. - * - * @param str Character array to append - * @param bytes Number of bytes from `str` to append. - * @return This string with the appended argument - */ - __device__ dstring& append(char const* str, cudf::size_type bytes); - - /** - * @brief Append a string to the end of this string. - * - * @param str String to append - * @return This string with the appended argument - */ - __device__ dstring& append(cudf::string_view const str); - - /** - * @brief Append a character to the end of this string - * a specified number of times. - * - * @param chr Character to append - * @param count Number of times to append `chr` - * @return This string with the append character(s) - */ - __device__ dstring& append(cudf::char_utf8 chr, cudf::size_type count = 1); - - /** - * @brief Insert a string into the character position specified. - * - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Character position to begin insert - * @param str String to insert into this one - * @return This string with the inserted argument - */ - __device__ dstring& insert(cudf::size_type pos, cudf::string_view const str); - - /** - * @brief Insert a null-terminated character array into the character position specified. - * - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Character position to begin insert - * @param data Null-terminated character array to insert - * @return This string with the inserted argument - */ - __device__ dstring& insert(cudf::size_type pos, char const* data); - - /** - * @brief Insert a character array into the character position specified. - * - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Character position to begin insert - * @param data Character array to insert - * @param bytes Number of bytes from `data` to insert - * @return This string with the inserted argument - */ - __device__ dstring& insert(cudf::size_type pos, char const* data, cudf::size_type bytes); - - /** - * @brief Insert a character one or more times into the character position specified. - * - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Character position to begin insert - * @param count Number of times to insert `chr` - * @param chr Character to insert - * @return This string with the inserted argument - */ - __device__ dstring& insert(cudf::size_type pos, cudf::size_type count, cudf::char_utf8 chr); - - /** - * @brief Returns a substring of this string. - * - * An empty string is returned if `pos < 0 or pos >= length()`. - * - * @param pos Character position to start the substring - * @param count Number of characters for the substring; - * This can be greater than the number of available characters. - * Default npos returns characters in range `[pos, length())`. - * @return New string with the specified characters - */ - __device__ dstring substr(cudf::size_type pos, cudf::size_type count = npos) const; - - /** - * @brief Replace a range of characters with a given string. - * - * Replaces characters in range `[pos, pos + count]` with `str`. - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Position of first character to replace - * @param count Number of characters to replace - * @param str String to replace the given range - * @return This string modified with the replacement - */ - __device__ dstring& replace(cudf::size_type pos, - cudf::size_type count, - cudf::string_view const str); - - /** - * @brief Replace a range of characters with a null-terminated character array. - * - * Replaces characters in range `[pos, pos + count)` with `data`. - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Position of first character to replace - * @param count Number of characters to replace - * @param data Null-terminated character array to replace the given range - * @return This string modified with the replacement - */ - __device__ dstring& replace(cudf::size_type pos, cudf::size_type count, char const* data); - - /** - * @brief Replace a range of characters with a given character array. - * - * Replaces characters in range `[pos, pos + count)` with `[data, data + bytes)`. - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Position of first character to replace - * @param count Number of characters to replace - * @param data String to replace the given range - * @param bytes Number of bytes from data to use for replacement - * @return This string modified with the replacement - */ - __device__ dstring& replace(cudf::size_type pos, - cudf::size_type count, - char const* data, - cudf::size_type bytes); - - /** - * @brief Replace a range of characters with a character one or more times. - * - * Replaces characters in range `[pos, pos + count)` with `chr` `chr_count` times. - * There is no effect if `pos < 0 or pos > length()`. - * - * @param pos Position of first character to replace - * @param count Number of characters to replace - * @param chr_count Number of times `chr` will repeated - * @param chr Character to use for replacement - * @return This string modified with the replacement - */ - __device__ dstring& replace(cudf::size_type pos, - cudf::size_type count, - cudf::size_type chr_count, - cudf::char_utf8 chr); - - /** - * @brief Removes specified characters from this string. - * - * Removes `min(count, length() - pos)` characters starting at `pos`. - * There is no effect if `pos < 0 or pos >= length()`. - * - * @param pos Character position to begin insert - * @param count Number of characters to remove starting at `pos` - * @return This string with remove characters - */ - __device__ dstring& erase(cudf::size_type pos, cudf::size_type count = npos); - - private: - char* m_data{}; - cudf::size_type m_bytes{}; - cudf::size_type m_capacity{}; - - // utilities - __device__ char* allocate(cudf::size_type bytes); - __device__ void deallocate(char* data); - __device__ void reallocate(cudf::size_type bytes); - __device__ cudf::size_type char_offset(cudf::size_type bytepos) const; - __device__ void shift_bytes(cudf::size_type spos, cudf::size_type epos, cudf::size_type nbytes); -}; - -} // namespace udf -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index 2863ace6fdd..f1fe03dc29f 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -16,7 +16,6 @@ */ #pragma once -#include "dstring.cuh" #include @@ -58,24 +57,6 @@ __device__ inline cudf::size_type count(string_view const source, return count; } -/** - * @brief Returns the number of times that the target string appears - * in the source string. - * - * @param source String to search - * @param target Null-terminated string to match within source - * @param start First character position within source to start the search - * @param end Last character position (exclusive) within source to search - * @return Number of matches - */ -__device__ inline cudf::size_type count(string_view const source, - char const* target, - cudf::size_type start = 0, - cudf::size_type end = -1) -{ - return count( - source, cudf::string_view{target, detail::bytes_in_null_terminated_string(target)}, start, end); -} } // namespace udf } // namespace strings diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/split.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/split.cuh deleted file mode 100644 index 4b79ecf8bb9..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/split.cuh +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "../split/split_utils.cuh" -#include "dstring.cuh" - -#include - -namespace cudf { -namespace strings { -namespace udf { - -/** - * @brief Split string using given string. - * - * @code{.cpp} - * auto d_str = cudf::string_view{"the best of times ", 19}; - * auto tgt = cudf::string_view{}; // empty string - * auto token_count = split(d_str, tgt, nullptr); - * auto result = new cudf::string_view[token_count]; - * split(d_str, tgt, result); - * // result is array like ["the", "best", "of", "times"] - * @endcode - * - * @param d_str String to split - * @param tgt String to split on - * @param result Empty array to populate with output objects. - * Pass `nullptr` to just get the token count. - * @return Number of tokens returned - */ -__device__ inline cudf::size_type split(cudf::string_view const d_str, - cudf::string_view const tgt, - cudf::string_view* result) -{ - auto const nchars = d_str.length(); - cudf::size_type count = 0; - - cudf::size_type last_pos = 0; - while (last_pos <= nchars) { - cudf::size_type const pos = d_str.find(tgt, last_pos); - auto const length = (pos < 0 ? nchars : pos) - last_pos; - if (result) { *result++ = d_str.substr(last_pos, length); } - last_pos = pos + tgt.length(); - ++count; - if (pos < 0) { break; } - } - - return count; -} - -/** - * @brief Split string using given target array. - * - * @param d_str String to split - * @param tgt Character array encoded in UTF-8 used for identifying split points - * @param bytes Number of bytes to read from `tgt` - * @param result Empty array to populate with output objects. - * Pass `nullptr` to just get the token count. - * @return Number of tokens returned - */ -__device__ inline int split(cudf::string_view const d_str, - char const* tgt, - cudf::size_type bytes, - cudf::string_view* result) -{ - return split(d_str, cudf::string_view{tgt, bytes}, result); -} - -/** - * @brief Split string using given target array. - * - * @param d_str String to split - * @param tgt Null-terminated character array encoded in UTF-8 used for identifying split points - * @param result Empty array to populate with output objects. - * Pass `nullptr` to just get the token count. - * @return Number of tokens returned - */ -__device__ inline int split(cudf::string_view const d_str, - char const* tgt, - cudf::string_view* result) -{ - return split(d_str, tgt, detail::bytes_in_null_terminated_string(tgt), result); -} - -/** - * @brief Split string on whitespace. - * - * This will create tokens by splitting on one or more consecutive whitespace characters - * found in `d_str`. - * - * @param d_str String to split - * @param result Empty array to populate with output objects. - * Pass `nullptr` to just get the token count. - * @return Number of tokens returned - */ -__device__ inline cudf::size_type split(cudf::string_view const d_str, cudf::string_view* result) -{ - cudf::strings::detail::whitespace_string_tokenizer tokenizer{d_str}; - cudf::size_type count = 0; - while (tokenizer.next_token()) { - auto token = tokenizer.get_token(); - if (result) { *result++ = d_str.substr(token.first, token.second - token.first); } - ++count; - } - return count; -} - -/** - * @brief Join an array of strings with a separator. - * - * @code{.cpp} - * auto separator = cudf::string_view{"::", 2}; - * cudf::string_view input[] = { - * cudf::string_view{"hello", 5}, - * cudf::string_view{"goodbye", 7}, - * cudf::string_view{"world", 5} }; - * - * auto result = join(separator, input, 3); - * // result is "hello::goodbye::world" - * @endcode - * - * @param separator Separator string - * @param input An array of strings to join - * @param count Number of elements in `input` - * @return New string - */ -__device__ inline dstring join(cudf::string_view const separator, - cudf::string_view* input, - cudf::size_type count) -{ - dstring result{""}; - while (count-- > 0) { - result += *input++; - if (count > 0) { result += separator; } - } - return result; -} - -/** - * @brief Join an array of strings with a separator. - * - * @param separator Null-terminated UTF-8 string - * @param bytes Number of bytes to read from `separator` - * @param input An array of strings to join - * @param count Number of elements in `input` - * @return New string - */ -__device__ inline dstring join(char const* separator, - cudf::size_type bytes, - cudf::string_view* input, - cudf::size_type count) -{ - return join(cudf::string_view{separator, bytes}, input, count); -} - -/** - * @brief Join an array of strings with a separator. - * - * @param separator Null-terminated UTF-8 string - * @param input An array of strings to join - * @param count Number of elements in `input` - * @return New string - */ -__device__ inline dstring join(char const* separator, - cudf::string_view* input, - cudf::size_type count) -{ - return join(separator, detail::bytes_in_null_terminated_string(separator), input, count); -} - -} // namespace udf -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh index c5a7f24563a..73374d64ae5 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh @@ -16,8 +16,6 @@ #pragma once -#include "dstring.cuh" - #include namespace cudf { @@ -42,19 +40,6 @@ __device__ inline bool starts_with(cudf::string_view const dstr, return start_str.compare(tgt, bytes) == 0; } -/** - * @brief Returns true if the beginning of the specified string - * matches the given character array. - * - * @param dstr String to check - * @param tgt Null-terminated character array encoded in UTF-8 - * @return true if `tgt` matches the beginning of `dstr` - */ -__device__ inline bool starts_with(cudf::string_view const dstr, char const* tgt) -{ - return starts_with(dstr, tgt, detail::bytes_in_null_terminated_string(tgt)); -} - /** * @brief Returns true if the beginning of the specified string * matches the given target string. @@ -86,18 +71,6 @@ __device__ inline bool ends_with(cudf::string_view const dstr, return end_str.compare(tgt, bytes) == 0; } -/** - * @brief Returns true if the end of the specified string - * matches the given character array. - * - * @param dstr String to check - * @param tgt Null-terminated character array encoded in UTF-8 - * @return true if `tgt` matches the end of `dstr` - */ -__device__ inline bool ends_with(cudf::string_view const dstr, char const* tgt) -{ - return ends_with(dstr, tgt, detail::bytes_in_null_terminated_string(tgt)); -} /** * @brief Returns true if the end of the specified string diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp deleted file mode 100644 index ec4522d8962..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include - -#include -#include -#include - -// somewhat iffy forward reference -namespace jitify { -class Program; -} - -/** - * @brief Module instance returned by create_udf_module - */ -struct udf_module { - jitify::Program *program{}; - udf_module(jitify::Program *p) : program(p) {} - ~udf_module(); -}; - -/** - * @brief Build UDF module with kernel source and compile options. - * - * @param udf String containing kernel source code - * @param options Compile options for the jitify compiler - * @return udf module to pass to `call_udf` - */ -std::unique_ptr create_udf_module(std::string const &udf, - std::vector const &options); - -/** - * @brief Launch kernel named `udf_name` in UDF module. - * - * @param udf Returned from `create_udf_module` - * @param udf_name Name of global device function to execute in UDF module - * @param output_size Output strings column size. - * Also used to computing the thread block size. - * @param input libcudf columns to pass to the kernel - * @param heap_size Size in bytes to reserve for device-side malloc. - * @return New libcudf strings column created by the kernel logic. - */ -std::unique_ptr call_udf(udf_module const &udf, - std::string const &udf_name, - cudf::size_type output_size, - std::vector input, - size_t heap_size = 1073741824); - -/** - * @brief Return a cudf::string_view array for the given strings column - * - * @throw cudf::logic_error if input is not a strings column. - */ -std::unique_ptr to_string_view_array(cudf::column_view const input); - -/** - * @brief Return a cudf::column given an array of dstring objects. - * - * @param d_buffer Pointer to device memory of dstring objects - * @param d_size The number of bytes in the d_buffer - * @return A strings column copy of the dstring objects - */ -std::unique_ptr from_dstring_array(void *d_buffer, std::size_t size); - diff --git a/python/strings_udf/cpp/sample_udfs/copy.udf b/python/strings_udf/cpp/sample_udfs/copy.udf deleted file mode 100644 index 1bbf5743f18..00000000000 --- a/python/strings_udf/cpp/sample_udfs/copy.udf +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -// This illustrates a simple copy of the input. -// The input string_view object is converted to a dstring and returned. - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid < count ) - { - d_out_strs[tid] = d_in_strs[tid]; - } -} diff --git a/python/strings_udf/cpp/sample_udfs/example.txt b/python/strings_udf/cpp/sample_udfs/example.txt deleted file mode 100644 index 37e10de75b9..00000000000 --- a/python/strings_udf/cpp/sample_udfs/example.txt +++ /dev/null @@ -1,5 +0,0 @@ -Example text: -"Pears £12" -"Plums $34" -"Temp 72℉" -"100K℧" diff --git a/python/strings_udf/cpp/sample_udfs/example.xml b/python/strings_udf/cpp/sample_udfs/example.xml deleted file mode 100644 index f8a0e2d42fd..00000000000 --- a/python/strings_udf/cpp/sample_udfs/example.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/python/strings_udf/cpp/sample_udfs/filter.udf b/python/strings_udf/cpp/sample_udfs/filter.udf deleted file mode 100644 index 1cd781c9bb1..00000000000 --- a/python/strings_udf/cpp/sample_udfs/filter.udf +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -// -// Example text: -// "pears £12" -// "plums $34" -// "Temp 72℉" -// "100K℧" -// -// Output from this udf: -// "pears 12" -// "plums 34" -// "Temp 72 " -// "100K " -// - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid >= count ) return; - - cudf::string_view str = d_in_strs[tid]; - char const* sptr = str.data(); - char const* eptr = sptr + str.size_bytes(); - - cudf::strings::udf::dstring out; - while( sptr < eptr ) - { - char ch = *sptr++; - if( ((ch < '0') || (ch > 'z')) || - ((ch > '9') && (ch < 'A')) || - ((ch > 'Z') && (ch < 'a')) ) - out.append(' '); - else - out.append(ch); - } - d_out_strs[tid] = out; -} - diff --git a/python/strings_udf/cpp/sample_udfs/integers.udf b/python/strings_udf/cpp/sample_udfs/integers.udf deleted file mode 100644 index bd9018da99f..00000000000 --- a/python/strings_udf/cpp/sample_udfs/integers.udf +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -using dstring = cudf::strings::udf::dstring; - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid < count ) - { - auto input = d_in_strs[tid]; - auto end = input.substr( input.length()-2, 2 ); - auto value = cudf::strings::udf::stoi(end); - dstring out = cudf::strings::udf::to_string(value); - d_out_strs[tid] = out; - } -} diff --git a/python/strings_udf/cpp/sample_udfs/join.udf b/python/strings_udf/cpp/sample_udfs/join.udf deleted file mode 100644 index 8cc68f3a575..00000000000 --- a/python/strings_udf/cpp/sample_udfs/join.udf +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -// -// Example input string: -// "peaches 12" -// -// Splits on ' ' space to get array like: -// ['peaches', '12'] -// -// Joins with ':::' to get a final string: -// "peaches:::12" -// - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid >= count ) return; - - cudf::string_view str = d_in_strs[tid]; - cudf::string_view entries[2]; // 2 is the max split for the example - - // split on whitespace - auto splits = cudf::strings::udf::split( str, entries ); - - // join with new separator - cudf::string_view separator(":::", 3); - auto out = cudf::strings::udf::join(separator, entries, splits); - - d_out_strs[tid] = out; -} - diff --git a/python/strings_udf/cpp/sample_udfs/lower.udf b/python/strings_udf/cpp/sample_udfs/lower.udf deleted file mode 100644 index fe558ee2ac5..00000000000 --- a/python/strings_udf/cpp/sample_udfs/lower.udf +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -using dstring = cudf::strings::udf::dstring; - -// supports lower-case conversion for ASCII characters only -__device__ dstring to_lower_a(cudf::string_view const d_str) -{ - dstring result = d_str; - // ASCII case conversion can be done in-place - auto ptr = result.data(); - auto end = ptr + result.size_bytes(); - while( ptr < end ) { - auto chr = *ptr; - if( chr >= 'A' && chr <= 'Z' ) - chr = chr + 32; // lower-case in the ASCII table - *ptr++ = chr; - } - return result; -} - -// supports upper-case conversion for ASCII characters only -__device__ dstring to_upper_a(cudf::string_view const d_str) -{ - dstring result = d_str; - // ASCII case conversion can be done in-place - auto ptr = result.data(); - auto end = ptr + result.size_bytes(); - while( ptr < end ) { - auto chr = *ptr; - if( chr >= 'a' && chr <= 'z' ) - chr = chr - 32; // upper-case in the ASCII table - *ptr++ = chr; - } - return result; -} - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid < count ) - { - dstring out = to_lower_a(d_in_strs[tid]); - // dstring out = to_upper_a(d_in_strs[tid]); - d_out_strs[tid] = out; - } -} diff --git a/python/strings_udf/cpp/sample_udfs/print.udf b/python/strings_udf/cpp/sample_udfs/print.udf deleted file mode 100644 index 0bf2c696d7f..00000000000 --- a/python/strings_udf/cpp/sample_udfs/print.udf +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -using dstring = cudf::strings::udf::dstring; - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid < count ) - { - dstring str = d_in_strs[tid]; - printf("%d:[%s]\n", tid, str.data()); - d_out_strs[tid] = str; - } -} diff --git a/python/strings_udf/cpp/sample_udfs/split.udf b/python/strings_udf/cpp/sample_udfs/split.udf deleted file mode 100644 index a27166265e0..00000000000 --- a/python/strings_udf/cpp/sample_udfs/split.udf +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -// -// Example input string: -// -// -// Splits on ' ' space to get array like: -// [''] -// -// Splits each try on '=' to find the one with 'name': -// ['name', '"Ted"'] -// -// Finally, splits the value to remove the double-quotes: -// ['"', 'Ted', '"'] --> output is element 1 -// - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid >= count ) return; - - cudf::string_view str = d_in_strs[tid]; - cudf::string_view entries[5]; // 5 is the max split for the example - - // first, split on whitespace - auto splits = cudf::strings::udf::split( str, entries ); - - cudf::strings::udf::dstring out{""}; // empty if name is not found - - cudf::string_view name("name", 4); - for( int idx=1; idx < splits; ++idx ) { - cudf::string_view attrs[2]; // looking for 'name="value"' - cudf::strings::udf::split( entries[idx], "=", attrs ); - if( attrs[0] == name ) { - // extract value from the double-quotes - cudf::string_view values[3]; - cudf::strings::udf::split( attrs[1], "\"", values ); - out = values[1]; // actual name is entry 1 - } - } - - d_out_strs[tid] = out; -} - diff --git a/python/strings_udf/cpp/sample_udfs/starts_with.udf b/python/strings_udf/cpp/sample_udfs/starts_with.udf deleted file mode 100644 index 09a4e424261..00000000000 --- a/python/strings_udf/cpp/sample_udfs/starts_with.udf +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid < count ) - { - auto const d_str = d_in_strs[tid]; - cudf::strings::udf::dstring d_out = d_str; - if( cudf::strings::udf::ends_with(d_str, "/>") ) - d_out += " <------- entry"; - else if( cudf::strings::udf::ends_with(d_str, "/>") ) - d_out += " <------- last entry"; - if( cudf::strings::udf::starts_with(d_str, " - -using dstring = cudf::strings::udf::dstring; - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid < count ) - { - dstring out = cudf::strings::udf::strip(d_in_strs[tid]); - out.insert(0,"["); - out.append("]"); - d_out_strs[tid] = out; - } -} diff --git a/python/strings_udf/cpp/sample_udfs/xml.udf b/python/strings_udf/cpp/sample_udfs/xml.udf deleted file mode 100644 index 52fdb5112d3..00000000000 --- a/python/strings_udf/cpp/sample_udfs/xml.udf +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -__device__ cudf::string_view find_attr( cudf::string_view const& input, - cudf::string_view const& name ) -{ - auto pos = input.find(name); - if( pos < 0 ) return cudf::string_view{"",0}; - - cudf::string_view quote("\"",1); - auto begin = input.find(quote, pos) + 1; - auto end = input.find(quote, begin); - - return input.substr(begin, end-begin); -} - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid >= count ) return; - - auto input_str = d_in_strs[tid]; - - auto name = find_attr(input_str, cudf::string_view("name",4)); - - d_out_strs[tid] = name; // makes a copy here -} diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu index ec12d9be1d0..774b1c7fd36 100644 --- a/python/strings_udf/cpp/src/strings/udf/shim.cu +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -14,7 +14,6 @@ * limitations under the License. */ -#include #include #include #include diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu deleted file mode 100644 index 7189557ec42..00000000000 --- a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "jitify.hpp" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -namespace { - -rmm::device_buffer create_dstring_array(cudf::size_type size, rmm::cuda_stream_view stream) -{ - auto const output_vector_size = size * sizeof(cudf::strings::udf::dstring); - rmm::device_buffer result(output_vector_size, stream); - cudaMemset(result.data(), 0, output_vector_size); - return result; -} - -struct free_dstring_fn { - cudf::strings::udf::dstring *d_strings; - __device__ void operator()(cudf::size_type idx) { d_strings[idx].clear(); } -}; - -void free_dstring_array(void *d_buffer, std::size_t buffer_size, rmm::cuda_stream_view stream) -{ - auto const size = static_cast(buffer_size / sizeof(cudf::strings::udf::dstring)); - auto d_strings = reinterpret_cast(d_buffer); - thrust::for_each_n( - rmm::exec_policy(stream), thrust::make_counting_iterator(0), size, free_dstring_fn{d_strings}); -} - -void set_malloc_heap_size(size_t heap_size) -{ - size_t max_malloc_heap_size = 0; - cudaDeviceGetLimit(&max_malloc_heap_size, cudaLimitMallocHeapSize); - if (max_malloc_heap_size < heap_size) { - max_malloc_heap_size = heap_size; - if (cudaDeviceSetLimit(cudaLimitMallocHeapSize, max_malloc_heap_size) != cudaSuccess) { - fprintf(stderr, "could not set malloc heap size to %ldMB\n", (heap_size / (1024 * 1024))); - throw std::runtime_error(""); - } - } -} - -struct dstring_to_string_view_transform_fn { - __device__ cudf::string_view operator()(cudf::strings::udf::dstring const &dstr) - { - return cudf::string_view{dstr.data(), dstr.size_bytes()}; - } -}; - -} // namespace - -static jitify::JitCache kernel_cache; - -std::unique_ptr create_udf_module(std::string const &udf_code, - std::vector const &options) -{ - std::vector jitify_options; - jitify_options.push_back("-std=c++17"); - jitify_options.push_back("-DCUDF_JIT_UDF"); - jitify_options.push_back("-I../include"); - jitify_options.push_back("-I../cpp/include"); - std::copy(options.begin(), options.end(), std::back_inserter(jitify_options)); - // nvrtc did not recognize --expt-relaxed-constexpr - // also it has trouble including thrust headers - - try { - auto program = kernel_cache.program(udf_code.c_str(), 0, jitify_options); - return std::make_unique(new jitify::Program(std::move(program))); - } catch (std::runtime_error &exc) { - return nullptr; - } -} - -udf_module::~udf_module() { delete program; } - -namespace { - -using column_span = std::pair; - -struct udf_data_fn { - cudf::column_view const input; - - template ()> * = nullptr> - column_span operator()(std::vector> &) - { - return std::make_pair((void *)input.data(), input.size()); - } - - template > * = nullptr> - column_span operator()(std::vector> &strings_vectors) - { - auto sv = - cudf::strings::detail::create_string_vector_from_column(cudf::strings_column_view(input)); - strings_vectors.emplace_back(std::move(sv)); - auto const &sv_ref = strings_vectors.back(); - return std::make_pair((void *)sv_ref.data(), (cudf::size_type)sv_ref.size()); - } - - template ::value and - !cudf::is_fixed_width()> * = nullptr> - column_span operator()(std::vector> &) - { - return column_span{nullptr, 0}; // throw error here? - } -}; - -std::unique_ptr to_string_view_array(cudf::column_view const input, - rmm::cuda_stream_view stream) -{ - return std::make_unique( - std::move(cudf::strings::detail::create_string_vector_from_column( - cudf::strings_column_view(input), stream) - .release())); -} - -std::unique_ptr from_dstring_array(void *d_buffer, - std::size_t buffer_size, - rmm::cuda_stream_view stream) -{ - auto const size = static_cast(buffer_size / sizeof(cudf::strings::udf::dstring)); - auto d_input = reinterpret_cast(d_buffer); - - // create string_views of the dstrings - auto indices = rmm::device_uvector(size, stream); - thrust::transform(rmm::exec_policy(stream), - d_input, - d_input + size, - indices.data(), - dstring_to_string_view_transform_fn{}); - - auto results = cudf::make_strings_column(indices, cudf::string_view(nullptr, 0), stream); - - // free the individual dstring elements - free_dstring_array(d_buffer, buffer_size, stream); - - // return new column - return results; -} - -template -void set_global_variables(KernelType &kernel) -{ - try { - // set global variable data needed for the is-char-type functions - if (kernel.get_global_ptr("cudf::strings::udf::g_character_flags_table")) { - auto flags_table = cudf::strings::detail::get_character_flags_table(); - kernel.set_global_array("cudf::strings::udf::g_character_flags_table", &flags_table, 1); - } - } catch (...) { - // this global variable is optional - } - try { - // set global variable data needed for upper/lower functions - if (kernel.get_global_ptr("cudf::strings::udf::g_character_cases_table")) { - auto cases_table = cudf::strings::detail::get_character_cases_table(); - kernel.set_global_array("cudf::strings::udf::g_character_cases_table", &cases_table, 1); - } - if (kernel.get_global_ptr("cudf::strings::udf::g_special_case_mapping_table")) { - auto special_cases_table = cudf::strings::detail::get_special_case_mapping_table(); - kernel.set_global_array( - "cudf::strings::udf::g_special_case_mapping_table", &special_cases_table, 1); - } - } catch (...) { - // these global variables are optional - } -} - -} // namespace - -std::unique_ptr call_udf(udf_module const &udf, - std::string const &udf_name, - cudf::size_type output_size, - std::vector input, - size_t heap_size) -{ - set_malloc_heap_size(heap_size); - - rmm::cuda_stream_view stream = rmm::cuda_stream_default; - - // setup kernel parameters - std::vector> strings_vectors; // for strings columns - std::vector args; // holds column pointers and sizes; - jitify::detail::vector arg_types; // this parameter is not strictly required - // create args for each input column - for (int col = 0; col < (int)input.size(); ++col) { - column_span data = cudf::type_dispatcher( - input[col].type(), udf_data_fn{input[col]}, strings_vectors); - args.push_back(data.first); - arg_types.push_back(jitify::reflection::reflect()); - args.push_back((void *)(long)data.second); - arg_types.push_back(jitify::reflection::reflect()); - } - // transform required because jit launch() args are expected to be pointers to pointers - std::vector jitargs; - std::transform( - args.begin(), args.end(), std::back_inserter(jitargs), [](auto &pv) { return &pv; }); - - // allocate an output array - rmm::device_buffer output = create_dstring_array(output_size, stream); - - // add the output strings column parameter - void *d_out = output.data(); - jitargs.push_back(&d_out); - arg_types.push_back(jitify::reflection::reflect()); - // add the kernel thread count parameter - jitargs.push_back(reinterpret_cast(&output_size)); - arg_types.push_back(jitify::reflection::reflect()); - - // setup kernel launch parameters - auto const num_blocks = ((output_size - 1) / 128) + 1; - dim3 grid(num_blocks); - dim3 block(128); - - jitify::Program *pp = udf.program; - auto kernel = pp->kernel(udf_name.c_str()).instantiate(); - set_global_variables(kernel); - auto launcher = kernel.configure(grid, block); - // launch the kernel passing the parameters - CUresult result = launcher.launch(jitargs, arg_types); - if (result) { - const char *result_str = "ok"; - cuGetErrorName(result, &result_str); - fprintf(stderr, "launch result = %d [%s]\n", (int)result, result_str); - } - auto const err = cudaDeviceSynchronize(); - if (err) { fprintf(stderr, "%s=(%d) ", udf_name.c_str(), (int)err); } - - // convert the output array into a strings column - // this also frees the individual dstring objects - return from_dstring_array(output.data(), output.size(), stream); -} - -std::unique_ptr to_string_view_array(cudf::column_view const input) -{ - return to_string_view_array(input, rmm::cuda_stream_default); -} - -std::unique_ptr from_dstring_array(void *d_buffer, std::size_t buffer_size) -{ - return from_dstring_array(d_buffer, buffer_size, rmm::cuda_stream_default); -} diff --git a/python/strings_udf/cpp/src/strings/udf/udf_cli.cpp b/python/strings_udf/cpp/src/strings/udf/udf_cli.cpp deleted file mode 100644 index 02422a57abb..00000000000 --- a/python/strings_udf/cpp/src/strings/udf/udf_cli.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -double GetTime() -{ - timeval tv; - gettimeofday(&tv, NULL); - return (double)(tv.tv_sec * 1000000 + tv.tv_usec) / 1000000.0; -} - -std::string load_udf(std::ifstream &input) -{ - std::stringstream udf; - std::string line; - while (std::getline(input, line)) udf << line << "\n"; - return udf.str(); -} - -void print_column(cudf::strings_column_view const &input) -{ - if (input.chars_size() == 0) { - printf("empty\n"); - return; - } - - auto offsets = input.offsets(); - std::vector h_offsets(offsets.size()); - auto chars = input.chars(); - std::vector h_chars(chars.size()); - cudaMemcpy(h_offsets.data(), - offsets.data(), - offsets.size() * sizeof(int32_t), - cudaMemcpyDeviceToHost); - cudaMemcpy(h_chars.data(), chars.data(), chars.size(), cudaMemcpyDeviceToHost); - - for (int idx = 0; idx < input.size(); ++idx) { - int offset = h_offsets[idx]; - const char *str = h_chars.data() + offset; - int length = h_offsets[idx + 1] - offset; - std::string output(str, length); - std::cout << output << "\n"; - } -} - -std::map parse_cli_parms(int argc, const char **argv) -{ - std::map parms; - while (argc > 1) { - const char *value = argv[argc - 1]; - const char *key = (argv[argc - 2]) + 1; - parms[key] = value; - argc -= 2; - } - return parms; -} - -int main(int argc, const char **argv) -{ - if (argc < 3) { - printf("parameters:\n"); - printf("-u UDF text file\n"); - printf("-n kernel name (default is 'udf_kernel')\n"); - printf("-i libcudf include dir (default is $CONDA_PREFIX/include)\n"); - printf("-t text/csv file\n"); - printf("-c 0-based column number if csv file (default is 0=first column)\n"); - printf("-r number of rows to read from file (default is 0=entire file)\n"); - printf("-f output file (default is stdout)\n"); - printf("-m malloc heap size (default is 1GB)\n"); - return 0; - } - - std::map parms = parse_cli_parms(argc, argv); - - std::string const udf_text = parms["u"]; - std::string const csv_file = parms["t"]; - if (udf_text.empty() || csv_file.empty()) { - printf("UDF file (-u) and text file (-t) are required parameters.\n"); - return 0; - } - - std::string const cudf_include = [parms] { - if (parms.find("i") != parms.end()) return parms.at("i"); - std::string conda_prefix = - std::getenv("CONDA_PREFIX") ? std::getenv("CONDA_PREFIX") : "/conda/envs/rapids"; - return conda_prefix + "/include"; - }(); - - std::string const udf_name = parms.find("n") != parms.end() ? parms["n"] : "udf_kernel"; - - int const column = parms.find("c") != parms.end() ? std::atoi(parms["c"].c_str()) : 0; - int const rows = parms.find("r") != parms.end() ? std::atoi(parms["r"].c_str()) : 0; - auto const verbose = parms.find("v") != parms.end(); - size_t const heap_size = - (parms.find("m") != parms.end() ? std::atoi(parms["m"].c_str()) : 1024) * 1024 * 1024; - - // load the udf source code - std::ifstream udf_stream(udf_text); - if (!udf_stream.is_open()) { - printf("could not open file [%s]\n", udf_text.c_str()); - return 0; - } - std::string udf_code = load_udf(udf_stream); - // adding the filename to the top of the source code - // helps with jitify displaying compile errors - udf_code = udf_text + "\n" + udf_code; - - // load the text file using the CSV reader - double st_load_data = GetTime(); - cudf::io::csv_reader_options in_opts = - cudf::io::csv_reader_options::builder(cudf::io::source_info{csv_file}).header(-1); - in_opts.set_use_cols_indexes({column}); - if (rows > 0) in_opts.set_nrows(rows); - in_opts.set_dtypes({cudf::data_type{cudf::type_id::STRING}}); - auto csv_result = cudf::io::read_csv(in_opts); - auto input = cudf::strings_column_view(csv_result.tbl->view().column(0)); - - double et_load_data = GetTime() - st_load_data; - if (verbose) fprintf(stderr, "Load data: %g seconds\n", et_load_data); - - auto const strings_count = input.size(); - if (verbose) fprintf(stderr, "input strings count = %d\n", strings_count); - - // create UDF module - std::vector options; - options.push_back("-I" + cudf_include); - double st_compile = GetTime(); - auto module = create_udf_module(udf_code, options); - double et_compile = GetTime() - st_compile; - if (module == nullptr || module->program == nullptr) { - printf("compile error\n"); - return 0; - } - if (verbose) fprintf(stderr, "Compile UDF: %g seconds\n", et_compile); - - // run UDF module - double st_run = GetTime(); - auto results = call_udf(*module, udf_name, strings_count, {input.parent()}, heap_size); - double et_run = GetTime() - st_run; - if (verbose) fprintf(stderr, "Run UDF: %g seconds\n", et_run); - - auto scv = cudf::strings_column_view(results->view()); - // output results - std::string out_filename = parms["f"]; - if (out_filename.empty()) { - print_column(scv); - return 0; - } - - // write csv file - double st_output_data = GetTime(); - auto output_table = cudf::table_view{std::vector{results->view()}}; - cudf::io::sink_info const sink{out_filename}; - cudf::io::csv_writer_options writer_options = - cudf::io::csv_writer_options::builder(sink, output_table).include_header(false); - cudf::io::write_csv(writer_options); - double et_output_data = GetTime() - st_output_data; - - if (verbose) fprintf(stderr, "Output to file: %g seconds\n", et_output_data); - - return 0; -} diff --git a/python/strings_udf/cpp/tests/append.udf b/python/strings_udf/cpp/tests/append.udf deleted file mode 100644 index 1159a145bc1..00000000000 --- a/python/strings_udf/cpp/tests/append.udf +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const hello = cudf::string_view{"hello", 5}; - auto const hello_space = cudf::string_view{"hello ", 6}; - auto const world = cudf::string_view{"world", 5}; - auto const hello_world = cudf::string_view{"hello world", 11}; - - dstring d_str; - - d_str.append("hello"); - verify(d_str, hello, "append(char*)"); - - d_str.append(' '); - verify(d_str, hello_space, "append(char)"); - - d_str.append(world); - verify(d_str, hello_world, "append(string_view)"); - - d_str.append(" goodbye", 5); - verify(d_str, cudf::string_view{"hello world good", 16}, "append(char*,size)"); - - d_str.clear(); - - d_str += "hello"; - verify(d_str, hello, "operator+=(char*)"); - - d_str += ' '; - verify(d_str, hello_space, "operator+=(char)"); - - d_str += world; - verify(d_str, hello_world, "operator+=(string_view)"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/char_types.udf b/python/strings_udf/cpp/tests/char_types.udf deleted file mode 100644 index bd73c6cbe7e..00000000000 --- a/python/strings_udf/cpp/tests/char_types.udf +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -namespace cudf::strings::udf { -// global variable with character-type flags -__device__ cudf::strings::detail::character_flags_table_type* g_character_flags_table; -} - -using namespace cudf::strings; - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - auto const alpha = cudf::string_view{"Hello", 5}; - auto const alpha_num = cudf::string_view{"Hello123", 8}; - auto const numeric = cudf::string_view{"17¼", 4}; - auto const digit = cudf::string_view{"2³", 3}; - auto const decimal = cudf::string_view{"156789", 6}; - auto const space = cudf::string_view{" \t\n\r", 4}; - auto const upper = cudf::string_view{"123XYZ", 6}; - auto const lower = cudf::string_view{"xyz123", 6}; - - check_result(udf::is_alpha(udf::g_character_flags_table, alpha), "alpha"); - check_result(!udf::is_alpha(udf::g_character_flags_table, alpha_num), "!alpha"); - - check_result(udf::is_alpha_numeric(udf::g_character_flags_table, alpha_num), "alpha_num"); - check_result(!udf::is_alpha_numeric(udf::g_character_flags_table, space), "!alpha_num"); - - check_result(udf::is_numeric(udf::g_character_flags_table, numeric), "numeric"); - check_result(!udf::is_numeric(udf::g_character_flags_table, alpha), "!numeric"); - - check_result(udf::is_digit(udf::g_character_flags_table, digit), "digit"); - check_result(!udf::is_digit(udf::g_character_flags_table, alpha), "!digit"); - - check_result(udf::is_decimal(udf::g_character_flags_table, decimal), "decimal"); - check_result(!udf::is_decimal(udf::g_character_flags_table, alpha), "!decimal"); - - check_result(udf::is_space(udf::g_character_flags_table, space), "space"); - check_result(!udf::is_space(udf::g_character_flags_table, alpha), "!space"); - - check_result(udf::is_lower(udf::g_character_flags_table, lower), "lower"); - check_result(!udf::is_lower(udf::g_character_flags_table, alpha), "!lower"); - - check_result(udf::is_upper(udf::g_character_flags_table, upper), "upper"); - check_result(!udf::is_upper(udf::g_character_flags_table, alpha), "!upper"); - - // - auto alpha_space_type = string_character_types::ALPHA | string_character_types::SPACE; - auto const test1 = cudf::string_view{"Hello world", 11}; - check_result(udf::all_characters_of_type(udf::g_character_flags_table, test1, alpha_space_type), "alpha+space"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/ctors.udf b/python/strings_udf/cpp/tests/ctors.udf deleted file mode 100644 index 0e1cd1bbfde..00000000000 --- a/python/strings_udf/cpp/tests/ctors.udf +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - auto null_string = cudf::string_view{nullptr,0}; - - dstring def; - verify(def, null_string, "default ctor"); - - dstring literal{"hello"}; - verify(literal, cudf::string_view{"hello",5}, "null-terminated ctor" ); - - dstring chr_array{"goodbye", 4}; - verify(chr_array, cudf::string_view{"good",4}, "char array ctor"); - - dstring chr_str{4, 'X'}; - verify(chr_str, cudf::string_view{"XXXX",4}, "char ctor"); - - auto world = cudf::string_view{"world",5}; - dstring d_str{world}; - verify(d_str, world, "string_view ctor"); - - dstring copied{d_str}; - verify(copied, d_str, "copy ctor"); - - dstring moved{std::move(d_str)}; - verify(moved, copied, "move ctor"); - verify(d_str, null_string, "move ctor arg check"); - - d_str = literal; - verify(d_str, literal, "assignment dstring"); - - d_str = world; - verify(d_str, world, "assignment string_view "); - - moved = std::move(d_str); - verify(moved, world, "move assignment"); - verify(d_str, null_string, "move assignment arg check"); - - d_str.assign(literal); - verify(d_str, literal, "assign()"); - d_str.assign("abcdefghijklmnopqrstuvwxyz"); - verify(d_str, cudf::string_view{"abcdefghijklmnopqrstuvwxyz",26}, "assign(char*)"); - d_str.assign("abcdefghijklmnopqrstuvwxyz", 10); - verify(d_str, cudf::string_view{"abcdefghij",10}, "assign(char*,size)"); - d_str.assign(world); - verify(d_str, world, "assign(string_view)"); - moved.assign(std::move(d_str)); - verify(moved, world, "assign(&&)"); - verify(d_str, null_string, "assign(&&) arg check"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/done.txt b/python/strings_udf/cpp/tests/done.txt deleted file mode 100644 index a965a70ed4e..00000000000 --- a/python/strings_udf/cpp/tests/done.txt +++ /dev/null @@ -1 +0,0 @@ -Done diff --git a/python/strings_udf/cpp/tests/erase.udf b/python/strings_udf/cpp/tests/erase.udf deleted file mode 100644 index 09b7348ee00..00000000000 --- a/python/strings_udf/cpp/tests/erase.udf +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"0123456789", 10}; - - dstring d_str{test_data}; - - d_str.erase(5, 5); - verify(d_str, cudf::string_view{"01234", 5}, "erase(5,5)"); - d_str = test_data; - d_str.erase(5); - verify(d_str, cudf::string_view{"01234", 5}, "erase(5)"); - - d_str = test_data; - d_str.erase(0,5); - verify(d_str, cudf::string_view{"56789", 5}, "erase(0,5)"); - - d_str = test_data; - d_str.erase(0); - verify(d_str, cudf::string_view{"", 0}, "erase(0)"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/insert.udf b/python/strings_udf/cpp/tests/insert.udf deleted file mode 100644 index 1ddadb029c3..00000000000 --- a/python/strings_udf/cpp/tests/insert.udf +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const helloworld = cudf::string_view{"helloworld", 10}; - auto const hello_world = cudf::string_view{"hello world", 11}; - auto const hello_world2 = cudf::string_view{"hello, world", 12}; - - dstring d_str{helloworld}; - - d_str.insert(5, 1, ' '); - verify(d_str, hello_world, "insert(char)"); - - d_str = helloworld; - d_str.insert(5, cudf::string_view{", ",2}); - verify(d_str, hello_world2, "insert(string_view)"); - - d_str = helloworld; - d_str.insert(5, ", "); - verify(d_str, hello_world2, "insert(char*)"); - - d_str = helloworld; - d_str.insert(5, ", there", 2); - verify(d_str, hello_world2, "insert(char*,size)"); - - d_str = helloworld; - d_str.insert(10, "!"); - verify(d_str, cudf::string_view{"helloworld!", 11}, "insert() end"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/integers.udf b/python/strings_udf/cpp/tests/integers.udf deleted file mode 100644 index 153783c2ede..00000000000 --- a/python/strings_udf/cpp/tests/integers.udf +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"-1234567890A", 12}; - - auto value = cudf::strings::udf::stoi(test_data); - dstring d_str = cudf::strings::udf::to_string(value); - verify(d_str, test_data.substr(0,11), "-1234567890"); - - value = cudf::strings::udf::stoi(test_data.substr(0,1)); - d_str = cudf::strings::udf::to_string(value); - verify(d_str, cudf::string_view("0",1), "sign"); - - value = cudf::strings::udf::stoi(test_data.substr(0,0)); - d_str = cudf::strings::udf::to_string(value); - verify(d_str, cudf::string_view("0",1), ""); - - value = cudf::strings::udf::stoi(test_data.substr(11,1)); - d_str = cudf::strings::udf::to_string(value); - verify(d_str, cudf::string_view("0",1), "A"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/replace.udf b/python/strings_udf/cpp/tests/replace.udf deleted file mode 100644 index 39a6ae5e26f..00000000000 --- a/python/strings_udf/cpp/tests/replace.udf +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"0123456789", 10}; - - dstring d_str{test_data}; - - auto const expected_same = cudf::string_view{"01234 6789", 10}; - d_str.replace(5, 1, 1, ' '); - verify(d_str, expected_same, "replace(char) same size"); - d_str.replace(5, 1, " "); - verify(d_str, expected_same, "replace(char*) same size"); - d_str.replace(5, 1, " !", 1); - verify(d_str, expected_same, "replace(char*,size) same size"); - d_str.replace(5, 1, cudf::string_view{" ", 1}); - verify(d_str, expected_same, "replace(string_view) same size"); - - auto const expected_small = cudf::string_view{"01 789", 7}; - d_str = test_data; - d_str.replace(2, 5, 2, ' '); - verify(d_str, expected_small, "replace(char) smaller"); - d_str = test_data; - d_str.replace(2, 5, " "); - verify(d_str, expected_small, "replace(char*) smaller"); - d_str = test_data; - d_str.replace(2, 5, " !", 2); - verify(d_str, expected_small, "replace(char*,size) smaller"); - d_str = test_data; - d_str.replace(2, 5, cudf::string_view{" ", 2}); - verify(d_str, expected_small, "replace(string_view) smaller"); - - auto const expected_large = cudf::string_view{"0 456789", 12}; - d_str = test_data; - d_str.replace(1, 3, 5, ' '); - verify(d_str, expected_large, "replace(char) larger"); - d_str = test_data; - d_str.replace(1, 3, " "); - verify(d_str, expected_large, "replace(char*) larger"); - d_str = test_data; - d_str.replace(1, 3, " !", 5); - verify(d_str, expected_large, "replace(char*,size) larger"); - d_str = test_data; - d_str.replace(1, 3, cudf::string_view{" ", 5}); - verify(d_str, expected_large, "replace(string_view) larger"); - - d_str = test_data; - d_str.replace(5, -1, ""); - verify(d_str, cudf::string_view{"01234",5}, "replace(5,end)"); - - d_str = test_data; - d_str.replace(5, 0, " "); - verify(d_str, cudf::string_view{"01234 56789",11}, "replace(5,0)"); - - d_str = test_data; - d_str.replace(-1, -1, " "); - verify(d_str, d_str, "replace(-1)"); - d_str.replace(45, -1, " "); - verify(d_str, d_str, "replace(pos>end)"); - d_str.replace(0, -1, " ", -1); - verify(d_str, d_str, "replace(char*,size<0)"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/resize.udf b/python/strings_udf/cpp/tests/resize.udf deleted file mode 100644 index 9bc7e355783..00000000000 --- a/python/strings_udf/cpp/tests/resize.udf +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"0123456789", 10}; - - dstring d_str{test_data}; - - d_str.reserve(5); - verify(d_str, test_data, "reserve(5)"); - d_str.reserve(25); - verify(d_str, test_data, "reserve(5)"); - - d_str.shrink_to_fit(); - verify(d_str, test_data, "shrink_to_fit"); - - d_str.resize(12); - verify(d_str, cudf::string_view{"0123456789\0\0", 12}, "resize(12)"); - d_str.resize(4); - verify(d_str, cudf::string_view{"0123", 4}, "resize(4)"); - - d_str.clear(); - verify(d_str, cudf::string_view{nullptr, 0}, "clear()"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/run_tests.sh b/python/strings_udf/cpp/tests/run_tests.sh deleted file mode 100755 index 4af1217c58a..00000000000 --- a/python/strings_udf/cpp/tests/run_tests.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2022, NVIDIA CORPORATION. - -./udf_cli -u ../tests/ctors.udf -t ../tests/done.txt -./udf_cli -u ../tests/append.udf -t ../tests/done.txt -./udf_cli -u ../tests/insert.udf -t ../tests/done.txt -./udf_cli -u ../tests/replace.udf -t ../tests/done.txt -./udf_cli -u ../tests/substr.udf -t ../tests/done.txt -./udf_cli -u ../tests/erase.udf -t ../tests/done.txt -./udf_cli -u ../tests/resize.udf -t ../tests/done.txt - -./udf_cli -u ../tests/integers.udf -t ../tests/done.txt -./udf_cli -u ../tests/split.udf -t ../tests/done.txt -./udf_cli -u ../tests/strip.udf -t ../tests/done.txt - -./udf_cli -u ../tests/starts_ends.udf -t ../tests/done.txt -./udf_cli -u ../tests/char_types.udf -t ../tests/done.txt diff --git a/python/strings_udf/cpp/tests/search.udf b/python/strings_udf/cpp/tests/search.udf deleted file mode 100644 index e9b3e0c24db..00000000000 --- a/python/strings_udf/cpp/tests/search.udf +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -using namespace cudf::strings; - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - auto const test_data = cudf::string_view{"Here is an orange and an apple", 30}; - auto const empty = cudf::string_view{}; - - check_result(udf::count(test_data, "an")==4, "count(an)=4"); - check_result(udf::count(test_data, "a", 10, 40)==4, "count(a,10,40)=4"); - check_result(udf::count(test_data, "g", 1, 10)==0, "count(g,1,10)=0"); - check_result(udf::count(test_data, "g")==1, "count(g)=1"); - check_result(udf::count(test_data, "orange", 15, 25)==0, "count(orange,15,25)=0"); - check_result(udf::count(test_data, "an orange")==1, "count(an orange)=1"); - check_result(udf::count(test_data, "banana")==0, "count(banana)=0"); - - check_result(udf::count(test_data, empty)==0, "count('')=0"); - check_result(udf::count(empty, empty)==0, "count('','')=0"); - check_result(udf::count(empty, "a")==0, "count('',a)=0"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/split.udf b/python/strings_udf/cpp/tests/split.udf deleted file mode 100644 index f39ae546276..00000000000 --- a/python/strings_udf/cpp/tests/split.udf +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"01 234 56789 ", 13}; - cudf::string_view tokens[4]; - - auto token_count = cudf::strings::udf::split(test_data, tokens); - auto d_str = cudf::strings::udf::join("::", tokens, token_count); - verify(d_str, cudf::string_view{"01::234::56789", 14}, "split().join('::')"); - - token_count = cudf::strings::udf::split(test_data, "4 ", tokens); - d_str = cudf::strings::udf::join("/", tokens, token_count); - verify(d_str, cudf::string_view{"01 23/56789 ", 12}, "split('4 ').join('/')"); - - token_count = cudf::strings::udf::split(test_data, " ", tokens); - d_str = cudf::strings::udf::join("xyz", tokens, token_count); - verify(d_str, cudf::string_view{"01xyz234xyz56789xyz", 19}, "split(' ').join('xyz')"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/starts_ends.udf b/python/strings_udf/cpp/tests/starts_ends.udf deleted file mode 100644 index 8edf9665ee5..00000000000 --- a/python/strings_udf/cpp/tests/starts_ends.udf +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"0123456789", 10}; - - dstring d_test{test_data}; - cudf::string_view first("012345",6); - cudf::string_view last("456789",6); - - check_result(cudf::strings::udf::starts_with(d_test, "0123"), "starts_with(0123)"); - check_result(!cudf::strings::udf::starts_with(d_test, "123"), "starts_with(123)"); - check_result(cudf::strings::udf::starts_with(d_test, "0123", 2), "starts_with(0123,2)"); - check_result(!cudf::strings::udf::starts_with(d_test, "123", 2), "starts_with(123,2)"); - check_result(cudf::strings::udf::starts_with(d_test, first), "starts_with(first)"); - check_result(!cudf::strings::udf::starts_with(d_test, last), "starts_with(last)"); - - check_result(cudf::strings::udf::ends_with(d_test, "6789"), "ends_with(6789)"); - check_result(!cudf::strings::udf::ends_with(d_test, "78"), "ends_with(78)"); - check_result(cudf::strings::udf::ends_with(d_test, "8901", 2), "ends_with(8901,2)"); - check_result(!cudf::strings::udf::ends_with(d_test, "8901", 3), "ends_with(890,2)"); - check_result(cudf::strings::udf::ends_with(d_test, last), "ends_with(last)"); - check_result(!cudf::strings::udf::ends_with(d_test, first), "ends_with(first)"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/strip.udf b/python/strings_udf/cpp/tests/strip.udf deleted file mode 100644 index 2db45b8b158..00000000000 --- a/python/strings_udf/cpp/tests/strip.udf +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include -#include -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto empty = cudf::string_view{}; - cudf::string_view tests[] = { - empty, - cudf::string_view{" aaa ",5}, - cudf::string_view{"bbb ",5}, - cudf::string_view{" cccc",5}, - cudf::string_view{" a b c ",7}, - cudf::string_view{"a b c",5}, - cudf::string_view{" ",3}, - cudf::string_view{"aaaaa",5} }; - - auto d_str = cudf::strings::udf::strip(empty); - verify(d_str, empty, ""); - - d_str = cudf::strings::udf::strip(tests[1]); - verify(d_str, tests[1].substr(1,3), " aaa "); - - d_str = cudf::strings::udf::strip(tests[2]); - verify(d_str, tests[2].substr(0,3), "bbb "); - - d_str = cudf::strings::udf::strip(tests[3]); - verify(d_str, tests[3].substr(1,4), " cccc"); - - d_str = cudf::strings::udf::strip(tests[4]); - verify(d_str, tests[4].substr(1,5), " a b c "); - - d_str = cudf::strings::udf::strip(tests[5]); - verify(d_str, tests[5], "a b c"); - - d_str = cudf::strings::udf::strip(tests[6]); - verify(d_str, empty, ""); - - d_str = cudf::strings::udf::strip(tests[7]); - verify(d_str, tests[7], "aaaaa"); - - auto N = static_cast( sizeof(tests)/sizeof(cudf::string_view) ); - for( int i=0; i < N; ++i ) { - d_str = cudf::strings::udf::strip(tests[i], " abc"); - dstring name = cudf::strings::udf::to_string(i); - verify(d_str, empty, name.data()); - } - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/substr.udf b/python/strings_udf/cpp/tests/substr.udf deleted file mode 100644 index 27992a3ed7a..00000000000 --- a/python/strings_udf/cpp/tests/substr.udf +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2022, NVIDIA CORPORATION. - -#include - -#include "../tests/utilities.cuh" - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid > 0 ) return; - - using dstring = cudf::strings::udf::dstring; - - auto const test_data = cudf::string_view{"0123456789", 10}; - - dstring d_test{test_data}; - - auto d_str = d_test.substr(0, 5); - verify(d_str, cudf::string_view{"01234", 5}, "substr(0,5)"); - - d_str = d_test.substr(5); - verify(d_str, cudf::string_view{"56789", 5}, "substr(5)"); - d_str = d_test.substr(5, 45); - verify(d_str, cudf::string_view{"56789", 5}, "substr(5, 45)"); - - d_str = d_test.substr(0); - verify(d_str, test_data, "substr(0)"); - d_str = d_test.substr(-1); - verify(d_str, cudf::string_view("",0), "substr(-1)"); - - d_str = d_test.substr(3,0); - verify(d_str, cudf::string_view("",0), "substr(3,0)"); - - d_out_strs[tid] = d_in_strs[tid]; -} diff --git a/python/strings_udf/cpp/tests/utilities.cuh b/python/strings_udf/cpp/tests/utilities.cuh deleted file mode 100644 index 01a071c7e26..00000000000 --- a/python/strings_udf/cpp/tests/utilities.cuh +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -__device__ void print_debug(cudf::strings::udf::dstring const& d_str, char const* name = "") -{ - printf( - "%s:(%p,%d,%d)=[%s]\n", name, d_str.data(), d_str.size_bytes(), d_str.capacity(), d_str.data()); -} - -__device__ void verify(cudf::strings::udf::dstring const& d_str, - cudf::string_view const expected, - char const* name = 0) -{ - if (d_str.compare(expected) == 0) { - printf("\x1B[32mOK\x1B[0m: %s\n", name); - } else { - auto exp_str = cudf::strings::udf::dstring(expected); - printf("\x1B[31mError\x1B[0m: %s [%s]!=[%s]\n", name, d_str.data(), exp_str.data()); - } -} - -__device__ void check_result(bool result, char const* str = 0) -{ - if (result) { - printf("\x1B[32mOK\x1B[0m: %s\n", str); - } else { - printf("\x1B[31mError\x1B[0m: %s\n", str); - } -} diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index fe7e4187bdd..9f0c9171c92 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,11 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. from ptxcompiler.patch import patch_needed -breakpoint() ENABLED = False if patch_needed() else True from pathlib import Path here = str(Path(__file__).parent.absolute()) -relative = "shim/shim.ptx" +relative = "/shim/shim.ptx" ptxpath = here + relative From 196f0ddca4466fc551505d8d2834b8a9273e80c6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 16 Aug 2022 10:49:58 -0700 Subject: [PATCH 073/212] add back mistakenly removed udf_apis.hpp, which is required --- .../cpp/include/cudf/strings/udf/udf_apis.hpp | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp new file mode 100644 index 00000000000..4f61f178c09 --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +#include + +#include +#include +#include + +// somewhat iffy forward reference +namespace jitify { +class Program; +} + +/** + * @brief Module instance returned by create_udf_module + */ +struct udf_module { + jitify::Program *program{}; + udf_module(jitify::Program *p) : program(p) {} + ~udf_module(); +}; + +/** + * @brief Build UDF module with kernel source and compile options. + * + * @param udf String containing kernel source code + * @param options Compile options for the jitify compiler + * @return udf module to pass to `call_udf` + */ +std::unique_ptr create_udf_module(std::string const &udf, + std::vector const &options); + +/** + * @brief Launch kernel named `udf_name` in UDF module. + * + * @param udf Returned from `create_udf_module` + * @param udf_name Name of global device function to execute in UDF module + * @param output_size Output strings column size. + * Also used to computing the thread block size. + * @param input libcudf columns to pass to the kernel + * @param heap_size Size in bytes to reserve for device-side malloc. + * @return New libcudf strings column created by the kernel logic. + */ +std::unique_ptr call_udf(udf_module const &udf, + std::string const &udf_name, + cudf::size_type output_size, + std::vector input, + size_t heap_size = 1073741824); + +/** + * @brief Return a cudf::string_view array for the given strings column + * + * @throw cudf::logic_error if input is not a strings column. + */ +std::unique_ptr to_string_view_array(cudf::column_view const input); + +/** + * @brief Return a cudf::column given an array of dstring objects. + * + * @param d_buffer Pointer to device memory of dstring objects + * @param d_size The number of bytes in the d_buffer + * @return A strings column copy of the dstring objects + */ +std::unique_ptr from_dstring_array(void *d_buffer, std::size_t size); From 241fd3b557b99bdd58e9a30d8368b291d0a38a5d Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 16 Aug 2022 12:48:40 -0700 Subject: [PATCH 074/212] add back in just the needed parts of udf_apis, resolve cython errors --- python/strings_udf/cpp/CMakeLists.txt | 36 +++++++++++++ .../cpp/include/cudf/strings/udf/udf_apis.hpp | 49 ------------------ .../cpp/src/strings/udf/udf_apis.cu | 51 +++++++++++++++++++ .../strings_udf/_lib/cudf_jit_udf.pyx | 49 ------------------ 4 files changed, 87 insertions(+), 98 deletions(-) create mode 100644 python/strings_udf/cpp/src/strings/udf/udf_apis.cu diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 7b5791ced1f..11a1b03c0c2 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -44,10 +44,21 @@ message(STATUS "CONDA_PREFIX=${CONDA_PREFIX}") find_package(CUDAToolkit REQUIRED) +# depends on an installed cudf dev env +set(UDF_INCLUDES ${CONDA_PREFIX}/include) +list(APPEND UDF_INCLUDES ${CONDA_PREFIX}/include/rapids/libcudacxx) +list(APPEND UDF_INCLUDES ${CMAKE_SOURCE_DIR}/build/_deps/jitify-src) + +set(UDF_LIBS ${CONDA_PREFIX}/lib/libcudf.so nvrtc) + +set(UDF_CXX_FLAGS "") +set(UDF_CUDA_FLAGS "") set(SHIM_CUDA_FLAGS "") +list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true -keep) +add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) add_library(shim OBJECT src/strings/udf/shim.cu) set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) @@ -64,8 +75,33 @@ target_include_directories( PUBLIC ${CONDA_PREFIX}/include ) +set_target_properties( + cudf_strings_udf + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON +) + +target_compile_options( + cudf_strings_udf PRIVATE "$<$:${UDF_CXX_FLAGS}>" + "$<$:${UDF_CUDA_FLAGS}>" +) + target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") +target_include_directories( + cudf_strings_udf + PRIVATE include + PUBLIC ${UDF_INCLUDES} +) +target_link_libraries(cudf_strings_udf PUBLIC ${UDF_LIBS}) + +install(TARGETS cudf_strings_udf) install(FILES ${CMAKE_SOURCE_DIR}/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx DESTINATION ${CMAKE_SOURCE_DIR}/../strings_udf/shim/ ) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp index 4f61f178c09..a7191eb56ea 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -26,46 +26,6 @@ #include #include -// somewhat iffy forward reference -namespace jitify { -class Program; -} - -/** - * @brief Module instance returned by create_udf_module - */ -struct udf_module { - jitify::Program *program{}; - udf_module(jitify::Program *p) : program(p) {} - ~udf_module(); -}; - -/** - * @brief Build UDF module with kernel source and compile options. - * - * @param udf String containing kernel source code - * @param options Compile options for the jitify compiler - * @return udf module to pass to `call_udf` - */ -std::unique_ptr create_udf_module(std::string const &udf, - std::vector const &options); - -/** - * @brief Launch kernel named `udf_name` in UDF module. - * - * @param udf Returned from `create_udf_module` - * @param udf_name Name of global device function to execute in UDF module - * @param output_size Output strings column size. - * Also used to computing the thread block size. - * @param input libcudf columns to pass to the kernel - * @param heap_size Size in bytes to reserve for device-side malloc. - * @return New libcudf strings column created by the kernel logic. - */ -std::unique_ptr call_udf(udf_module const &udf, - std::string const &udf_name, - cudf::size_type output_size, - std::vector input, - size_t heap_size = 1073741824); /** * @brief Return a cudf::string_view array for the given strings column @@ -73,12 +33,3 @@ std::unique_ptr call_udf(udf_module const &udf, * @throw cudf::logic_error if input is not a strings column. */ std::unique_ptr to_string_view_array(cudf::column_view const input); - -/** - * @brief Return a cudf::column given an array of dstring objects. - * - * @param d_buffer Pointer to device memory of dstring objects - * @param d_size The number of bytes in the d_buffer - * @return A strings column copy of the dstring objects - */ -std::unique_ptr from_dstring_array(void *d_buffer, std::size_t size); diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu new file mode 100644 index 00000000000..647433cc1c6 --- /dev/null +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2021-2022, NVIDIA CORPORATION. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "jitify.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +std::unique_ptr to_string_view_array(cudf::column_view const input, + rmm::cuda_stream_view stream) +{ +return std::make_unique( +std::move(cudf::strings::detail::create_string_vector_from_column( +cudf::strings_column_view(input), stream) +.release())); +} + +std::unique_ptr to_string_view_array(cudf::column_view const input) +{ +return to_string_view_array(input, rmm::cuda_stream_default); +} diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index fe17c10f349..2b7dcd81637 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -19,49 +19,12 @@ from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from strings_udf._lib.cpp.strings_udf cimport ( - call_udf as cpp_call_udf, - create_udf_module as cpp_create_udf_module, - from_dstring_array as cpp_from_dstring_array, to_string_view_array as cpp_to_string_view_array, - udf_module as cpp_udf_module, ) import numpy as np -def process_udf(udf, name, cols): - cdef string c_udf - cdef string c_name - cdef size_type c_size - - cdef vector[column_view] c_columns - cdef unique_ptr[cpp_udf_module] c_module - cdef vector[string] c_options - - cdef unique_ptr[column] c_result - - c_udf = udf.encode('UTF-8') - c_name = name.encode('UTF-8') - - cdef Column col = cols[0]._column - c_size = col.size - for c in cols: - col = c._column - c_columns.push_back(col.view()) - - include_path = "-I" + os.environ.get("CONDA_PREFIX") + "/include" - c_options.push_back(str(include_path).encode('UTF-8')) - - # with nogil: - c_module = move(cpp_create_udf_module(c_udf, c_options)) - # c_module will be nullptr if there is a compile error - - # with nogil: - c_result = move(cpp_call_udf(c_module.get()[0], c_name, c_size, c_columns)) - - return Column.from_unique_ptr(move(c_result)) - - def to_string_view_array(Column strings_col): cdef unique_ptr[device_buffer] c_buffer @@ -71,15 +34,3 @@ def to_string_view_array(Column strings_col): buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) buffer = Buffer(buffer) return buffer - - -def from_dstring_array(DeviceBuffer d_buffer): - cdef size_t size = d_buffer.c_size() - cdef void* data = d_buffer.c_data() - cdef unique_ptr[column] c_result - # data = - - # with nogil: - c_result = move(cpp_from_dstring_array(data, size)) - - return Column.from_unique_ptr(move(c_result)) From 71e5cabfd5ad639db88493cc6b1455037ba67671 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Aug 2022 12:11:24 -0700 Subject: [PATCH 075/212] fix _get_frame_row_type struct alignment issues --- python/cudf/cudf/core/udf/row_function.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 93f4f9cc243..367f0f6f99a 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -34,12 +34,10 @@ def _get_frame_row_type(dtype): Models each column and its mask as a MaskedType and models the row as a dictionary like data structure containing these MaskedTypes. - Large parts of this function are copied with comments from the Numba internals and slightly modified to account for validity bools to be present in the final struct. - See numba.np.numpy_support.from_struct_dtype for details. """ @@ -48,7 +46,7 @@ def _get_frame_row_type(dtype): fields = [] offset = 0 - sizes = [] + sizes = [itemsizes.get(val[0]) or val[0].itemsize for val in dtype.fields.values()] for i, (name, info) in enumerate(dtype.fields.items()): # *info* consists of the element dtype, its offset from the beginning # of the record, and an optional "title" containing metadata. @@ -66,7 +64,6 @@ def _get_frame_row_type(dtype): # increment offset by itemsize plus one byte for validity itemsize = itemsizes.get(elemdtype) or elemdtype.itemsize - sizes.append(itemsize) offset += itemsize + 1 # Align the next member of the struct to be a multiple of the @@ -74,7 +71,7 @@ def _get_frame_row_type(dtype): if i < len(sizes) - 1: next_itemsize = sizes[i + 1] offset = int(math.ceil(offset / next_itemsize) * next_itemsize) - + # Numba requires that structures are aligned for the CUDA target _is_aligned_struct = True return Record(fields, offset, _is_aligned_struct) From 24d602212570a23da6ba4fda62138987898c4909 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Aug 2022 13:13:42 -0700 Subject: [PATCH 076/212] move PTX to conda prefix --- python/cudf/cudf/tests/test_extension_compilation.py | 2 +- python/strings_udf/cpp/CMakeLists.txt | 2 +- python/strings_udf/strings_udf/__init__.py | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/python/cudf/cudf/tests/test_extension_compilation.py b/python/cudf/cudf/tests/test_extension_compilation.py index 692f40873d7..f1ed17c5df5 100644 --- a/python/cudf/cudf/tests/test_extension_compilation.py +++ b/python/cudf/cudf/tests/test_extension_compilation.py @@ -10,7 +10,7 @@ from cudf import NA from cudf.core.udf.api import Masked -from cudf.core.udf.typing import MaskedType +from cudf.core.udf.masked_typing import MaskedType from cudf.testing._utils import parametrize_numeric_dtypes_pairwise arith_ops = ( diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 11a1b03c0c2..534f88c4807 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -103,5 +103,5 @@ target_link_libraries(cudf_strings_udf PUBLIC ${UDF_LIBS}) install(TARGETS cudf_strings_udf) install(FILES ${CMAKE_SOURCE_DIR}/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx - DESTINATION ${CMAKE_SOURCE_DIR}/../strings_udf/shim/ + DESTINATION ${CONDA_PREFIX}/lib ) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index 9f0c9171c92..c1701b913aa 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,10 +1,7 @@ # Copyright (c) 2022, NVIDIA CORPORATION. from ptxcompiler.patch import patch_needed +import os ENABLED = False if patch_needed() else True -from pathlib import Path - -here = str(Path(__file__).parent.absolute()) -relative = "/shim/shim.ptx" -ptxpath = here + relative +ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" From 996d944fd1dd1a3dc69f666a00a921cc379b8fde Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 17 Aug 2022 13:19:48 -0700 Subject: [PATCH 077/212] minor update --- python/cudf/cudf/core/udf/row_function.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 367f0f6f99a..f9d08033bbf 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -46,7 +46,10 @@ def _get_frame_row_type(dtype): fields = [] offset = 0 - sizes = [itemsizes.get(val[0]) or val[0].itemsize for val in dtype.fields.values()] + sizes = [ + itemsizes.get(val[0]) or val[0].itemsize + for val in dtype.fields.values() + ] for i, (name, info) in enumerate(dtype.fields.items()): # *info* consists of the element dtype, its offset from the beginning # of the record, and an optional "title" containing metadata. @@ -71,7 +74,7 @@ def _get_frame_row_type(dtype): if i < len(sizes) - 1: next_itemsize = sizes[i + 1] offset = int(math.ceil(offset / next_itemsize) * next_itemsize) - + # Numba requires that structures are aligned for the CUDA target _is_aligned_struct = True return Record(fields, offset, _is_aligned_struct) From 2b669ded865eea1922a3dcd4c1a0a33e8dfb8616 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 19 Aug 2022 08:24:13 -0700 Subject: [PATCH 078/212] create skbuild process based on the one from cudf --- python/strings_udf/CMakeLists.txt | 36 ++++ python/strings_udf/cpp/CMakeLists.txt | 5 +- python/strings_udf/setup.cfg | 18 +- python/strings_udf/setup.py | 180 ++++++++++++++---- .../strings_udf/_lib/CMakeLists.txt | 28 +++ .../strings_udf/_lib/cpp/strings_udf.pxd | 5 +- 6 files changed, 229 insertions(+), 43 deletions(-) create mode 100644 python/strings_udf/CMakeLists.txt create mode 100644 python/strings_udf/strings_udf/_lib/CMakeLists.txt diff --git a/python/strings_udf/CMakeLists.txt b/python/strings_udf/CMakeLists.txt new file mode 100644 index 00000000000..a306eab826c --- /dev/null +++ b/python/strings_udf/CMakeLists.txt @@ -0,0 +1,36 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) + +set(strings_udf_version 22.10.00) + +include(../../fetch_rapids.cmake) + +project( + strings-udf-python + VERSION ${strings_udf_version} + LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + # language to be enabled here. The test project that is built in scikit-build to verify + # various linking options for the python library is hardcoded to build with C, so until + # that is fixed we need to keep C. + C CXX +) + +find_package(cudf ${strings_udf_version} REQUIRED) + +include(rapids-cython) +rapids_cython_init() + +add_subdirectory(strings_udf/_lib) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 534f88c4807..808ab571a73 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -85,6 +85,7 @@ set_target_properties( CUDA_STANDARD_REQUIRED ON POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON + PUBLIC_HEADER "include/cudf/strings/udf/udf_apis.hpp" ) target_compile_options( @@ -101,7 +102,9 @@ target_include_directories( ) target_link_libraries(cudf_strings_udf PUBLIC ${UDF_LIBS}) -install(TARGETS cudf_strings_udf) +install(TARGETS cudf_strings_udf + PUBLIC_HEADER DESTINATION ${CONDA_PREFIX}/include/cudf/strings/udf/ +) install(FILES ${CMAKE_SOURCE_DIR}/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx DESTINATION ${CONDA_PREFIX}/lib ) diff --git a/python/strings_udf/setup.cfg b/python/strings_udf/setup.cfg index 51e8aaaecae..8a648097ac8 100644 --- a/python/strings_udf/setup.cfg +++ b/python/strings_udf/setup.cfg @@ -1,4 +1,16 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. + +# See the docstring in versioneer.py for instructions. Note that you must +# re-run 'versioneer.py setup' after changing this section, and commit the +# resulting files. + +[versioneer] +VCS = git +style = pep440 +versionfile_source = cudf/_version.py +versionfile_build = cudf/_version.py +tag_prefix = v +parentdir_prefix = cudf- [isort] line_length=79 @@ -13,9 +25,9 @@ known_dask= dask_cuda known_rapids= rmm - cudf -known_first_party= strings_udf +known_first_party= + cudf default_section=THIRDPARTY sections=FUTURE,STDLIB,THIRDPARTY,DASK,RAPIDS,FIRSTPARTY,LOCALFOLDER skip= diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index f9fd74952a3..aa024cee7d7 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -1,51 +1,157 @@ -# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# Copyright (c) 2018-2022, NVIDIA CORPORATION. import os -from distutils.sysconfig import get_python_lib +import re +import shutil +import subprocess +import sys +from distutils.spawn import find_executable -from Cython.Build import cythonize from setuptools import find_packages from skbuild import setup -from setuptools.extension import Extension +from skbuild.command.build_ext import build_ext -CUDA_HOME = "/usr/local/cuda" -cuda_include_dir = os.path.join(CUDA_HOME, "include") -cuda_lib_dir = os.path.join(CUDA_HOME, "lib64") - -CONDA_PREFIX = os.environ.get("CONDA_PREFIX") -print(CONDA_PREFIX) -extensions = [ - Extension( - "*", - sources=["strings_udf/_lib/*.pyx"], - include_dirs=[ - os.path.abspath(os.path.join(CONDA_PREFIX, "include/cudf")), - os.path.join(CONDA_PREFIX, "include/rapids/libcudacxx"), - "./cpp/include", - cuda_include_dir, - ], - library_dirs=( - [ - get_python_lib(), - os.path.join(os.sys.prefix, "lib"), - cuda_lib_dir, - "cpp/build", - ] - ), - libraries=["cudart", "cudf", "nvrtc", "cudf_strings_udf"], - language="c++", - extra_compile_args=["-std=c++17"], - ) +import versioneer + +install_requires = [ + "cachetools", + "cuda-python>=11.5,<11.7.1", + "fsspec>=0.6.0", + "numba>=0.53.1", + "numpy", + "nvtx>=0.2.1", + "packaging", + "pandas>=1.0,<1.5.0dev0", + "protobuf>=3.20.1,<3.21.0a0", + "typing_extensions", ] -directives = dict(profile=False, language_level=3, embedsignature=True) +extras_require = { + "test": [ + "pytest", + "pytest-benchmark", + "pytest-xdist", + "hypothesis", + "mimesis", + "fastavro>=0.22.9", + "python-snappy>=0.6.0", + "pyorc", + "msgpack", + "transformers<=4.10.3", + ] +} + + +def get_cuda_version_from_header(cuda_include_dir, delimeter=""): + + cuda_version = None + + with open(os.path.join(cuda_include_dir, "cuda.h"), encoding="utf-8") as f: + for line in f.readlines(): + if re.search(r"#define CUDA_VERSION ", line) is not None: + cuda_version = line + break + + if cuda_version is None: + raise TypeError("CUDA_VERSION not found in cuda.h") + cuda_version = int(cuda_version.split()[2]) + return "%d%s%d" % ( + cuda_version // 1000, + delimeter, + (cuda_version % 1000) // 10, + ) + + +CUDA_HOME = os.environ.get("CUDA_HOME", False) +if not CUDA_HOME: + path_to_cuda_gdb = shutil.which("cuda-gdb") + if path_to_cuda_gdb is None: + raise OSError( + "Could not locate CUDA. " + "Please set the environment variable " + "CUDA_HOME to the path to the CUDA installation " + "and try again." + ) + CUDA_HOME = os.path.dirname(os.path.dirname(path_to_cuda_gdb)) + +if not os.path.isdir(CUDA_HOME): + raise OSError(f"Invalid CUDA_HOME: directory does not exist: {CUDA_HOME}") + +cuda_include_dir = os.path.join(CUDA_HOME, "include") +install_requires.append( + "cupy-cuda" + + get_cuda_version_from_header(cuda_include_dir) + + ">=9.5.0,<11.0.0a0" +) + + +class build_ext_and_proto(build_ext): + def run(self): + # Get protoc + protoc = None + if "PROTOC" in os.environ and os.path.exists(os.environ["PROTOC"]): + protoc = os.environ["PROTOC"] + else: + protoc = find_executable("protoc") + if protoc is None: + sys.stderr.write("protoc not found") + sys.exit(1) + + # Build .proto file + for source in [ + "../cudf/cudf/utils/metadata/orc_column_statistics.proto" + ]: + output = source.replace(".proto", "_pb2.py") + + if not os.path.exists(output) or ( + os.path.getmtime(source) > os.path.getmtime(output) + ): + with open(output, "a") as src: + src.write("# flake8: noqa" + os.linesep) + src.write("# fmt: off" + os.linesep) + subprocess.check_call([protoc, "--python_out=.", source]) + with open(output, "r+") as src: + new_src_content = ( + "# flake8: noqa" + + os.linesep + + "# fmt: off" + + os.linesep + + src.read() + + "# fmt: on" + + os.linesep + ) + src.seek(0) + src.write(new_src_content) + + # Run original Cython build_ext command + super().run() + + +cmdclass = versioneer.get_cmdclass() +cmdclass["build_ext"] = build_ext_and_proto setup( name="strings_udf", - description="cudf strings udf library", + version=versioneer.get_version(), + description="Strings UDF Library", + url="https://github.com/rapidsai/cudf", author="NVIDIA Corporation", - setup_requires=["cython"], - ext_modules=cythonize(extensions, compiler_directives=directives), + license="Apache 2.0", + classifiers=[ + "Intended Audience :: Developers", + "Topic :: Database", + "Topic :: Scientific/Engineering", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + ], + packages=find_packages(include=["strings_udf", "strings_udf.*"]), + package_data={ + key: ["*.pxd"] for key in find_packages(include=["strings_udf._lib*"]) + }, + cmdclass=cmdclass, + install_requires=install_requires, + extras_require=extras_require, zip_safe=False, - packages=find_packages(), ) diff --git a/python/strings_udf/strings_udf/_lib/CMakeLists.txt b/python/strings_udf/strings_udf/_lib/CMakeLists.txt new file mode 100644 index 00000000000..d9b69aca60e --- /dev/null +++ b/python/strings_udf/strings_udf/_lib/CMakeLists.txt @@ -0,0 +1,28 @@ +# ============================================================================= +# Copyright (c) 2022, NVIDIA CORPORATION. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============================================================================= + +set(cython_sources cudf_jit_udf.pyx tables.pyx) +set(linked_libraries cudf::cudf) +rapids_cython_create_modules( + CXX + SOURCE_FILES "${cython_sources}" + LINKED_LIBRARIES "${linked_libraries}" +) + +foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/cpp") + set_target_properties( + ${cython_module} PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/include + ) +endforeach() diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index 653ddae4b29..e0526d52136 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -5,13 +5,14 @@ from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -cdef extern from "cudf/strings/udf/udf_apis.hpp": +cdef extern from "udf_apis.hpp": cdef cppclass udf_module cdef unique_ptr[udf_module] create_udf_module(string, vector[string]) cdef unique_ptr[column] call_udf( From 8324831751bee3030056795c715d4ecee763d465 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 19 Aug 2022 08:42:35 -0700 Subject: [PATCH 079/212] run pre-commit --- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 10 +++++----- python/strings_udf/strings_udf/tests/utils.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 2b7dcd81637..5d03019b1af 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -12,16 +12,16 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer -from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer - from strings_udf._lib.cpp.strings_udf cimport ( to_string_view_array as cpp_to_string_view_array, ) +from cudf._lib.column cimport Column +from cudf._lib.cpp.column.column cimport column +from cudf._lib.cpp.column.column_view cimport column_view +from cudf._lib.cpp.types cimport size_type + import numpy as np diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 01ed86eb497..2a8f22da572 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -7,13 +7,13 @@ from numba.core.typing import signature as nb_signature from numba.types import CPointer, void -import cudf -from cudf.testing._utils import assert_eq - from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view +import cudf +from cudf.testing._utils import assert_eq + def run_udf_test(data, func, dtype): dtype = np.dtype(dtype) From 08904f7b78bb6a41df52da2d64a870d6acd1a788 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 22 Aug 2022 08:17:43 -0700 Subject: [PATCH 080/212] install versioneer into subpackage --- .gitattributes | 1 + .pre-commit-config.yaml | 1 + python/strings_udf/setup.cfg | 14 +- python/strings_udf/strings_udf/__init__.py | 4 + python/strings_udf/strings_udf/_version.py | 711 +++++++ python/strings_udf/versioneer.py | 2239 ++++++++++++++++++++ 6 files changed, 2961 insertions(+), 9 deletions(-) create mode 100644 python/strings_udf/strings_udf/_version.py create mode 100644 python/strings_udf/versioneer.py diff --git a/.gitattributes b/.gitattributes index 0201d7cb5e4..7c7256b4890 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ python/cudf/cudf/_version.py export-subst +python/strings_udf/strings_udf/_version.py export-subst CHANGELOG.md merge=union diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f838ba3f45..0bc4d3e578c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,6 +25,7 @@ repos: args: ["--config=setup.cfg"] files: python/.*\.(py|pyx|pxd)$ types: [file] + exclude: python/strings_udf/versioneer.py - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v0.782' hooks: diff --git a/python/strings_udf/setup.cfg b/python/strings_udf/setup.cfg index 8a648097ac8..c963b3dc7a7 100644 --- a/python/strings_udf/setup.cfg +++ b/python/strings_udf/setup.cfg @@ -1,16 +1,12 @@ -# Copyright (c) 2018-2022, NVIDIA CORPORATION. - -# See the docstring in versioneer.py for instructions. Note that you must -# re-run 'versioneer.py setup' after changing this section, and commit the -# resulting files. +# Copyright (c) 2022, NVIDIA CORPORATION. [versioneer] VCS = git style = pep440 -versionfile_source = cudf/_version.py -versionfile_build = cudf/_version.py +versionfile_source = strings_udf/_version.py +versionfile_build = strings_udf/_version.py tag_prefix = v -parentdir_prefix = cudf- +parentdir_prefix = strings_udf- [isort] line_length=79 @@ -27,7 +23,7 @@ known_rapids= rmm strings_udf known_first_party= - cudf + strings_udf default_section=THIRDPARTY sections=FUTURE,STDLIB,THIRDPARTY,DASK,RAPIDS,FIRSTPARTY,LOCALFOLDER skip= diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index c1701b913aa..8c81b9a4d71 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -5,3 +5,7 @@ ENABLED = False if patch_needed() else True ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" + +from . import _version + +__version__ = _version.get_versions()["version"] diff --git a/python/strings_udf/strings_udf/_version.py b/python/strings_udf/strings_udf/_version.py new file mode 100644 index 00000000000..14ff9ec314d --- /dev/null +++ b/python/strings_udf/strings_udf/_version.py @@ -0,0 +1,711 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer) + +"""Git implementation of _version.py.""" + +import errno +import functools +import os +import re +import subprocess +import sys +from typing import Callable, Dict + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "$Format:%d$" + git_full = "$Format:%H$" + git_date = "$Format:%ci$" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "pep440" + cfg.tag_prefix = "v" + cfg.parentdir_prefix = "strings_udf-" + cfg.versionfile_source = "strings_udf/_version.py" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + + return decorate + + +def run_command( + commands, args, cwd=None, verbose=False, hide_stderr=False, env=None +): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen( + [command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs, + ) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix) :], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None, + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r"\d", r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix) :] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r"\d", r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": None, + "date": date, + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None, + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner( + GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True + ) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner( + GITS, + [ + "describe", + "--tags", + "--dirty", + "--always", + "--long", + "--match", + f"{tag_prefix}[[:digit:]]*", + ], + cwd=root, + ) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner( + GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root + ) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[: git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = ( + "unable to parse git-describe output: '%s'" % describe_out + ) + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( + full_tag, + tag_prefix, + ) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix) :] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ + 0 + ].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post( + pieces["closest-tag"] + ) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % ( + post_version + 1, + pieces["distance"], + ) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None, + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date"), + } + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords( + get_keywords(), cfg.tag_prefix, verbose + ) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split("/"): + root = os.path.dirname(root) + except NameError: + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None, + } + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None, + } diff --git a/python/strings_udf/versioneer.py b/python/strings_udf/versioneer.py new file mode 100644 index 00000000000..d9e2d619cc3 --- /dev/null +++ b/python/strings_udf/versioneer.py @@ -0,0 +1,2239 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +# Version: 0.23 + +"""The Versioneer - like a rocketeer, but for versions. + +The Versioneer +============== + +* like a rocketeer, but for versions! +* https://github.com/python-versioneer/python-versioneer +* Brian Warner +* License: Public Domain (CC0-1.0) +* Compatible with: Python 3.7, 3.8, 3.9, 3.10 and pypy3 +* [![Latest Version][pypi-image]][pypi-url] +* [![Build Status][travis-image]][travis-url] + +This is a tool for managing a recorded version number in +distutils/setuptools-based python projects. The goal is to +remove the tedious and error-prone "update the embedded version string" +step from your release process. Making a new release should be as easy +as recording a new tag in your version-control +system, and maybe making new tarballs. + + +## Quick Install + +* `pip install versioneer` to somewhere in your $PATH +* add a `[versioneer]` section to your setup.cfg (see [Install](INSTALL.md)) +* run `versioneer install` in your source tree, commit the results +* Verify version information with `python setup.py version` + +## Version Identifiers + +Source trees come from a variety of places: + +* a version-control system checkout (mostly used by developers) +* a nightly tarball, produced by build automation +* a snapshot tarball, produced by a web-based VCS browser, like github's + "tarball from tag" feature +* a release tarball, produced by "setup.py sdist", distributed through PyPI + +Within each source tree, the version identifier (either a string or a number, +this tool is format-agnostic) can come from a variety of places: + +* ask the VCS tool itself, e.g. "git describe" (for checkouts), which knows + about recent "tags" and an absolute revision-id +* the name of the directory into which the tarball was unpacked +* an expanded VCS keyword ($Id$, etc) +* a `_version.py` created by some earlier build step + +For released software, the version identifier is closely related to a VCS +tag. Some projects use tag names that include more than just the version +string (e.g. "myproject-1.2" instead of just "1.2"), in which case the tool +needs to strip the tag prefix to extract the version identifier. For +unreleased software (between tags), the version identifier should provide +enough information to help developers recreate the same tree, while also +giving them an idea of roughly how old the tree is (after version 1.2, before +version 1.3). Many VCS systems can report a description that captures this, +for example `git describe --tags --dirty --always` reports things like +"0.7-1-g574ab98-dirty" to indicate that the checkout is one revision past the +0.7 tag, has a unique revision id of "574ab98", and is "dirty" (it has +uncommitted changes). + +The version identifier is used for multiple purposes: + +* to allow the module to self-identify its version: `myproject.__version__` +* to choose a name and prefix for a 'setup.py sdist' tarball + +## Theory of Operation + +Versioneer works by adding a special `_version.py` file into your source +tree, where your `__init__.py` can import it. This `_version.py` knows how to +dynamically ask the VCS tool for version information at import time. + +`_version.py` also contains `$Revision$` markers, and the installation +process marks `_version.py` to have this marker rewritten with a tag name +during the `git archive` command. As a result, generated tarballs will +contain enough information to get the proper version. + +To allow `setup.py` to compute a version too, a `versioneer.py` is added to +the top level of your source tree, next to `setup.py` and the `setup.cfg` +that configures it. This overrides several distutils/setuptools commands to +compute the version when invoked, and changes `setup.py build` and `setup.py +sdist` to replace `_version.py` with a small static file that contains just +the generated version data. + +## Installation + +See [INSTALL.md](./INSTALL.md) for detailed installation instructions. + +## Version-String Flavors + +Code which uses Versioneer can learn about its version string at runtime by +importing `_version` from your main `__init__.py` file and running the +`get_versions()` function. From the "outside" (e.g. in `setup.py`), you can +import the top-level `versioneer.py` and run `get_versions()`. + +Both functions return a dictionary with different flavors of version +information: + +* `['version']`: A condensed version string, rendered using the selected + style. This is the most commonly used value for the project's version + string. The default "pep440" style yields strings like `0.11`, + `0.11+2.g1076c97`, or `0.11+2.g1076c97.dirty`. See the "Styles" section + below for alternative styles. + +* `['full-revisionid']`: detailed revision identifier. For Git, this is the + full SHA1 commit id, e.g. "1076c978a8d3cfc70f408fe5974aa6c092c949ac". + +* `['date']`: Date and time of the latest `HEAD` commit. For Git, it is the + commit date in ISO 8601 format. This will be None if the date is not + available. + +* `['dirty']`: a boolean, True if the tree has uncommitted changes. Note that + this is only accurate if run in a VCS checkout, otherwise it is likely to + be False or None + +* `['error']`: if the version string could not be computed, this will be set + to a string describing the problem, otherwise it will be None. It may be + useful to throw an exception in setup.py if this is set, to avoid e.g. + creating tarballs with a version string of "unknown". + +Some variants are more useful than others. Including `full-revisionid` in a +bug report should allow developers to reconstruct the exact code being tested +(or indicate the presence of local changes that should be shared with the +developers). `version` is suitable for display in an "about" box or a CLI +`--version` output: it can be easily compared against release notes and lists +of bugs fixed in various releases. + +The installer adds the following text to your `__init__.py` to place a basic +version in `YOURPROJECT.__version__`: + + from ._version import get_versions + __version__ = get_versions()['version'] + del get_versions + +## Styles + +The setup.cfg `style=` configuration controls how the VCS information is +rendered into a version string. + +The default style, "pep440", produces a PEP440-compliant string, equal to the +un-prefixed tag name for actual releases, and containing an additional "local +version" section with more detail for in-between builds. For Git, this is +TAG[+DISTANCE.gHEX[.dirty]] , using information from `git describe --tags +--dirty --always`. For example "0.11+2.g1076c97.dirty" indicates that the +tree is like the "1076c97" commit but has uncommitted changes (".dirty"), and +that this commit is two revisions ("+2") beyond the "0.11" tag. For released +software (exactly equal to a known tag), the identifier will only contain the +stripped tag, e.g. "0.11". + +Other styles are available. See [details.md](details.md) in the Versioneer +source tree for descriptions. + +## Debugging + +Versioneer tries to avoid fatal errors: if something goes wrong, it will tend +to return a version of "0+unknown". To investigate the problem, run `setup.py +version`, which will run the version-lookup code in a verbose mode, and will +display the full contents of `get_versions()` (including the `error` string, +which may help identify what went wrong). + +## Known Limitations + +Some situations are known to cause problems for Versioneer. This details the +most significant ones. More can be found on Github +[issues page](https://github.com/python-versioneer/python-versioneer/issues). + +### Subprojects + +Versioneer has limited support for source trees in which `setup.py` is not in +the root directory (e.g. `setup.py` and `.git/` are *not* siblings). The are +two common reasons why `setup.py` might not be in the root: + +* Source trees which contain multiple subprojects, such as + [Buildbot](https://github.com/buildbot/buildbot), which contains both + "master" and "slave" subprojects, each with their own `setup.py`, + `setup.cfg`, and `tox.ini`. Projects like these produce multiple PyPI + distributions (and upload multiple independently-installable tarballs). +* Source trees whose main purpose is to contain a C library, but which also + provide bindings to Python (and perhaps other languages) in subdirectories. + +Versioneer will look for `.git` in parent directories, and most operations +should get the right version string. However `pip` and `setuptools` have bugs +and implementation details which frequently cause `pip install .` from a +subproject directory to fail to find a correct version string (so it usually +defaults to `0+unknown`). + +`pip install --editable .` should work correctly. `setup.py install` might +work too. + +Pip-8.1.1 is known to have this problem, but hopefully it will get fixed in +some later version. + +[Bug #38](https://github.com/python-versioneer/python-versioneer/issues/38) +is tracking this issue. The discussion in +[PR #61](https://github.com/python-versioneer/python-versioneer/pull/61) +describes the issue from the Versioneer side in more detail. +[pip PR#3176](https://github.com/pypa/pip/pull/3176) and +[pip PR#3615](https://github.com/pypa/pip/pull/3615) contain work to improve +pip to let Versioneer work correctly. + +Versioneer-0.16 and earlier only looked for a `.git` directory next to the +`setup.cfg`, so subprojects were completely unsupported with those releases. + +### Editable installs with setuptools <= 18.5 + +`setup.py develop` and `pip install --editable .` allow you to install a +project into a virtualenv once, then continue editing the source code (and +test) without re-installing after every change. + +"Entry-point scripts" (`setup(entry_points={"console_scripts": ..})`) are a +convenient way to specify executable scripts that should be installed along +with the python package. + +These both work as expected when using modern setuptools. When using +setuptools-18.5 or earlier, however, certain operations will cause +`pkg_resources.DistributionNotFound` errors when running the entrypoint +script, which must be resolved by re-installing the package. This happens +when the install happens with one version, then the egg_info data is +regenerated while a different version is checked out. Many setup.py commands +cause egg_info to be rebuilt (including `sdist`, `wheel`, and installing into +a different virtualenv), so this can be surprising. + +[Bug #83](https://github.com/python-versioneer/python-versioneer/issues/83) +describes this one, but upgrading to a newer version of setuptools should +probably resolve it. + + +## Updating Versioneer + +To upgrade your project to a new release of Versioneer, do the following: + +* install the new Versioneer (`pip install -U versioneer` or equivalent) +* edit `setup.cfg`, if necessary, to include any new configuration settings + indicated by the release notes. See [UPGRADING](./UPGRADING.md) for details. +* re-run `versioneer install` in your source tree, to replace + `SRC/_version.py` +* commit any changed files + +## Future Directions + +This tool is designed to make it easily extended to other version-control +systems: all VCS-specific components are in separate directories like +src/git/ . The top-level `versioneer.py` script is assembled from these +components by running make-versioneer.py . In the future, make-versioneer.py +will take a VCS name as an argument, and will construct a version of +`versioneer.py` that is specific to the given VCS. It might also take the +configuration arguments that are currently provided manually during +installation by editing setup.py . Alternatively, it might go the other +direction and include code from all supported VCS systems, reducing the +number of intermediate scripts. + +## Similar projects + +* [setuptools_scm](https://github.com/pypa/setuptools_scm/) - a non-vendored + build-time dependency +* [minver](https://github.com/jbweston/miniver) - a lightweight + reimplementation of versioneer +* [versioningit](https://github.com/jwodder/versioningit) - a PEP 518-based + setuptools plugin + +## License + +To make Versioneer easier to embed, all its code is dedicated to the public +domain. The `_version.py` that it creates is also in the public domain. +Specifically, both are released under the Creative Commons "Public Domain +Dedication" license (CC0-1.0), as described in +https://creativecommons.org/publicdomain/zero/1.0/ . + +[pypi-image]: https://img.shields.io/pypi/v/versioneer.svg +[pypi-url]: https://pypi.python.org/pypi/versioneer/ +[travis-image]: +https://img.shields.io/travis/com/python-versioneer/python-versioneer.svg +[travis-url]: https://travis-ci.com/github/python-versioneer/python-versioneer + +""" +# pylint:disable=invalid-name,import-outside-toplevel,missing-function-docstring +# pylint:disable=missing-class-docstring,too-many-branches,too-many-statements +# pylint:disable=raise-missing-from,too-many-lines,too-many-locals,import-error +# pylint:disable=too-few-public-methods,redefined-outer-name,consider-using-with +# pylint:disable=attribute-defined-outside-init,too-many-arguments + +import configparser +import errno +import functools +import json +import os +import re +import subprocess +import sys +from typing import Callable, Dict + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_root(): + """Get the project root directory. + + We require that all commands are run from the project root, i.e. the + directory that contains setup.py, setup.cfg, and versioneer.py . + """ + root = os.path.realpath(os.path.abspath(os.getcwd())) + setup_py = os.path.join(root, "setup.py") + versioneer_py = os.path.join(root, "versioneer.py") + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): + # allow 'python path/to/setup.py COMMAND' + root = os.path.dirname(os.path.realpath(os.path.abspath(sys.argv[0]))) + setup_py = os.path.join(root, "setup.py") + versioneer_py = os.path.join(root, "versioneer.py") + if not (os.path.exists(setup_py) or os.path.exists(versioneer_py)): + err = ( + "Versioneer was unable to run the project root directory. " + "Versioneer requires setup.py to be executed from " + "its immediate directory (like 'python setup.py COMMAND'), " + "or in a way that lets it use sys.argv[0] to find the root " + "(like 'python path/to/setup.py COMMAND')." + ) + raise VersioneerBadRootError(err) + try: + # Certain runtime workflows (setup.py install/develop in a setuptools + # tree) execute all dependencies in a single python process, so + # "versioneer" may be imported multiple times, and python's shared + # module-import table will cache the first one. So we can't use + # os.path.dirname(__file__), as that will find whichever + # versioneer.py was first imported, even in later projects. + my_path = os.path.realpath(os.path.abspath(__file__)) + me_dir = os.path.normcase(os.path.splitext(my_path)[0]) + vsr_dir = os.path.normcase(os.path.splitext(versioneer_py)[0]) + if me_dir != vsr_dir: + print( + "Warning: build in %s is using versioneer.py from %s" + % (os.path.dirname(my_path), versioneer_py) + ) + except NameError: + pass + return root + + +def get_config_from_root(root): + """Read the project setup.cfg file to determine Versioneer config.""" + # This might raise OSError (if setup.cfg is missing), or + # configparser.NoSectionError (if it lacks a [versioneer] section), or + # configparser.NoOptionError (if it lacks "VCS="). See the docstring at + # the top of versioneer.py for instructions on writing your setup.cfg . + setup_cfg = os.path.join(root, "setup.cfg") + parser = configparser.ConfigParser() + with open(setup_cfg, "r") as cfg_file: + parser.read_file(cfg_file) + VCS = parser.get("versioneer", "VCS") # mandatory + + # Dict-like interface for non-mandatory entries + section = parser["versioneer"] + + cfg = VersioneerConfig() + cfg.VCS = VCS + cfg.style = section.get("style", "") + cfg.versionfile_source = section.get("versionfile_source") + cfg.versionfile_build = section.get("versionfile_build") + cfg.tag_prefix = section.get("tag_prefix") + if cfg.tag_prefix in ("''", '""', None): + cfg.tag_prefix = "" + cfg.parentdir_prefix = section.get("parentdir_prefix") + cfg.verbose = section.get("verbose") + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +# these dictionaries contain VCS-specific tools +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + HANDLERS.setdefault(vcs, {})[method] = f + return f + + return decorate + + +def run_command( + commands, args, cwd=None, verbose=False, hide_stderr=False, env=None +): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen( + [command] + args, + cwd=cwd, + env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr else None), + **popen_kwargs, + ) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %s" % dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %s" % (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %s (error)" % dispcmd) + print("stdout was %s" % stdout) + return None, process.returncode + return stdout, process.returncode + + +LONG_VERSION_PY[ + "git" +] = r''' +# This file helps to compute a version number in source trees obtained from +# git-archive tarball (such as those provided by githubs download-from-tag +# feature). Distribution tarballs (built by setup.py sdist) and build +# directories (produced by setup.py build) will contain a much shorter file +# that just contains the computed version number. + +# This file is released into the public domain. Generated by +# versioneer-0.23 (https://github.com/python-versioneer/python-versioneer) + +"""Git implementation of _version.py.""" + +import errno +import os +import re +import subprocess +import sys +from typing import Callable, Dict +import functools + + +def get_keywords(): + """Get the keywords needed to look up the version information.""" + # these strings will be replaced by git during git-archive. + # setup.py/versioneer.py will grep for the variable names, so they must + # each be defined on a line of their own. _version.py will just call + # get_keywords(). + git_refnames = "%(DOLLAR)sFormat:%%d%(DOLLAR)s" + git_full = "%(DOLLAR)sFormat:%%H%(DOLLAR)s" + git_date = "%(DOLLAR)sFormat:%%ci%(DOLLAR)s" + keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} + return keywords + + +class VersioneerConfig: + """Container for Versioneer configuration parameters.""" + + +def get_config(): + """Create, populate and return the VersioneerConfig() object.""" + # these strings are filled in when 'setup.py versioneer' creates + # _version.py + cfg = VersioneerConfig() + cfg.VCS = "git" + cfg.style = "%(STYLE)s" + cfg.tag_prefix = "%(TAG_PREFIX)s" + cfg.parentdir_prefix = "%(PARENTDIR_PREFIX)s" + cfg.versionfile_source = "%(VERSIONFILE_SOURCE)s" + cfg.verbose = False + return cfg + + +class NotThisMethod(Exception): + """Exception raised if a method is not valid for the current scenario.""" + + +LONG_VERSION_PY: Dict[str, str] = {} +HANDLERS: Dict[str, Dict[str, Callable]] = {} + + +def register_vcs_handler(vcs, method): # decorator + """Create decorator to mark a method as the handler of a VCS.""" + def decorate(f): + """Store f in HANDLERS[vcs][method].""" + if vcs not in HANDLERS: + HANDLERS[vcs] = {} + HANDLERS[vcs][method] = f + return f + return decorate + + +def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, + env=None): + """Call the given command(s).""" + assert isinstance(commands, list) + process = None + + popen_kwargs = {} + if sys.platform == "win32": + # This hides the console window if pythonw.exe is used + startupinfo = subprocess.STARTUPINFO() + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + popen_kwargs["startupinfo"] = startupinfo + + for command in commands: + try: + dispcmd = str([command] + args) + # remember shell=False, so use git.cmd on windows, not just git + process = subprocess.Popen([command] + args, cwd=cwd, env=env, + stdout=subprocess.PIPE, + stderr=(subprocess.PIPE if hide_stderr + else None), **popen_kwargs) + break + except OSError: + e = sys.exc_info()[1] + if e.errno == errno.ENOENT: + continue + if verbose: + print("unable to run %%s" %% dispcmd) + print(e) + return None, None + else: + if verbose: + print("unable to find command, tried %%s" %% (commands,)) + return None, None + stdout = process.communicate()[0].strip().decode() + if process.returncode != 0: + if verbose: + print("unable to run %%s (error)" %% dispcmd) + print("stdout was %%s" %% stdout) + return None, process.returncode + return stdout, process.returncode + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return {"version": dirname[len(parentdir_prefix):], + "full-revisionid": None, + "dirty": False, "error": None, "date": None} + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print("Tried directories %%s but none started with prefix %%s" %% + (str(rootdirs), parentdir_prefix)) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG):] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %%d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r'\d', r)} + if verbose: + print("discarding '%%s', no digits" %% ",".join(refs - tags)) + if verbose: + print("likely tags: %%s" %% ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix):] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r'\d', r): + continue + if verbose: + print("picking %%s" %% r) + return {"version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": None, + "date": date} + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return {"version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, "error": "no suitable tags", "date": None} + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root, + hide_stderr=True) + if rc != 0: + if verbose: + print("Directory %%s not under git control" %% root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner(GITS, [ + "describe", "--tags", "--dirty", "--always", "--long", + "--match", f"{tag_prefix}[[:digit:]]*" + ], cwd=root) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"], + cwd=root) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[:git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = ("unable to parse git-describe output: '%%s'" + %% describe_out) + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%%s' doesn't start with prefix '%%s'" + print(fmt %% (full_tag, tag_prefix)) + pieces["error"] = ("tag '%%s' doesn't start with prefix '%%s'" + %% (full_tag, tag_prefix)) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix):] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%%ci", "HEAD"], cwd=root)[0].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%%d.g%%s" %% (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%%d.g%%s" %% (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%%d.g%%s" %% (pieces["distance"], + pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + rendered = tag_version + if post_version is not None: + rendered += ".post%%d.dev%%d" %% (post_version + 1, pieces["distance"]) + else: + rendered += ".post0.dev%%d" %% (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%%d" %% pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%%s" %% pieces["short"] + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%%s" %% pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%%s" %% pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%%s" %% pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%%d" %% pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%%d-g%%s" %% (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return {"version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None} + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%%s'" %% style) + + return {"version": rendered, "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], "error": None, + "date": pieces.get("date")} + + +def get_versions(): + """Get version information or return default if unable to do so.""" + # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have + # __file__, we can work backwards from there to the root. Some + # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which + # case we can only use expanded keywords. + + cfg = get_config() + verbose = cfg.verbose + + try: + return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, + verbose) + except NotThisMethod: + pass + + try: + root = os.path.realpath(__file__) + # versionfile_source is the relative path from the top of the source + # tree (where the .git directory might live) to this file. Invert + # this to find the root from __file__. + for _ in cfg.versionfile_source.split('/'): + root = os.path.dirname(root) + except NameError: + return {"version": "0+unknown", "full-revisionid": None, + "dirty": None, + "error": "unable to find root of source tree", + "date": None} + + try: + pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) + return render(pieces, cfg.style) + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + except NotThisMethod: + pass + + return {"version": "0+unknown", "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", "date": None} +''' + + +@register_vcs_handler("git", "get_keywords") +def git_get_keywords(versionfile_abs): + """Extract version information from the given file.""" + # the code embedded in _version.py can just fetch the value of these + # keywords. When used from setup.py, we don't want to import _version.py, + # so we do it with a regexp instead. This function is not used from + # _version.py. + keywords = {} + try: + with open(versionfile_abs, "r") as fobj: + for line in fobj: + if line.strip().startswith("git_refnames ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["refnames"] = mo.group(1) + if line.strip().startswith("git_full ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["full"] = mo.group(1) + if line.strip().startswith("git_date ="): + mo = re.search(r'=\s*"(.*)"', line) + if mo: + keywords["date"] = mo.group(1) + except OSError: + pass + return keywords + + +@register_vcs_handler("git", "keywords") +def git_versions_from_keywords(keywords, tag_prefix, verbose): + """Get version information from git keywords.""" + if "refnames" not in keywords: + raise NotThisMethod("Short version file found") + date = keywords.get("date") + if date is not None: + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + + # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant + # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 + # -like" string, which we must then edit to make compliant), because + # it's been around since git-1.5.3, and it's too difficult to + # discover which version we're using, or to work around using an + # older one. + date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + refnames = keywords["refnames"].strip() + if refnames.startswith("$Format"): + if verbose: + print("keywords are unexpanded, not using") + raise NotThisMethod("unexpanded keywords, not a git-archive tarball") + refs = {r.strip() for r in refnames.strip("()").split(",")} + # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of + # just "foo-1.0". If we see a "tag: " prefix, prefer those. + TAG = "tag: " + tags = {r[len(TAG) :] for r in refs if r.startswith(TAG)} + if not tags: + # Either we're using git < 1.8.3, or there really are no tags. We use + # a heuristic: assume all version tags have a digit. The old git %d + # expansion behaves like git log --decorate=short and strips out the + # refs/heads/ and refs/tags/ prefixes that would let us distinguish + # between branches and tags. By ignoring refnames without digits, we + # filter out many common branch names like "release" and + # "stabilization", as well as "HEAD" and "master". + tags = {r for r in refs if re.search(r"\d", r)} + if verbose: + print("discarding '%s', no digits" % ",".join(refs - tags)) + if verbose: + print("likely tags: %s" % ",".join(sorted(tags))) + for ref in sorted(tags): + # sorting will prefer e.g. "2.0" over "2.0rc1" + if ref.startswith(tag_prefix): + r = ref[len(tag_prefix) :] + # Filter out refs that exactly match prefix or that don't start + # with a number once the prefix is stripped (mostly a concern + # when prefix is '') + if not re.match(r"\d", r): + continue + if verbose: + print("picking %s" % r) + return { + "version": r, + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": None, + "date": date, + } + # no suitable tags, so version is "0+unknown", but full hex is still there + if verbose: + print("no suitable tags, using unknown + full revision id") + return { + "version": "0+unknown", + "full-revisionid": keywords["full"].strip(), + "dirty": False, + "error": "no suitable tags", + "date": None, + } + + +@register_vcs_handler("git", "pieces_from_vcs") +def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): + """Get version from 'git describe' in the root of the source tree. + + This only gets called if the git-archive 'subst' keywords were *not* + expanded, and _version.py hasn't already been rewritten with a short + version string, meaning we're inside a checked out source tree. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + + # GIT_DIR can interfere with correct operation of Versioneer. + # It may be intended to be passed to the Versioneer-versioned project, + # but that should not change where we get our version from. + env = os.environ.copy() + env.pop("GIT_DIR", None) + runner = functools.partial(runner, env=env) + + _, rc = runner( + GITS, ["rev-parse", "--git-dir"], cwd=root, hide_stderr=True + ) + if rc != 0: + if verbose: + print("Directory %s not under git control" % root) + raise NotThisMethod("'git rev-parse --git-dir' returned error") + + # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] + # if there isn't one, this yields HEX[-dirty] (no NUM) + describe_out, rc = runner( + GITS, + [ + "describe", + "--tags", + "--dirty", + "--always", + "--long", + "--match", + f"{tag_prefix}[[:digit:]]*", + ], + cwd=root, + ) + # --long was added in git-1.5.5 + if describe_out is None: + raise NotThisMethod("'git describe' failed") + describe_out = describe_out.strip() + full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root) + if full_out is None: + raise NotThisMethod("'git rev-parse' failed") + full_out = full_out.strip() + + pieces = {} + pieces["long"] = full_out + pieces["short"] = full_out[:7] # maybe improved later + pieces["error"] = None + + branch_name, rc = runner( + GITS, ["rev-parse", "--abbrev-ref", "HEAD"], cwd=root + ) + # --abbrev-ref was added in git-1.6.3 + if rc != 0 or branch_name is None: + raise NotThisMethod("'git rev-parse --abbrev-ref' returned error") + branch_name = branch_name.strip() + + if branch_name == "HEAD": + # If we aren't exactly on a branch, pick a branch which represents + # the current commit. If all else fails, we are on a branchless + # commit. + branches, rc = runner(GITS, ["branch", "--contains"], cwd=root) + # --contains was added in git-1.5.4 + if rc != 0 or branches is None: + raise NotThisMethod("'git branch --contains' returned error") + branches = branches.split("\n") + + # Remove the first line if we're running detached + if "(" in branches[0]: + branches.pop(0) + + # Strip off the leading "* " from the list of branches. + branches = [branch[2:] for branch in branches] + if "master" in branches: + branch_name = "master" + elif not branches: + branch_name = None + else: + # Pick the first branch that is returned. Good or bad. + branch_name = branches[0] + + pieces["branch"] = branch_name + + # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] + # TAG might have hyphens. + git_describe = describe_out + + # look for -dirty suffix + dirty = git_describe.endswith("-dirty") + pieces["dirty"] = dirty + if dirty: + git_describe = git_describe[: git_describe.rindex("-dirty")] + + # now we have TAG-NUM-gHEX or HEX + + if "-" in git_describe: + # TAG-NUM-gHEX + mo = re.search(r"^(.+)-(\d+)-g([0-9a-f]+)$", git_describe) + if not mo: + # unparsable. Maybe git-describe is misbehaving? + pieces["error"] = ( + "unable to parse git-describe output: '%s'" % describe_out + ) + return pieces + + # tag + full_tag = mo.group(1) + if not full_tag.startswith(tag_prefix): + if verbose: + fmt = "tag '%s' doesn't start with prefix '%s'" + print(fmt % (full_tag, tag_prefix)) + pieces["error"] = "tag '%s' doesn't start with prefix '%s'" % ( + full_tag, + tag_prefix, + ) + return pieces + pieces["closest-tag"] = full_tag[len(tag_prefix) :] + + # distance: number of commits since tag + pieces["distance"] = int(mo.group(2)) + + # commit: short hex revision ID + pieces["short"] = mo.group(3) + + else: + # HEX: no tags + pieces["closest-tag"] = None + out, rc = runner(GITS, ["rev-list", "HEAD", "--left-right"], cwd=root) + pieces["distance"] = len(out.split()) # total number of commits + + # commit date: see ISO-8601 comment in git_versions_from_keywords() + date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[ + 0 + ].strip() + # Use only the last line. Previous lines may contain GPG signature + # information. + date = date.splitlines()[-1] + pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) + + return pieces + + +def do_vcs_install(versionfile_source, ipy): + """Git-specific installation logic for Versioneer. + + For Git, this means creating/changing .gitattributes to mark _version.py + for export-subst keyword substitution. + """ + GITS = ["git"] + if sys.platform == "win32": + GITS = ["git.cmd", "git.exe"] + files = [versionfile_source] + if ipy: + files.append(ipy) + try: + my_path = __file__ + if my_path.endswith(".pyc") or my_path.endswith(".pyo"): + my_path = os.path.splitext(my_path)[0] + ".py" + versioneer_file = os.path.relpath(my_path) + except NameError: + versioneer_file = "versioneer.py" + files.append(versioneer_file) + present = False + try: + with open(".gitattributes", "r") as fobj: + for line in fobj: + if line.strip().startswith(versionfile_source): + if "export-subst" in line.strip().split()[1:]: + present = True + break + except OSError: + pass + if not present: + with open(".gitattributes", "a+") as fobj: + fobj.write(f"{versionfile_source} export-subst\n") + files.append(".gitattributes") + run_command(GITS, ["add", "--"] + files) + + +def versions_from_parentdir(parentdir_prefix, root, verbose): + """Try to determine the version from the parent directory name. + + Source tarballs conventionally unpack into a directory that includes both + the project name and a version string. We will also support searching up + two directory levels for an appropriately named parent directory + """ + rootdirs = [] + + for _ in range(3): + dirname = os.path.basename(root) + if dirname.startswith(parentdir_prefix): + return { + "version": dirname[len(parentdir_prefix) :], + "full-revisionid": None, + "dirty": False, + "error": None, + "date": None, + } + rootdirs.append(root) + root = os.path.dirname(root) # up a level + + if verbose: + print( + "Tried directories %s but none started with prefix %s" + % (str(rootdirs), parentdir_prefix) + ) + raise NotThisMethod("rootdir doesn't start with parentdir_prefix") + + +SHORT_VERSION_PY = """ +# This file was generated by 'versioneer.py' (0.23) from +# revision-control system data, or from the parent directory name of an +# unpacked source archive. Distribution tarballs contain a pre-generated copy +# of this file. + +import json + +version_json = ''' +%s +''' # END VERSION_JSON + + +def get_versions(): + return json.loads(version_json) +""" + + +def versions_from_file(filename): + """Try to determine the version from _version.py if present.""" + try: + with open(filename) as f: + contents = f.read() + except OSError: + raise NotThisMethod("unable to read _version.py") + mo = re.search( + r"version_json = '''\n(.*)''' # END VERSION_JSON", + contents, + re.M | re.S, + ) + if not mo: + mo = re.search( + r"version_json = '''\r\n(.*)''' # END VERSION_JSON", + contents, + re.M | re.S, + ) + if not mo: + raise NotThisMethod("no version_json in _version.py") + return json.loads(mo.group(1)) + + +def write_to_version_file(filename, versions): + """Write the given version number to the given _version.py file.""" + os.unlink(filename) + contents = json.dumps( + versions, sort_keys=True, indent=1, separators=(",", ": ") + ) + with open(filename, "w") as f: + f.write(SHORT_VERSION_PY % contents) + + print("set %s to '%s'" % (filename, versions["version"])) + + +def plus_or_dot(pieces): + """Return a + if we don't already have one, else return a .""" + if "+" in pieces.get("closest-tag", ""): + return "." + return "+" + + +def render_pep440(pieces): + """Build up version string, with post-release "local version identifier". + + Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you + get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty + + Exceptions: + 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_branch(pieces): + """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] . + + The ".dev0" means not master branch. Note that .dev0 sorts backwards + (a feature branch will appear "older" than the master branch). + + Exceptions: + 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0" + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+untagged.%d.g%s" % (pieces["distance"], pieces["short"]) + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def pep440_split_post(ver): + """Split pep440 version string at the post-release segment. + + Returns the release segments before the post-release and the + post-release version number (or -1 if no post-release segment is present). + """ + vc = str.split(ver, ".post") + return vc[0], int(vc[1] or 0) if len(vc) == 2 else None + + +def render_pep440_pre(pieces): + """TAG[.postN.devDISTANCE] -- No -dirty. + + Exceptions: + 1: no tags. 0.post0.devDISTANCE + """ + if pieces["closest-tag"]: + if pieces["distance"]: + # update the post release segment + tag_version, post_version = pep440_split_post( + pieces["closest-tag"] + ) + rendered = tag_version + if post_version is not None: + rendered += ".post%d.dev%d" % ( + post_version + 1, + pieces["distance"], + ) + else: + rendered += ".post0.dev%d" % (pieces["distance"]) + else: + # no commits, use the tag as the version + rendered = pieces["closest-tag"] + else: + # exception #1 + rendered = "0.post0.dev%d" % pieces["distance"] + return rendered + + +def render_pep440_post(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX] . + + The ".dev0" means dirty. Note that .dev0 sorts backwards + (a dirty tree will appear "older" than the corresponding clean one), + but you shouldn't be releasing software with -dirty anyways. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + return rendered + + +def render_pep440_post_branch(pieces): + """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] . + + The ".dev0" means not master branch. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += plus_or_dot(pieces) + rendered += "g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["branch"] != "master": + rendered += ".dev0" + rendered += "+g%s" % pieces["short"] + if pieces["dirty"]: + rendered += ".dirty" + return rendered + + +def render_pep440_old(pieces): + """TAG[.postDISTANCE[.dev0]] . + + The ".dev0" means dirty. + + Exceptions: + 1: no tags. 0.postDISTANCE[.dev0] + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"] or pieces["dirty"]: + rendered += ".post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + else: + # exception #1 + rendered = "0.post%d" % pieces["distance"] + if pieces["dirty"]: + rendered += ".dev0" + return rendered + + +def render_git_describe(pieces): + """TAG[-DISTANCE-gHEX][-dirty]. + + Like 'git describe --tags --dirty --always'. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + if pieces["distance"]: + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render_git_describe_long(pieces): + """TAG-DISTANCE-gHEX[-dirty]. + + Like 'git describe --tags --dirty --always -long'. + The distance/hash is unconditional. + + Exceptions: + 1: no tags. HEX[-dirty] (note: no 'g' prefix) + """ + if pieces["closest-tag"]: + rendered = pieces["closest-tag"] + rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) + else: + # exception #1 + rendered = pieces["short"] + if pieces["dirty"]: + rendered += "-dirty" + return rendered + + +def render(pieces, style): + """Render the given version pieces into the requested style.""" + if pieces["error"]: + return { + "version": "unknown", + "full-revisionid": pieces.get("long"), + "dirty": None, + "error": pieces["error"], + "date": None, + } + + if not style or style == "default": + style = "pep440" # the default + + if style == "pep440": + rendered = render_pep440(pieces) + elif style == "pep440-branch": + rendered = render_pep440_branch(pieces) + elif style == "pep440-pre": + rendered = render_pep440_pre(pieces) + elif style == "pep440-post": + rendered = render_pep440_post(pieces) + elif style == "pep440-post-branch": + rendered = render_pep440_post_branch(pieces) + elif style == "pep440-old": + rendered = render_pep440_old(pieces) + elif style == "git-describe": + rendered = render_git_describe(pieces) + elif style == "git-describe-long": + rendered = render_git_describe_long(pieces) + else: + raise ValueError("unknown style '%s'" % style) + + return { + "version": rendered, + "full-revisionid": pieces["long"], + "dirty": pieces["dirty"], + "error": None, + "date": pieces.get("date"), + } + + +class VersioneerBadRootError(Exception): + """The project root directory is unknown or missing key files.""" + + +def get_versions(verbose=False): + """Get the project version from whatever source is available. + + Returns dict with two keys: 'version' and 'full'. + """ + if "versioneer" in sys.modules: + # see the discussion in cmdclass.py:get_cmdclass() + del sys.modules["versioneer"] + + root = get_root() + cfg = get_config_from_root(root) + + assert cfg.VCS is not None, "please set [versioneer]VCS= in setup.cfg" + handlers = HANDLERS.get(cfg.VCS) + assert handlers, "unrecognized VCS '%s'" % cfg.VCS + verbose = verbose or cfg.verbose + assert ( + cfg.versionfile_source is not None + ), "please set versioneer.versionfile_source" + assert cfg.tag_prefix is not None, "please set versioneer.tag_prefix" + + versionfile_abs = os.path.join(root, cfg.versionfile_source) + + # extract version from first of: _version.py, VCS command (e.g. 'git + # describe'), parentdir. This is meant to work for developers using a + # source checkout, for users of a tarball created by 'setup.py sdist', + # and for users of a tarball/zipball created by 'git archive' or github's + # download-from-tag feature or the equivalent in other VCSes. + + get_keywords_f = handlers.get("get_keywords") + from_keywords_f = handlers.get("keywords") + if get_keywords_f and from_keywords_f: + try: + keywords = get_keywords_f(versionfile_abs) + ver = from_keywords_f(keywords, cfg.tag_prefix, verbose) + if verbose: + print("got version from expanded keyword %s" % ver) + return ver + except NotThisMethod: + pass + + try: + ver = versions_from_file(versionfile_abs) + if verbose: + print("got version from file %s %s" % (versionfile_abs, ver)) + return ver + except NotThisMethod: + pass + + from_vcs_f = handlers.get("pieces_from_vcs") + if from_vcs_f: + try: + pieces = from_vcs_f(cfg.tag_prefix, root, verbose) + ver = render(pieces, cfg.style) + if verbose: + print("got version from VCS %s" % ver) + return ver + except NotThisMethod: + pass + + try: + if cfg.parentdir_prefix: + ver = versions_from_parentdir(cfg.parentdir_prefix, root, verbose) + if verbose: + print("got version from parentdir %s" % ver) + return ver + except NotThisMethod: + pass + + if verbose: + print("unable to compute version") + + return { + "version": "0+unknown", + "full-revisionid": None, + "dirty": None, + "error": "unable to compute version", + "date": None, + } + + +def get_version(): + """Get the short version string for this project.""" + return get_versions()["version"] + + +def get_cmdclass(cmdclass=None): + """Get the custom setuptools subclasses used by Versioneer. + + If the package uses a different cmdclass (e.g. one from numpy), it + should be provide as an argument. + """ + if "versioneer" in sys.modules: + del sys.modules["versioneer"] + # this fixes the "python setup.py develop" case (also 'install' and + # 'easy_install .'), in which subdependencies of the main project are + # built (using setup.py bdist_egg) in the same python process. Assume + # a main project A and a dependency B, which use different versions + # of Versioneer. A's setup.py imports A's Versioneer, leaving it in + # sys.modules by the time B's setup.py is executed, causing B to run + # with the wrong versioneer. Setuptools wraps the sub-dep builds in a + # sandbox that restores sys.modules to it's pre-build state, so the + # parent is protected against the child's "import versioneer". By + # removing ourselves from sys.modules here, before the child build + # happens, we protect the child from the parent's versioneer too. + # Also see https://github.com/python-versioneer/python-versioneer/issues/52 + + cmds = {} if cmdclass is None else cmdclass.copy() + + # we add "version" to setuptools + from setuptools import Command + + class cmd_version(Command): + description = "report generated version string" + user_options = [] + boolean_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + vers = get_versions(verbose=True) + print("Version: %s" % vers["version"]) + print(" full-revisionid: %s" % vers.get("full-revisionid")) + print(" dirty: %s" % vers.get("dirty")) + print(" date: %s" % vers.get("date")) + if vers["error"]: + print(" error: %s" % vers["error"]) + + cmds["version"] = cmd_version + + # we override "build_py" in setuptools + # + # most invocation pathways end up running build_py: + # distutils/build -> build_py + # distutils/install -> distutils/build ->.. + # setuptools/bdist_wheel -> distutils/install ->.. + # setuptools/bdist_egg -> distutils/install_lib -> build_py + # setuptools/install -> bdist_egg ->.. + # setuptools/develop -> ? + # pip install: + # copies source tree to a tempdir before running egg_info/etc + # if .git isn't copied too, 'git describe' will fail + # then does setup.py bdist_wheel, or sometimes setup.py install + # setup.py egg_info -> ? + + # pip install -e . and setuptool/editable_wheel will invoke build_py + # but the build_py command is not expected to copy any files. + + # we override different "build_py" commands for both environments + if "build_py" in cmds: + _build_py = cmds["build_py"] + else: + from setuptools.command.build_py import build_py as _build_py + + class cmd_build_py(_build_py): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + _build_py.run(self) + if getattr(self, "editable_mode", False): + # During editable installs `.py` and data files are + # not copied to build_lib + return + # now locate _version.py in the new build/ directory and replace + # it with an updated value + if cfg.versionfile_build: + target_versionfile = os.path.join( + self.build_lib, cfg.versionfile_build + ) + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + cmds["build_py"] = cmd_build_py + + if "build_ext" in cmds: + _build_ext = cmds["build_ext"] + else: + from setuptools.command.build_ext import build_ext as _build_ext + + class cmd_build_ext(_build_ext): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + _build_ext.run(self) + if self.inplace: + # build_ext --inplace will only build extensions in + # build/lib<..> dir with no _version.py to write to. + # As in place builds will already have a _version.py + # in the module dir, we do not need to write one. + return + # now locate _version.py in the new build/ directory and replace + # it with an updated value + target_versionfile = os.path.join( + self.build_lib, cfg.versionfile_build + ) + if not os.path.exists(target_versionfile): + print( + f"Warning: {target_versionfile} does not exist, skipping " + "version update. This can happen if you are running build_ext " + "without first running build_py." + ) + return + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + cmds["build_ext"] = cmd_build_ext + + if "cx_Freeze" in sys.modules: # cx_freeze enabled? + from cx_Freeze.dist import build_exe as _build_exe + + # nczeczulin reports that py2exe won't like the pep440-style string + # as FILEVERSION, but it can be used for PRODUCTVERSION, e.g. + # setup(console=[{ + # "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION + # "product_version": versioneer.get_version(), + # ... + + class cmd_build_exe(_build_exe): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + target_versionfile = cfg.versionfile_source + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + _build_exe.run(self) + os.unlink(target_versionfile) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + cmds["build_exe"] = cmd_build_exe + del cmds["build_py"] + + if "py2exe" in sys.modules: # py2exe enabled? + from py2exe.distutils_buildexe import py2exe as _py2exe + + class cmd_py2exe(_py2exe): + def run(self): + root = get_root() + cfg = get_config_from_root(root) + versions = get_versions() + target_versionfile = cfg.versionfile_source + print("UPDATING %s" % target_versionfile) + write_to_version_file(target_versionfile, versions) + + _py2exe.run(self) + os.unlink(target_versionfile) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + cmds["py2exe"] = cmd_py2exe + + # sdist farms its file list building out to egg_info + if "egg_info" in cmds: + _sdist = cmds["egg_info"] + else: + from setuptools.command.egg_info import egg_info as _egg_info + + class cmd_egg_info(_egg_info): + def find_sources(self): + # egg_info.find_sources builds the manifest list and writes it + # in one shot + super().find_sources() + + # Modify the filelist and normalize it + root = get_root() + cfg = get_config_from_root(root) + self.filelist.append("versioneer.py") + if cfg.versionfile_source: + # There are rare cases where versionfile_source might not be + # included by default, so we must be explicit + self.filelist.append(cfg.versionfile_source) + self.filelist.sort() + self.filelist.remove_duplicates() + + # The write method is hidden in the manifest_maker instance that + # generated the filelist and was thrown away + # We will instead replicate their final normalization (to unicode, + # and POSIX-style paths) + from setuptools import unicode_utils + + normalized = [ + unicode_utils.filesys_decode(f).replace(os.sep, "/") + for f in self.filelist.files + ] + + manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") + with open(manifest_filename, "w") as fobj: + fobj.write("\n".join(normalized)) + + cmds["egg_info"] = cmd_egg_info + + # we override different "sdist" commands for both environments + if "sdist" in cmds: + _sdist = cmds["sdist"] + else: + from setuptools.command.sdist import sdist as _sdist + + class cmd_sdist(_sdist): + def run(self): + versions = get_versions() + self._versioneer_generated_versions = versions + # unless we update this, the command will keep using the old + # version + self.distribution.metadata.version = versions["version"] + return _sdist.run(self) + + def make_release_tree(self, base_dir, files): + root = get_root() + cfg = get_config_from_root(root) + _sdist.make_release_tree(self, base_dir, files) + # now locate _version.py in the new base_dir directory + # (remembering that it may be a hardlink) and replace it with an + # updated value + target_versionfile = os.path.join(base_dir, cfg.versionfile_source) + print("UPDATING %s" % target_versionfile) + write_to_version_file( + target_versionfile, self._versioneer_generated_versions + ) + + cmds["sdist"] = cmd_sdist + + return cmds + + +CONFIG_ERROR = """ +setup.cfg is missing the necessary Versioneer configuration. You need +a section like: + + [versioneer] + VCS = git + style = pep440 + versionfile_source = src/myproject/_version.py + versionfile_build = myproject/_version.py + tag_prefix = + parentdir_prefix = myproject- + +You will also need to edit your setup.py to use the results: + + import versioneer + setup(version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), ...) + +Please read the docstring in ./versioneer.py for configuration instructions, +edit setup.cfg, and re-run the installer or 'python versioneer.py setup'. +""" + +SAMPLE_CONFIG = """ +# See the docstring in versioneer.py for instructions. Note that you must +# re-run 'versioneer.py setup' after changing this section, and commit the +# resulting files. + +[versioneer] +#VCS = git +#style = pep440 +#versionfile_source = +#versionfile_build = +#tag_prefix = +#parentdir_prefix = + +""" + +OLD_SNIPPET = """ +from ._version import get_versions +__version__ = get_versions()['version'] +del get_versions +""" + +INIT_PY_SNIPPET = """ +from . import {0} +__version__ = {0}.get_versions()['version'] +""" + + +def do_setup(): + """Do main VCS-independent setup function for installing Versioneer.""" + root = get_root() + try: + cfg = get_config_from_root(root) + except ( + OSError, + configparser.NoSectionError, + configparser.NoOptionError, + ) as e: + if isinstance(e, (OSError, configparser.NoSectionError)): + print( + "Adding sample versioneer config to setup.cfg", file=sys.stderr + ) + with open(os.path.join(root, "setup.cfg"), "a") as f: + f.write(SAMPLE_CONFIG) + print(CONFIG_ERROR, file=sys.stderr) + return 1 + + print(" creating %s" % cfg.versionfile_source) + with open(cfg.versionfile_source, "w") as f: + LONG = LONG_VERSION_PY[cfg.VCS] + f.write( + LONG + % { + "DOLLAR": "$", + "STYLE": cfg.style, + "TAG_PREFIX": cfg.tag_prefix, + "PARENTDIR_PREFIX": cfg.parentdir_prefix, + "VERSIONFILE_SOURCE": cfg.versionfile_source, + } + ) + + ipy = os.path.join(os.path.dirname(cfg.versionfile_source), "__init__.py") + if os.path.exists(ipy): + try: + with open(ipy, "r") as f: + old = f.read() + except OSError: + old = "" + module = os.path.splitext(os.path.basename(cfg.versionfile_source))[0] + snippet = INIT_PY_SNIPPET.format(module) + if OLD_SNIPPET in old: + print(" replacing boilerplate in %s" % ipy) + with open(ipy, "w") as f: + f.write(old.replace(OLD_SNIPPET, snippet)) + elif snippet not in old: + print(" appending to %s" % ipy) + with open(ipy, "a") as f: + f.write(snippet) + else: + print(" %s unmodified" % ipy) + else: + print(" %s doesn't exist, ok" % ipy) + ipy = None + + # Make VCS-specific changes. For git, this means creating/changing + # .gitattributes to mark _version.py for export-subst keyword + # substitution. + do_vcs_install(cfg.versionfile_source, ipy) + return 0 + + +def scan_setup_py(): + """Validate the contents of setup.py against Versioneer's expectations.""" + found = set() + setters = False + errors = 0 + with open("setup.py", "r") as f: + for line in f.readlines(): + if "import versioneer" in line: + found.add("import") + if "versioneer.get_cmdclass()" in line: + found.add("cmdclass") + if "versioneer.get_version()" in line: + found.add("get_version") + if "versioneer.VCS" in line: + setters = True + if "versioneer.versionfile_source" in line: + setters = True + if len(found) != 3: + print("") + print("Your setup.py appears to be missing some important items") + print("(but I might be wrong). Please make sure it has something") + print("roughly like the following:") + print("") + print(" import versioneer") + print(" setup( version=versioneer.get_version(),") + print(" cmdclass=versioneer.get_cmdclass(), ...)") + print("") + errors += 1 + if setters: + print("You should remove lines like 'versioneer.VCS = ' and") + print("'versioneer.versionfile_source = ' . This configuration") + print("now lives in setup.cfg, and should be removed from setup.py") + print("") + errors += 1 + return errors + + +if __name__ == "__main__": + cmd = sys.argv[1] + if cmd == "setup": + errors = do_setup() + errors += scan_setup_py() + if errors: + sys.exit(1) From 7e985d34d88a3bd9339fbf9330ca4d0a69d50d06 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 22 Aug 2022 08:22:33 -0700 Subject: [PATCH 081/212] ignore versioneer in all subpackages --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0bc4d3e578c..29cc0e5396d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: args: ["--config=setup.cfg"] files: python/.*\.(py|pyx|pxd)$ types: [file] - exclude: python/strings_udf/versioneer.py + exclude: python/.*/versioneer.py - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v0.782' hooks: From 1406d887b4ba2010ff44916c4817cd41f3a06ebb Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 22 Aug 2022 08:47:00 -0700 Subject: [PATCH 082/212] link to libcudf_strings_udf during cython build --- python/strings_udf/strings_udf/_lib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/strings_udf/_lib/CMakeLists.txt b/python/strings_udf/strings_udf/_lib/CMakeLists.txt index d9b69aca60e..3cd81d884c0 100644 --- a/python/strings_udf/strings_udf/_lib/CMakeLists.txt +++ b/python/strings_udf/strings_udf/_lib/CMakeLists.txt @@ -13,7 +13,7 @@ # ============================================================================= set(cython_sources cudf_jit_udf.pyx tables.pyx) -set(linked_libraries cudf::cudf) +set(linked_libraries cudf::cudf cudf_strings_udf) rapids_cython_create_modules( CXX SOURCE_FILES "${cython_sources}" From 29bc117cd17978c006bde9c6f6d711d84d26e631 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 22 Aug 2022 08:54:29 -0700 Subject: [PATCH 083/212] small fixes --- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 6 +++--- python/strings_udf/strings_udf/tests/utils.py | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 5d03019b1af..8fd4fe9f8c5 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -13,14 +13,14 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -from strings_udf._lib.cpp.strings_udf cimport ( - to_string_view_array as cpp_to_string_view_array, -) from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type +from strings_udf._lib.cpp.strings_udf cimport ( + to_string_view_array as cpp_to_string_view_array, +) import numpy as np diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 2a8f22da572..657287d6d8b 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -7,13 +7,12 @@ from numba.core.typing import signature as nb_signature from numba.types import CPointer, void +import cudf +from cudf.testing._utils import assert_eq from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view -import cudf -from cudf.testing._utils import assert_eq - def run_udf_test(data, func, dtype): dtype = np.dtype(dtype) From 2aafe03f2b9314ab5211af80f172d6ef223864f3 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 22 Aug 2022 09:09:04 -0700 Subject: [PATCH 084/212] update properties of setup.cfg and rerun pre-commit --- python/strings_udf/setup.cfg | 2 +- python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd | 3 +-- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 4 ++-- python/strings_udf/strings_udf/tests/utils.py | 1 + 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/python/strings_udf/setup.cfg b/python/strings_udf/setup.cfg index c963b3dc7a7..9f29b26b5e0 100644 --- a/python/strings_udf/setup.cfg +++ b/python/strings_udf/setup.cfg @@ -21,7 +21,7 @@ known_dask= dask_cuda known_rapids= rmm - strings_udf + cudf known_first_party= strings_udf default_section=THIRDPARTY diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index e0526d52136..c59950d536f 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -5,11 +5,10 @@ from libcpp.memory cimport unique_ptr from libcpp.string cimport string from libcpp.vector cimport vector -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer - from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer cdef extern from "udf_apis.hpp": diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 8fd4fe9f8c5..2b7dcd81637 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -12,12 +12,12 @@ from libcpp.vector cimport vector from cudf.core.buffer import Buffer -from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer - from cudf._lib.column cimport Column from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.types cimport size_type +from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer + from strings_udf._lib.cpp.strings_udf cimport ( to_string_view_array as cpp_to_string_view_array, ) diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 657287d6d8b..01ed86eb497 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -9,6 +9,7 @@ import cudf from cudf.testing._utils import assert_eq + from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view From d2bc8995440502a47ba90dcde667d42db89f89c8 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 22 Aug 2022 10:47:42 -0700 Subject: [PATCH 085/212] pyarrow 8->9 in meta.yaml --- conda/recipes/strings_udf/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index 58ae0754c92..18dd0cbea0d 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -40,7 +40,7 @@ requirements: - setuptools - numba >=0.54 - dlpack>=0.5,<0.6.0a0 - - pyarrow =8 + - pyarrow =9 - libcudf ={{ version }} - cudf ={{ version }} - rmm ={{ minor_version }} From 1a5341aa7c9be311e9976feee7e2d7f287873cd6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 24 Aug 2022 14:57:09 -0500 Subject: [PATCH 086/212] updates from local CI testing --- build.sh | 4 +--- ci/gpu/build.sh | 4 ++-- python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 1d9606d29d2..ba18f33650a 100755 --- a/build.sh +++ b/build.sh @@ -340,13 +340,11 @@ if buildAll || hasArg strings_udf; then ls cmake -S ./ -B build -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ cmake --build build - ls + cmake --install ./build cd ${REPODIR}/python/strings_udf python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} if [[ ${INSTALL_TARGET} != "" ]]; then python setup.py install --single-version-externally-managed --record=record.txt -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} - cd ${REPODIR}/python/strings_udf/cpp/ - cmake --install ./build fi fi diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index ed09959b117..46fb92e8013 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -121,11 +121,11 @@ if [[ -z "$PROJECT_FLASH" || "$PROJECT_FLASH" == "0" ]]; then install_dask ################################################################################ - # BUILD - Build libcudf, cuDF, libcudf_kafka, and dask_cudf from source + # BUILD - Build libcudf, cuDF, libcudf_kafka, dask_cudf, and strings_udf from source ################################################################################ gpuci_logger "Build from source" - "$WORKSPACE/build.sh" clean libcudf cudf dask_cudf libcudf_kafka cudf_kafka benchmarks tests --ptds + "$WORKSPACE/build.sh" clean libcudf cudf dask_cudf libcudf_kafka cudf_kafka strings_udf benchmarks tests --ptds ################################################################################ # TEST - Run GoogleTest diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index c59950d536f..653ddae4b29 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -11,7 +11,7 @@ from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -cdef extern from "udf_apis.hpp": +cdef extern from "cudf/strings/udf/udf_apis.hpp": cdef cppclass udf_module cdef unique_ptr[udf_module] create_udf_module(string, vector[string]) cdef unique_ptr[column] call_udf( From b293eb64e498fa64dc65088021fbb5316cc33926 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 24 Aug 2022 17:19:24 -0500 Subject: [PATCH 087/212] simplify setup.py --- python/strings_udf/setup.py | 47 +------------------------------------ 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index aa024cee7d7..3069a5e6ffb 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -3,9 +3,6 @@ import os import re import shutil -import subprocess -import sys -from distutils.spawn import find_executable from setuptools import find_packages from skbuild import setup @@ -85,50 +82,8 @@ def get_cuda_version_from_header(cuda_include_dir, delimeter=""): ) -class build_ext_and_proto(build_ext): - def run(self): - # Get protoc - protoc = None - if "PROTOC" in os.environ and os.path.exists(os.environ["PROTOC"]): - protoc = os.environ["PROTOC"] - else: - protoc = find_executable("protoc") - if protoc is None: - sys.stderr.write("protoc not found") - sys.exit(1) - - # Build .proto file - for source in [ - "../cudf/cudf/utils/metadata/orc_column_statistics.proto" - ]: - output = source.replace(".proto", "_pb2.py") - - if not os.path.exists(output) or ( - os.path.getmtime(source) > os.path.getmtime(output) - ): - with open(output, "a") as src: - src.write("# flake8: noqa" + os.linesep) - src.write("# fmt: off" + os.linesep) - subprocess.check_call([protoc, "--python_out=.", source]) - with open(output, "r+") as src: - new_src_content = ( - "# flake8: noqa" - + os.linesep - + "# fmt: off" - + os.linesep - + src.read() - + "# fmt: on" - + os.linesep - ) - src.seek(0) - src.write(new_src_content) - - # Run original Cython build_ext command - super().run() - - cmdclass = versioneer.get_cmdclass() -cmdclass["build_ext"] = build_ext_and_proto +cmdclass["build_ext"] = build_ext setup( name="strings_udf", From 7df7172de43c858ea97b3cecbdebae49e2b4b492 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 30 Aug 2022 09:46:35 -0500 Subject: [PATCH 088/212] no need to rebuild strings_udf on test nodes, just install from package dir --- build.sh | 2 ++ ci/gpu/build.sh | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index ba18f33650a..020acfa3371 100755 --- a/build.sh +++ b/build.sh @@ -336,6 +336,8 @@ if buildAll || hasArg cudf; then fi if buildAll || hasArg strings_udf; then + # do not separately expose strings_udf c++ library + # always build python and c++ at the same time and include into the same conda package cd ${REPODIR}/python/strings_udf/cpp ls cmake -S ./ -B build -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 46fb92e8013..daf55ddb37a 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -169,13 +169,12 @@ else # TODO: Move boa install to gpuci/rapidsai gpuci_mamba_retry install boa - gpuci_logger "Building cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" + gpuci_logger "Building cudf, dask-cudf, cudf_kafka, and custreamz" export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/dask-cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf_kafka --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/custreamz --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} - gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_logger "Installing cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" From 475f62a952b2a7d70e48368052c15fe9ecf86042 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 30 Aug 2022 11:51:20 -0700 Subject: [PATCH 089/212] build strings_udf conda package on cpu_build jobs --- ci/cpu/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index b43a8461acf..96951802029 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -80,6 +80,12 @@ fi if [ "$BUILD_LIBCUDF" == '1' ]; then gpuci_logger "Build conda pkg for libcudf" gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/libcudf $CONDA_BUILD_ARGS + + # BUILD_LIBCUDF == 1 means this job is being run on the cpu_build jobs + # that is where we must also build the strings_udf package + gpuci_logger "Build conda pkg for strings_udf" + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS + mkdir -p ${CONDA_BLD_DIR}/libcudf/work cp -r ${CONDA_BLD_DIR}/work/* ${CONDA_BLD_DIR}/libcudf/work gpuci_logger "sccache stats" From 0460abc7389f34bc1e6b4a5aa4789a4d5817c569 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 31 Aug 2022 08:15:12 -0700 Subject: [PATCH 090/212] build both 3.8 and 3.9 conda packages on CPU only, and add debugging warning --- ci/cpu/build.sh | 7 +++++-- python/strings_udf/strings_udf/__init__.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 96951802029..5739ed4f659 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -83,8 +83,11 @@ if [ "$BUILD_LIBCUDF" == '1' ]; then # BUILD_LIBCUDF == 1 means this job is being run on the cpu_build jobs # that is where we must also build the strings_udf package - gpuci_logger "Build conda pkg for strings_udf" - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS + gpuci_logger "Build conda pkg for strings_udf (python 3.8)" + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=3.8 + gpuci_logger "Build conda pkg for strings_udf (python 3.9)" + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=3.9 + mkdir -p ${CONDA_BLD_DIR}/libcudf/work cp -r ${CONDA_BLD_DIR}/work/* ${CONDA_BLD_DIR}/libcudf/work diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index 8c81b9a4d71..d01b73a421b 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,9 +1,10 @@ # Copyright (c) 2022, NVIDIA CORPORATION. from ptxcompiler.patch import patch_needed import os +import warnings ENABLED = False if patch_needed() else True - +warnings.warn(f"String UDFs are enabled: {ENABLED}") ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" from . import _version From 1b307b98d6584da12634ca3b43a6cf8137207de8 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 31 Aug 2022 13:05:12 -0700 Subject: [PATCH 091/212] restrict strings_udf based on version of CUDA originally used to compile PTX --- python/strings_udf/strings_udf/__init__.py | 35 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index d01b73a421b..f0173613733 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,11 +1,40 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from ptxcompiler.patch import patch_needed +from ptxcompiler.patch import patch_needed, CMD import os import warnings +import sys +import subprocess + + +def versions_compatible(path): + """ + example PTX header: + + // Generated by NVIDIA NVVM Compiler + // + // Compiler Build ID: CL-30672275 + // Cuda compilation tools, release 11.5, V11.5.119 + // Based on NVVM 7 + """ + # obtain the cuda version used to compile this PTX file + file = open(path).read() + major, minor = file.split("\n")[4].split(" ")[-2][:-1].split(".") + + # adapted from patch_needed() + cp = subprocess.run([sys.executable, "-c", CMD], capture_output=True) + if cp.returncode: + # no driver + return False + + versions = [int(s) for s in cp.stdout.strip().split()] + driver_version = tuple(versions[:2]) + + return driver_version >= (int(major), int(minor)) and not patch_needed() + -ENABLED = False if patch_needed() else True -warnings.warn(f"String UDFs are enabled: {ENABLED}") ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" +ENABLED = versions_compatible(ptxpath) +warnings.warn(f"String UDFs are enabled: {ENABLED}") from . import _version From 67bb0a73ee64bac40cb480dd0a7b4439c383f286 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 2 Sep 2022 08:48:11 -0700 Subject: [PATCH 092/212] small cleanups --- ci/gpu/build.sh | 7 ++-- python/cudf/cudf/core/udf/masked_typing.py | 22 ++++++++++-- python/strings_udf/strings_udf/__init__.py | 2 +- .../strings_udf/_lib/cpp/strings_udf.pxd | 5 --- python/strings_udf/strings_udf/_typing.py | 35 +++++++++---------- python/strings_udf/strings_udf/lowering.py | 2 +- 6 files changed, 42 insertions(+), 31 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index daf55ddb37a..c3d0573231d 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -169,14 +169,17 @@ else # TODO: Move boa install to gpuci/rapidsai gpuci_mamba_retry install boa - gpuci_logger "Building cudf, dask-cudf, cudf_kafka, and custreamz" + gpuci_logger "Building cudf, dask-cudf, cudf_kafka and custreamz" export CONDA_BLD_DIR="$WORKSPACE/.conda-bld" gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/dask-cudf --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/cudf_kafka --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} gpuci_conda_retry mambabuild --croot ${CONDA_BLD_DIR} conda/recipes/custreamz --python=$PYTHON -c ${CONDA_ARTIFACT_PATH} - + # the CUDA component of strings_udf must be built on cuda 11.5 just like libcudf + # but because there is no separate python package, we must also build the python on the 11.5 jobs + # this means that at this point (on the GPU test jobs) the whole package is already built and has been + # copied by CI from the upstream 11.5 jobs into $CONDA_ARTIFACT_PATH gpuci_logger "Installing cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" gpuci_mamba_retry install cudf dask-cudf cudf_kafka custreamz strings_udf -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index f674f69bf49..558fbfdf4e2 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -46,7 +46,20 @@ ) supported_type_str = "\n".join(sorted(list(SUPPORTED_NUMPY_TYPES) + ["bool"])) -MASKED_INIT_MAP: Dict[Any, Any] = {} +redstart = "\033[91m" +redend = "\033[0m" + + +MASKED_INIT_MAP: Dict[Any, Any] = { + types.pyobject: types.Poison( + "\n" + + redstart + + "strings_udf library required for usage of string dtypes " + "inside user defined functions. try conda install strings_udf" + + redend + + "\n" + ) +} def _type_to_masked_type(t): @@ -55,14 +68,17 @@ def _type_to_masked_type(t): if isinstance(t, SUPPORTED_NUMBA_TYPES): return t else: + breakpoint() return types.Poison( # Unsupported Dtype. Numba tends to print out the type info # for whatever operands and operation failed to type and then # output its own error message. Putting the message in the repr # then is one way of getting the true cause to the user - "\nUnsupported MaskedType. This is usually caused by " + "\n" + + redstart + + "Unsupported MaskedType. This is usually caused by " "attempting to use a column of unsupported dtype in a UDF. " - f"Supported dtypes are:\n{supported_type_str}" + f"Supported dtypes are:\n{supported_type_str}" + redend ) else: return result diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index f0173613733..f9f1d78efcc 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -8,7 +8,7 @@ def versions_compatible(path): """ - example PTX header: + Example PTX header: // Generated by NVIDIA NVVM Compiler // diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index 653ddae4b29..7695951d5e5 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -12,12 +12,7 @@ from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer cdef extern from "cudf/strings/udf/udf_apis.hpp": - cdef cppclass udf_module - cdef unique_ptr[udf_module] create_udf_module(string, vector[string]) - cdef unique_ptr[column] call_udf( - udf_module, string, size_type, vector[column_view]) cdef unique_ptr[device_buffer] to_string_view_array(column_view) - cdef unique_ptr[column] from_dstring_array(void*, size_t) cdef extern from "cudf/strings/detail/char_tables.hpp" namespace \ "cudf::strings::detail": diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index c067a15a5f6..d7d33a90046 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -108,10 +108,7 @@ class StringLength(AbstractTemplate): """ def generic(self, args, kws): - if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and len(args) == 1 - ): + if isinstance(args[0], any_string_ty) and len(args) == 1: # length: # string_view -> int32 # dstring -> int32 @@ -126,9 +123,9 @@ class StringViewContains(AbstractTemplate): """ def generic(self, args, kws): - if isinstance( - args[0], (StringView, DString, types.StringLiteral) - ) and isinstance(args[1], (StringView, DString, types.StringLiteral)): + if isinstance(args[0], any_string_ty) and isinstance( + args[1], any_string_ty + ): return nb_signature(types.boolean, string_view, string_view) @@ -140,8 +137,8 @@ class StringViewEq(AbstractTemplate): def generic(self, args, kws): if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and isinstance(args[1], (StringView, DString, types.StringLiteral)) + isinstance(args[0], any_string_ty) + and isinstance(args[1], any_string_ty) and len(args) == 2 ): return nb_signature(types.boolean, string_view, string_view) @@ -155,8 +152,8 @@ class StringViewNe(AbstractTemplate): def generic(self, args, kws): if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and isinstance(args[1], (StringView, DString, types.StringLiteral)) + isinstance(args[0], any_string_ty) + and isinstance(args[1], any_string_ty) and len(args) == 2 ): return nb_signature(types.boolean, string_view, string_view) @@ -170,8 +167,8 @@ class StringViewGe(AbstractTemplate): def generic(self, args, kws): if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and isinstance(args[1], (StringView, DString, types.StringLiteral)) + isinstance(args[0], any_string_ty) + and isinstance(args[1], any_string_ty) and len(args) == 2 ): return nb_signature(types.boolean, string_view, string_view) @@ -185,8 +182,8 @@ class StringViewLe(AbstractTemplate): def generic(self, args, kws): if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and isinstance(args[1], (StringView, DString, types.StringLiteral)) + isinstance(args[0], any_string_ty) + and isinstance(args[1], any_string_ty) and len(args) == 2 ): return nb_signature(types.boolean, string_view, string_view) @@ -200,8 +197,8 @@ class StringViewGt(AbstractTemplate): def generic(self, args, kws): if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and isinstance(args[1], (StringView, DString, types.StringLiteral)) + isinstance(args[0], any_string_ty) + and isinstance(args[1], any_string_ty) and len(args) == 2 ): return nb_signature(types.boolean, string_view, string_view) @@ -215,8 +212,8 @@ class StringViewLt(AbstractTemplate): def generic(self, args, kws): if ( - isinstance(args[0], (StringView, DString, types.StringLiteral)) - and isinstance(args[1], (StringView, DString, types.StringLiteral)) + isinstance(args[0], any_string_ty) + and isinstance(args[1], any_string_ty) and len(args) == 2 ): return nb_signature(types.boolean, string_view, string_view) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index ca6df5b2ee5..7d1996b6978 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -324,7 +324,7 @@ def string_view_lt_impl(context, builder, sig, args): @cuda_lowering_registry.lower_cast(types.StringLiteral, string_view) def cast_string_literal_to_string_view(context, builder, fromty, toty, val): """ - cast a literal to a string_view + Cast a literal to a string_view """ # create an empty string_view sv = cgutils.create_struct_proxy(string_view)(context, builder) From b9acab999374df9bd7bec0262d59d432235c82ee Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 2 Sep 2022 11:44:50 -0700 Subject: [PATCH 093/212] prune files and update to strings_udf repo --- python/strings_udf/README.md | 140 --------- python/strings_udf/build.sh | 17 -- python/strings_udf/cpp/CMakeLists.txt | 2 - .../cpp/cmake/thirdparty/get_jitify.cmake | 32 --- .../cudf/strings/detail/convert/floats.cuh | 165 ----------- .../cudf/strings/detail/convert/integers.cuh | 181 +++--------- .../cudf/strings/split/split_utils.cuh | 206 ++++++------- .../include/cudf/strings/udf/char_types.cuh | 1 - .../cpp/include/cudf/strings/udf/numeric.cuh | 88 +++--- .../cpp/include/cudf/strings/udf/strip.cuh | 272 ------------------ .../cudf/strings/udf/type_traits_patch.hpp | 63 ---- .../cpp/include/cudf/strings/udf/udf_apis.hpp | 7 +- .../cpp/src/strings/udf/udf_apis.cu | 7 - 13 files changed, 191 insertions(+), 990 deletions(-) delete mode 100644 python/strings_udf/README.md delete mode 100644 python/strings_udf/build.sh delete mode 100644 python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake delete mode 100644 python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp diff --git a/python/strings_udf/README.md b/python/strings_udf/README.md deleted file mode 100644 index 4b35c0ad923..00000000000 --- a/python/strings_udf/README.md +++ /dev/null @@ -1,140 +0,0 @@ -# strings_udf -User Defined Function (UDF) prototype for operating against a libcudf strings column. - -UDFs are custom kernel/device CUDA code that execute in parallel threads on an NVIDIA GPU. -The libcudf library contains fixed operation primitives written in CUDA/C++ for strings. -Strings are variable length and libcudf is optimized to minimize costly memory allocations -when operations modify strings. This pattern can make custom UDF logic very difficult to write. - -## Strings UDF device library - -To make it easier to write UDFs, a device string class [dstring](cpp/include/cudf/strings/udf/dstring.hpp) has been created to perform specific operations on -individual strings. -The libcudf strings column strings are read-only but an individual `cudf::string_view` instance can be copied to a `dstring` and this copy can be modified using the `dstring` methods. -Once the UDF has been executed on each string, the resulting strings -can be converted back into a libcudf strings column. -Note that `dstring` uses CUDA malloc/free in device code to manage its string data. -We are hoping to improve this high cost memory allocation and deallocation in the future. - -## Dependencies -The libcudf strings implementation is available here: https://github.com/rapidsai/cudf. -To build the artifacts in this repo requires an existing developer install of libcudf. -This means libcudf and its appropriate dependencies must be available for include and link from the CUDA compiler (nvcc). -Further, it is expected cuDF and libcudf are installed in a Conda -environment and there is a `CONDA_PREFIX` environment variable set to that conda environment directory. - -Follow the [instructions to install cudf](https://github.com/rapidsai/cudf/#conda) - -The CUDA toolkit must be installed and include [NVRTC](https://docs.nvidia.com/cuda/nvrtc/index.html) to build and launch the UDFs. -The code here has only been tested on CUDA 11.5 but may work on 11.x or later versions as well. - -## Building -Make sure the `CONDA_PREFIX` environment variable points to the conda environment directory -containing cuDF and libcudf (e.g. `/conda/env/rapids`). - -### CUDA/C++ -The CUDA/C++ code is built using `cmake` which is expected to be version `3.20.1` or higher. - -From the `cpp` directory create a `build` directory and run `cmake` as follows: -``` -cd cpp -mkdir build -cd build -cmake .. -DCONDA_PREFIX=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -make -make install -``` - -This will build the `libcudf_strings_udf.so` functions library and the `udf_cli` command-line interface. - -### Python -The `libcudf_strings_udf.so` must be built first since the Python library here depends on it for executing UDFs. -Follow the instructions in the [Python](python) directory to build the python library. - - -## Command Line Interface (CLI) - -A CLI is included here to demonstrate executing a UDF on a libcudf strings column instance. -The strings column is by created from a text file with new-line delimiters for each string or from a CSV file. -The cudf cuIO CSV reader is used to load the text file into a libcudf strings column. - -The UDF CUDA kernel is launched with the number of threads equal to the number of input strings (rows). -And each thread can work on a single row to produce a single output string. -After the threads complete, the resulting strings are gathered into a libcudf strings column. - -Create the UDF function in a text file to pass to the CLI. -The output result can be written to a specified file or to the console. - -The CLI parameters are as follows - -| Parameter | Description | Default | -|:---------:| ----------- | ------- | -| -u | Text file contain UDF kernel function in CUDA/C++ | (required) | -| -n | Kernel function name in the UDF file | "udf_kernel" | -| -t | Text or CSV-file for creating strings column | (required) | -| -i | Include directory for libcudf | default is $CONDA_PREFIX/include | -| -c | 0-based column number if CSV file | 0 (first column) | -| -r | Number of rows to read from file | 0 (entire file) | -| -f | Output file name/path | default output is stdout | -| -m | Maximum malloc heap size in MB | 1000 | - -Note that to run this CLI you might need to add paths to your `LD_LIBRARY_PATH`. For example: -``` -export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH:$CONDA_PREFIX/lib -``` -Note this also prepends the `.` path so that the current directory is included when locating dependent shared objects to load. - -### Example -The following example shows parsing an XML file to retrieve the `name` attribute of each `entry`. - -Here is the example XML file [`example.xml`](cpp/sample_udfs/example.xml) -``` - - - - - - -``` - -Example UDF file [`xml.udf`](cpp/sample_udfs/xml.udf) -``` -#include - -__device__ cudf::string_view find_attr( cudf::string_view const& input, - cudf::string_view const& name ) -{ - auto pos = input.find(name); - if( pos < 0 ) return cudf::string_view{"",0}; - - cudf::string_view quote("\"",1); - auto begin = input.find(quote, pos) + 1; - auto end = input.find(quote, begin); - - return input.substr(begin, end-begin); -} - -__global__ void udf_kernel( cudf::string_view* d_in_strs, int size, - cudf::strings::udf::dstring* d_out_strs, int count ) -{ - int tid = (blockDim.x * blockIdx.x) + threadIdx.x; - if( tid >= count ) return; - - auto input_str = d_in_strs[tid]; - - auto name = find_attr(input_str, cudf::string_view("name",4)); - - d_out_strs[tid] = name; // makes a copy here -} -``` - -Example CLI: -``` -$ ./udf_cli -u ../sample_udfs/xml.udf -t ../sample_udfs/example.xml - -Toby -David -Bill -Ted -Jane -``` diff --git a/python/strings_udf/build.sh b/python/strings_udf/build.sh deleted file mode 100644 index 9069baf6fa4..00000000000 --- a/python/strings_udf/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# Copyright (c) 2022, NVIDIA CORPORATION. - -REPODIR=`git rev-parse --show-toplevel` - -BUILD_DIR=${REPODIR}/python/strings_udf/cpp/build - -mkdir ${BUILD_DIR} -cd ${BUILD_DIR} - -cmake .. -DCONDA_PREFIX=${CONDA_PREFIX} -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX}/ -make -make install - -cd $REPODIR/python/strings_udf/ -python setup.py install diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 808ab571a73..908889b8d98 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -26,7 +26,6 @@ include(rapids-export) include(rapids-find) rapids_cpm_init() -include(cmake/thirdparty/get_jitify.cmake) # set the project name and version project( @@ -47,7 +46,6 @@ find_package(CUDAToolkit REQUIRED) # depends on an installed cudf dev env set(UDF_INCLUDES ${CONDA_PREFIX}/include) list(APPEND UDF_INCLUDES ${CONDA_PREFIX}/include/rapids/libcudacxx) -list(APPEND UDF_INCLUDES ${CMAKE_SOURCE_DIR}/build/_deps/jitify-src) set(UDF_LIBS ${CONDA_PREFIX}/lib/libcudf.so nvrtc) diff --git a/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake b/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake deleted file mode 100644 index 08ff9124293..00000000000 --- a/python/strings_udf/cpp/cmake/thirdparty/get_jitify.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# ============================================================================= -# Copyright (c) 2022, NVIDIA CORPORATION. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except -# in compliance with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software distributed under the License -# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express -# or implied. See the License for the specific language governing permissions and limitations under -# the License. -# ============================================================================= - -# Jitify doesn't have a version :/ - -# This function finds Jitify and sets any additional necessary environment variables. -function(find_and_configure_jitify) - rapids_cpm_find( - jitify 2.0.0 - GIT_REPOSITORY https://github.com/rapidsai/jitify.git - GIT_TAG cudf_0.19 - GIT_SHALLOW TRUE - DOWNLOAD_ONLY TRUE - ) - set(JITIFY_INCLUDE_DIR - "${jitify_SOURCE_DIR}" - PARENT_SCOPE - ) -endfunction() - -find_and_configure_jitify() diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh deleted file mode 100644 index 241203213fa..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/detail/convert/floats.cuh +++ /dev/null @@ -1,165 +0,0 @@ - -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include - -#include -#include - -namespace cudf { -namespace strings { -namespace detail { - -/** - * @brief Returns true if input contains the not-a-number string. - * - * The following are valid for this function: "NAN" and "NaN" - * @param d_str input string - * @return true if input is as valid NaN string. - */ -inline __device__ bool is_nan_str(string_view const& d_str) -{ - auto const ptr = d_str.data(); - return (d_str.size_bytes() == 3) && (ptr[0] == 'N' || ptr[0] == 'n') && - (ptr[1] == 'A' || ptr[1] == 'a') && (ptr[2] == 'N' || ptr[2] == 'n'); -} - -/** - * @brief Returns true if input contains the infinity string. - * - * The following are valid for this function: "INF", "INFINITY", and "Inf" - * @param d_str input string - * @return true if input is as valid Inf string. - */ -inline __device__ bool is_inf_str(string_view const& d_str) -{ - auto const ptr = d_str.data(); - auto const size = d_str.size_bytes(); - - if (size != 3 && size != 8) return false; - - auto const prefix_valid = (ptr[0] == 'I' || ptr[0] == 'i') && (ptr[1] == 'N' || ptr[1] == 'n') && - (ptr[2] == 'F' || ptr[2] == 'f'); - - return prefix_valid && - ((size == 3) || ((ptr[3] == 'I' || ptr[3] == 'i') && (ptr[4] == 'N' || ptr[4] == 'n') && - (ptr[5] == 'I' || ptr[5] == 'i') && (ptr[6] == 'T' || ptr[6] == 't') && - (ptr[7] == 'Y' || ptr[7] == 'y'))); -} - -__device__ inline double stod(string_view const& d_str) -{ - const char* in_ptr = d_str.data(); - const char* end = in_ptr + d_str.size_bytes(); - if (end == in_ptr) return 0.0; - double sign{1.0}; - if (*in_ptr == '-' || *in_ptr == '+') { - sign = (*in_ptr == '-' ? -1 : 1); - ++in_ptr; - } - - // could not find INFINITY and std::numeric_limits::infinity() does not work; - // same for std::numeric_limits::quiet_NaN() but looks like nan() works ok - constexpr double infinity = (1.0 / 0.0); - - // special strings: NaN, Inf - if ((in_ptr < end) && *in_ptr > '9') { - auto const inf_nan = string_view(in_ptr, static_cast(end - in_ptr)); - if (is_nan_str(inf_nan)) return nan(""); - if (is_inf_str(inf_nan)) return sign * infinity; - } - - // Parse and store the mantissa as much as we can, - // until we are about to exceed the limit of uint64_t - constexpr uint64_t max_holding = (18446744073709551615U - 9U) / 10U; - uint64_t digits = 0; - int exp_off = 0; - bool decimal = false; - while (in_ptr < end) { - char ch = *in_ptr; - if (ch == '.') { - decimal = true; - ++in_ptr; - continue; - } - if (ch < '0' || ch > '9') break; - if (digits > max_holding) - exp_off += (int)!decimal; - else { - digits = (digits * 10L) + static_cast(ch - '0'); - if (digits > max_holding) { - digits = digits / 10L; - exp_off += (int)!decimal; - } else - exp_off -= (int)decimal; - } - ++in_ptr; - } - if (digits == 0) return sign * static_cast(0); - - // check for exponent char - int exp_ten = 0; - int exp_sign = 1; - if (in_ptr < end) { - char ch = *in_ptr++; - if (ch == 'e' || ch == 'E') { - if (in_ptr < end) { - ch = *in_ptr; - if (ch == '-' || ch == '+') { - exp_sign = (ch == '-' ? -1 : 1); - ++in_ptr; - } - while (in_ptr < end) { - ch = *in_ptr++; - if (ch < '0' || ch > '9') break; - exp_ten = (exp_ten * 10) + (int)(ch - '0'); - } - } - } - } - - int const num_digits = static_cast(log10((double)digits)) + 1; - exp_ten *= exp_sign; - exp_ten += exp_off; - exp_ten += num_digits - 1; - if (exp_ten > std::numeric_limits::max_exponent10) { - return sign > 0 ? infinity : -infinity; - } - - double base = sign * static_cast(digits); - - exp_ten += 1 - num_digits; - // If 10^exp_ten would result in a subnormal value, the base and - // exponent should be adjusted so that 10^exp_ten is a normal value - auto const subnormal_shift = std::numeric_limits::min_exponent10 - exp_ten; - if (subnormal_shift > 0) { - // Handle subnormal values. Ensure that both base and exponent are - // normal values before computing their product. - base = base / exp10(static_cast(num_digits - 1 + subnormal_shift)); - exp_ten += num_digits - 1; // adjust exponent - auto const exponent = exp10(static_cast(exp_ten + subnormal_shift)); - return base * exponent; - } - - double const exponent = exp10(static_cast(std::abs(exp_ten))); - return exp_ten < 0 ? base / exponent : base * exponent; -} - -} // namespace detail -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh index 460887449f5..13c02a08287 100644 --- a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh @@ -1,4 +1,3 @@ - /* * Copyright (c) 2022, NVIDIA CORPORATION. * @@ -14,136 +13,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#pragma once - -#include - -#include -#include - -namespace cudf { -namespace strings { -namespace detail { - -/** - * @brief Converts a single string into an integer. - * - * The '+' and '-' are allowed but only at the beginning of the string. - * The string is expected to contain base-10 [0-9] characters only. - * Any other character will end the parse. - * Overflow of the int64 type is not detected. - */ -__device__ inline int64_t string_to_integer(string_view const& d_str) -{ - int64_t value = 0; - auto bytes = d_str.size_bytes(); - if (bytes == 0) return value; - auto ptr = d_str.data(); - auto sign = 1; - if (*ptr == '-' || *ptr == '+') { - sign = (*ptr == '-' ? -1 : 1); - ++ptr; - --bytes; - } - for (size_type idx = 0; idx < bytes; ++idx) { - char chr = *ptr++; - if (chr < '0' || chr > '9') break; - value = (value * 10) + static_cast(chr - '0'); - } - return value * static_cast(sign); -} - -/** - * @brief Converts an integer into string - * - * @tparam IntegerType integer type to convert from - * @param value integer value to convert - * @param d_buffer character buffer to store the converted string - */ -template -__device__ inline size_type integer_to_string(IntegerType value, char* d_buffer) -{ - if (value == 0) { - *d_buffer = '0'; - return 1; - } - bool const is_negative = std::is_signed() ? (value < 0) : false; - - constexpr IntegerType base = 10; - // largest 64-bit integer is 20 digits; largest 128-bit integer is 39 digits - constexpr int MAX_DIGITS = std::numeric_limits::digits10 + 1; - char digits[MAX_DIGITS]; // place-holder for digit chars - int digits_idx = 0; - while (value != 0) { - assert(digits_idx < MAX_DIGITS); - digits[digits_idx++] = '0' + abs(value % base); - // next digit - value = value / base; - } - size_type const bytes = digits_idx + static_cast(is_negative); - - char* ptr = d_buffer; - if (is_negative) *ptr++ = '-'; - // digits are backwards, reverse the string into the output - while (digits_idx-- > 0) *ptr++ = digits[digits_idx]; - return bytes; -} - -/** - * @brief Counts number of digits in a integer value including '-' sign - * - * @tparam IntegerType integer type of input value - * @param value input value to count the digits of - * @return size_type number of digits in input value - */ -template -constexpr size_type count_digits(IntegerType value) -{ - if (value == 0) return 1; - bool const is_negative = std::is_signed() ? (value < 0) : false; - // std::numeric_limits::min() is negative; - // for all integer types, the max() and min() values have the same number of digits - value = (value == std::numeric_limits::min()) - ? std::numeric_limits::max() - : abs(value); - - auto const digits = [value] { - // largest 8-byte unsigned value is 18446744073709551615 (20 digits) - // largest 16-byte unsigned value is 340282366920938463463374607431768211455 (39 digits) - auto constexpr max_digits = std::numeric_limits::digits10 + 1; - - size_type digits = 1; - int64_t pow10 = 10; - for (; digits < max_digits; ++digits, pow10 *= 10) - if (value < pow10) break; - return digits; - }(); - - return digits + static_cast(is_negative); -} - -__device__ int64_t hex_to_integer(string_view const& d_str) -{ - int64_t result = 0; - int64_t base = 1; - auto const str = d_str.data(); - auto index = d_str.size_bytes(); - while (index-- > 0) { - auto const ch = str[index]; - if (ch >= '0' && ch <= '9') { - result += static_cast(ch - 48) * base; - base *= 16; - } else if (ch >= 'A' && ch <= 'F') { - result += static_cast(ch - 55) * base; - base *= 16; - } else if (ch >= 'a' && ch <= 'f') { - result += static_cast(ch - 87) * base; - base *= 16; - } - } - return result; -} - -} // namespace detail -} // namespace strings -} // namespace cudf + #pragma once + + #include + + #include + #include + + namespace cudf { + namespace strings { + namespace detail { + + /** + * Copied from cudf/cpp/include/cudf/strings/detail/convert/int_to_string.cuh + * Dependencies there cannot be compiled by jitify. + */ + template + __device__ inline size_type integer_to_string(IntegerType value, char* d_buffer) + { + if (value == 0) { + *d_buffer = '0'; + return 1; + } + bool const is_negative = std::is_signed() ? (value < 0) : false; + + constexpr IntegerType base = 10; + // largest 64-bit integer is 20 digits; largest 128-bit integer is 39 digits + constexpr int MAX_DIGITS = std::numeric_limits::digits10 + 1; + char digits[MAX_DIGITS]; // place-holder for digit chars + int digits_idx = 0; + while (value != 0) { + assert(digits_idx < MAX_DIGITS); + digits[digits_idx++] = '0' + abs(value % base); + // next digit + value = value / base; + } + size_type const bytes = digits_idx + static_cast(is_negative); + + char* ptr = d_buffer; + if (is_negative) *ptr++ = '-'; + // digits are backwards, reverse the string into the output + while (digits_idx-- > 0) *ptr++ = digits[digits_idx]; + return bytes; + } + + } // namespace detail + } // namespace strings + } // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh index af5e9c16bf7..813547d6a55 100644 --- a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh @@ -14,106 +14,108 @@ * limitations under the License. */ -#include + #include -namespace cudf { -namespace strings { -namespace detail { - -using position_pair = struct { - size_type first, second; -}; - -/** - * @brief Instantiated for each string to manage navigating tokens from - * the beginning or the end of that string. - */ -struct whitespace_string_tokenizer { - /** - * @brief Identifies the position range of the next token in the given - * string at the specified iterator position. - * - * Tokens are delimited by one or more whitespace characters. - * - * @return true if a token has been found - */ - __device__ bool next_token() - { - if (itr != d_str.begin()) { // skip these 2 lines the first time through - ++itr; - start_position = itr.byte_offset(); // end_position + 1; - } - if (start_position >= d_str.size_bytes()) return false; - // continue search for the next token - end_position = d_str.size_bytes(); - for (; itr < d_str.end(); ++itr) { - if (spaces == (*itr <= ' ')) { - if (spaces) - start_position = (itr + 1).byte_offset(); - else - end_position = (itr + 1).byte_offset(); - continue; - } - spaces = !spaces; - if (spaces) { - end_position = itr.byte_offset(); - break; - } - } - return start_position < end_position; - } - - /** - * @brief Identifies the position range of the previous token in the given - * string at the specified iterator position. - * - * Tokens are delimited by one or more whitespace characters. - * - * @return true if a token has been found - */ - __device__ bool prev_token() - { - end_position = start_position - 1; - --itr; - if (end_position <= 0) return false; - // continue search for the next token - start_position = 0; - for (; itr >= d_str.begin(); --itr) { - if (spaces == (*itr <= ' ')) { - if (spaces) - end_position = itr.byte_offset(); - else - start_position = itr.byte_offset(); - continue; - } - spaces = !spaces; - if (spaces) { - start_position = (itr + 1).byte_offset(); - break; - } - } - return start_position < end_position; - } - - __device__ position_pair get_token() const { return position_pair{start_position, end_position}; } - - __device__ whitespace_string_tokenizer(string_view const& d_str, bool reverse = false) - : d_str{d_str}, - spaces(true), - start_position{reverse ? d_str.size_bytes() + 1 : 0}, - end_position{d_str.size_bytes()}, - itr{reverse ? d_str.end() : d_str.begin()} - { - } - - private: - string_view const d_str; - bool spaces; // true if current position is whitespace - cudf::string_view::const_iterator itr; - size_type start_position; - size_type end_position; -}; - -} // namespace detail -} // namespace strings -} // namespace cudf + namespace cudf { + namespace strings { + namespace detail { + + // JIT has trouble including thrust/pair.h + using position_pair = struct { + size_type first; + size_type second; + }; + + /** + * @brief Instantiated for each string to manage navigating tokens from + * the beginning or the end of that string. + */ + struct whitespace_string_tokenizer { + /** + * @brief Identifies the position range of the next token in the given + * string at the specified iterator position. + * + * Tokens are delimited by one or more whitespace characters. + * + * @return true if a token has been found + */ + __device__ bool next_token() + { + if (itr != d_str.begin()) { // skip these 2 lines the first time through + ++itr; + start_position = itr.byte_offset(); // end_position + 1; + } + if (start_position >= d_str.size_bytes()) return false; + // continue search for the next token + end_position = d_str.size_bytes(); + for (; itr < d_str.end(); ++itr) { + if (spaces == (*itr <= ' ')) { + if (spaces) + start_position = (itr + 1).byte_offset(); + else + end_position = (itr + 1).byte_offset(); + continue; + } + spaces = !spaces; + if (spaces) { + end_position = itr.byte_offset(); + break; + } + } + return start_position < end_position; + } + + /** + * @brief Identifies the position range of the previous token in the given + * string at the specified iterator position. + * + * Tokens are delimited by one or more whitespace characters. + * + * @return true if a token has been found + */ + __device__ bool prev_token() + { + end_position = start_position - 1; + --itr; + if (end_position <= 0) return false; + // continue search for the next token + start_position = 0; + for (; itr >= d_str.begin(); --itr) { + if (spaces == (*itr <= ' ')) { + if (spaces) + end_position = itr.byte_offset(); + else + start_position = itr.byte_offset(); + continue; + } + spaces = !spaces; + if (spaces) { + start_position = (itr + 1).byte_offset(); + break; + } + } + return start_position < end_position; + } + + __device__ position_pair get_token() const { return position_pair{start_position, end_position}; } + + __device__ whitespace_string_tokenizer(string_view const& d_str, bool reverse = false) + : d_str{d_str}, + spaces(true), + start_position{reverse ? d_str.size_bytes() + 1 : 0}, + end_position{d_str.size_bytes()}, + itr{reverse ? d_str.end() : d_str.begin()} + { + } + + private: + string_view const d_str; + bool spaces; // true if current position is whitespace + cudf::string_view::const_iterator itr; + size_type start_position; + size_type end_position; + }; + + } // namespace detail + } // namespace strings + } // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh index fcc18c02668..091db225637 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh @@ -15,7 +15,6 @@ */ #pragma once -#include "type_traits_patch.hpp" // must be included before char_types_enum.hpp #include #include diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh index 20b7358d3e6..32ed98b6aa2 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh @@ -14,54 +14,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#pragma once + #pragma once -#include "../detail/convert/floats.cuh" -#include "../detail/convert/integers.cuh" -#include "dstring.cuh" - -namespace cudf { -namespace strings { -namespace udf { - -/** - * @brief Converts a string into an integer. - * - * The '+' and '-' are allowed but only at the beginning of the string. - * The string is expected to contain base-10 [0-9] characters only. - * Any other character will end the parse. - * Overflow of the int64 type is not detected. - */ -__device__ inline int64_t stoi(string_view const& d_str) -{ - return cudf::strings::detail::string_to_integer(d_str); -} - -/** - * @brief Converts an integer into string - * - * @param value integer value to convert - */ -__device__ inline dstring to_string(int64_t value) -{ - auto digits = cudf::strings::detail::count_digits(value); - dstring result; - result.resize(digits); - cudf::strings::detail::integer_to_string(value, result.data()); - return result; -} - -/** - * @brief Converts a string into a double. - * - * Support scientific notation as well. - * Overflow goes to inf or -inf and underflow may go to 0. - */ -__device__ inline double stod(string_view const& d_str) -{ - return cudf::strings::detail::stod(d_str); -} - -} // namespace udf -} // namespace strings -} // namespace cudf + + #include + #include + #include + + namespace cudf { + namespace strings { + namespace udf { + + /** + * @brief Converts a string into an integer. + * + * The '+' and '-' are allowed but only at the beginning of the string. + * The string is expected to contain base-10 [0-9] characters only. + * Any other character will end the parse. + * Overflow of the int64 type is not detected. + */ + __device__ inline int64_t stoi(string_view const& d_str) + { + return cudf::strings::detail::string_to_integer(d_str); + } + + + /** + * @brief Converts a string into a double. + * + * Support scientific notation as well. + * Overflow goes to inf or -inf and underflow may go to 0. + */ + __device__ inline double stod(string_view const& d_str) + { + return cudf::strings::detail::stod(d_str); + } + + } // namespace udf + } // namespace strings + } // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh deleted file mode 100644 index 3d2e9e4d84f..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/strip.cuh +++ /dev/null @@ -1,272 +0,0 @@ - -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include "../detail/strip_utils.cuh" -#include "dstring.cuh" - -namespace cudf { -namespace strings { -namespace udf { - -/** - * @brief Strip characters from the beginning and/or end of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" aba ", 5}; - * auto d_to_strip = cudf::string_view{}; // empty string - * auto result = strip(d_str, d_to_strip); - * // result is "aba" - * d_to_strip = cudf::string_view{" a", 2}; // space and 'a' - * result = strip(d_str, d_to_strip); - * // result is "b" ('a' or ' ' removed from the ends) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Characters to remove - * @param stype From where to strip the characters; - * Default `BOTH` indicates stripping characters from the - * beginning and the end of the input string `d_str` - * @return New string with characters removed - */ -__device__ dstring strip(cudf::string_view const d_str, - cudf::string_view const d_to_strip, - strip_type stype = strip_type::BOTH) -{ - return dstring{cudf::strings::detail::strip(d_str, d_to_strip, stype)}; -} - -/** - * @brief Strip characters from the beginning and/or end of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" abaa a ", 8}; - * auto result = strip(d_str, " ", 1); - * // result is "abaa a" - * result = strip(d_str, "a ", 2); // 'a' and space - * // result is "b" ('a' or ' ' removed from the ends) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Array of characters encoded in UTF-8 to remove - * @param bytes Number of bytes to read from `d_to_strip` - * @param stype From where to strip the characters; - * Default `BOTH` indicates stripping characters from the - * beginning and the end of the input string `d_str` - * @return New string with characters removed - */ -__device__ dstring strip(cudf::string_view const d_str, - char const* d_to_strip, - cudf::size_type bytes, - strip_type stype = strip_type::BOTH) -{ - auto const sv = cudf::string_view{d_to_strip, bytes}; - return strip(d_str, sv, stype); -} - -/** - * @brief Strip characters from the beginning and/or end of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" abca a ", 8}; - * auto result = strip(d_str); - * // result is "abca a" - * result = strip(d_str, "a b"); // 'a', 'b', and space - * // result is "c" ('a', ' ', or 'b' is removed from the ends) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Null-terminated array of characters encoded in UTF-8 - * to remove - * @param stype From where to strip the characters; - * Default `BOTH` indicates stripping characters from the - * beginning and the end of the input string `d_str` - * @return New string with characters removed - */ -__device__ dstring strip(cudf::string_view const d_str, - char const* d_to_strip = "", - strip_type stype = strip_type::BOTH) -{ - return strip(d_str, d_to_strip, detail::bytes_in_null_terminated_string(d_to_strip), stype); -} - -/** - * @brief Strip characters from the beginning of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" aba ", 5}; - * auto d_to_strip = cudf::string_view{}; // empty string - * auto result = lstrip(d_str, d_to_strip); - * // result is "aba " - * d_to_strip = cudf::string_view{"a ", 2}; // space and 'a' - * result = lstrip(d_str, d_to_strip); - * // result is "ba " ('a' or ' ' removed from the beginning) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Characters to remove - * @return New string with characters removed - */ -__device__ dstring lstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) -{ - return strip(d_str, d_to_strip, strip_type::LEFT); -} - -/** - * @brief Strip characters from the beginning of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" abaa a ", 8}; - * auto result = lstrip(d_str, " ", 1); - * // result is "abaa a " - * result = lstrip(d_str, "a ", 2); // 'a' and space - * // result is "baa a " ('a' or ' ' removed from the beginning) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Array of characters encoded in UTF-8 to remove - * @param bytes Number of bytes to read from `d_to_strip` - * @return New string with characters removed - */ -__device__ dstring lstrip(cudf::string_view const d_str, - char const* d_to_strip, - cudf::size_type bytes) -{ - auto const sv = cudf::string_view{d_to_strip, bytes}; - return strip(d_str, sv, strip_type::LEFT); -} - -/** - * @brief Strip characters from the beginning of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" abca a ", 8}; - * auto result = lstrip(d_str); - * // result is "abca a " - * result = lstrip(d_str, "a b"); // 'a', 'b', and space - * // result is "ca a " ('a', ' ', or 'b' removed from the beginning) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Null-terminated array of characters encoded in UTF-8 - * to remove - * @return New string with characters removed - */ -__device__ dstring lstrip(cudf::string_view const d_str, char const* d_to_strip = "") -{ - return strip( - d_str, d_to_strip, detail::bytes_in_null_terminated_string(d_to_strip), strip_type::LEFT); -} - -/** - * @brief Strip characters from the end of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" aba ", 5}; - * auto d_to_strip = cudf::string_view{}; // empty string - * auto result = rstrip(d_str, d_to_strip); - * // result is " aba" - * d_to_strip = cudf::string_view{" a", 2}; // space and 'a' - * result = rstrip(d_str, d_to_strip); - * // result is " ab" ('a' or ' ' removed from the end) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Characters to remove - * @return New string with characters removed - */ -__device__ dstring rstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) -{ - return strip(d_str, d_to_strip, strip_type::RIGHT); -} - -/** - * @brief Strip characters from the end of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" abaa a ", 8}; - * auto result = rstrip(d_str, " ", 1); - * // result is " abaa a" - * result = rstrip(d_str, " a", 2); // 'a' and space - * // result is " ab" ('a' or ' ' removed from the end) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Array of characters encoded in UTF-8 to remove - * @param bytes Number of bytes to read from `d_to_strip` - * @return New string with characters removed - */ -__device__ dstring rstrip(cudf::string_view const d_str, - char const* d_to_strip, - cudf::size_type bytes) -{ - auto const sv = cudf::string_view{d_to_strip, bytes}; - return strip(d_str, sv, strip_type::RIGHT); -} - -/** - * @brief Strip characters from the end of the given string. - * - * The `d_to_strip` is interpretted as an array of characters to be removed. - * If `d_to_strip` is an empty string, whitespace characters are stripped. - * - * @code{.cpp} - * auto d_str = cudf::string_view{" acba a ", 8}; - * auto result = rstrip(d_str); - * // result is " acba a" - * result = rstrip(d_str, "a b"); // 'a', 'b', and space - * // result is " ac" ('a', ' ', or 'b' removed from the end) - * @endcode - * - * @param d_str String to strip characters from - * @param d_to_strip Null-terminated array of characters encoded in UTF-8 - * to remove - * @return New string with characters removed - */ -__device__ dstring rstrip(cudf::string_view const d_str, char const* d_to_strip = "") -{ - return strip( - d_str, d_to_strip, detail::bytes_in_null_terminated_string(d_to_strip), strip_type::RIGHT); -} - -} // namespace udf -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp deleted file mode 100644 index 9d274d09691..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/type_traits_patch.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -// Patch for the that is setup by jitify.hpp. -// The source below supports the std::underlying_type_t which is -// missing from the jitify.hpp implementation of - -#ifdef CUDF_JIT_UDF - -namespace std { -/// integral_constant -// the 'udf' prefix prevents collision with jitify.hpp definition -// which is incompatible with how is-enum and underlying_type needs -template -struct udf_integral_constant { - static constexpr _Tp value = __v; - typedef _Tp value_type; - typedef udf_integral_constant<_Tp, __v> type; - constexpr operator value_type() const noexcept { return value; } - constexpr value_type operator()() const noexcept { return value; } -}; -template -constexpr _Tp udf_integral_constant<_Tp, __v>::value; - -/// is_enum -template -struct is_enum : public udf_integral_constant { -}; - -template ::value> -struct __underlying_type_impl { - using type = __underlying_type(_Tp); -}; - -template -struct __underlying_type_impl<_Tp, false> { -}; - -/// The underlying type of an enum. -template -struct underlying_type : public __underlying_type_impl<_Tp> { -}; - -/// Alias template for underlying_type -template -using underlying_type_t = typename underlying_type<_Tp>::type; -} // namespace std - -#endif \ No newline at end of file diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp index a7191eb56ea..36b7576aa0e 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -16,15 +16,12 @@ #pragma once -#include #include -#include -#include +#include #include -#include -#include + /** diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu index 647433cc1c6..3b11c73cfbe 100644 --- a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -14,24 +14,17 @@ * limitations under the License. */ -#include "jitify.hpp" -#include #include #include #include #include -#include -#include #include -#include -#include #include #include -#include #include #include From 3852d790d6c2aa919c66cc47ea22771bf1d504f3 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 2 Sep 2022 11:50:16 -0700 Subject: [PATCH 094/212] format c++ files --- python/strings_udf/cpp/.clang-format | 155 +++++++++++ .../cudf/strings/detail/convert/integers.cuh | 93 +++---- .../cudf/strings/split/split_utils.cuh | 208 +++++++------- .../include/cudf/strings/udf/char_types.cuh | 1 - .../cpp/include/cudf/strings/udf/numeric.cuh | 74 +++-- .../cpp/include/cudf/strings/udf/search.cuh | 2 - .../include/cudf/strings/udf/starts_with.cuh | 1 - .../cpp/include/cudf/strings/udf/udf_apis.hpp | 2 - .../strings_udf/cpp/src/strings/udf/shim.cu | 253 +++++++++--------- .../cpp/src/strings/udf/udf_apis.cu | 41 ++- 10 files changed, 492 insertions(+), 338 deletions(-) create mode 100644 python/strings_udf/cpp/.clang-format diff --git a/python/strings_udf/cpp/.clang-format b/python/strings_udf/cpp/.clang-format new file mode 100644 index 00000000000..6019a6f3d5c --- /dev/null +++ b/python/strings_udf/cpp/.clang-format @@ -0,0 +1,155 @@ +--- +# Refer to the following link for the explanation of each params: +# http://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveBitFields: true +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: true +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLambdasOnASingleLine: true +AllowShortLoopsOnASingleLine: false +# This is deprecated +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + # disabling the below splits, else, they'll just add to the vertical length of source files! + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakAfterJavaFieldAnnotations: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +# Kept the below 2 to be the same as `IndentWidth` to keep everything uniform +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +# Enabling comment reflow causes doxygen comments to be messed up in their formats! +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++17 +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +# Be consistent with indent-width, even for people who use tab for indentation! +TabWidth: 2 +UseTab: Never diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh index 13c02a08287..5727cc40471 100644 --- a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh @@ -13,50 +13,51 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #pragma once +#pragma once - #include - - #include - #include - - namespace cudf { - namespace strings { - namespace detail { - - /** - * Copied from cudf/cpp/include/cudf/strings/detail/convert/int_to_string.cuh - * Dependencies there cannot be compiled by jitify. - */ - template - __device__ inline size_type integer_to_string(IntegerType value, char* d_buffer) - { - if (value == 0) { - *d_buffer = '0'; - return 1; - } - bool const is_negative = std::is_signed() ? (value < 0) : false; - - constexpr IntegerType base = 10; - // largest 64-bit integer is 20 digits; largest 128-bit integer is 39 digits - constexpr int MAX_DIGITS = std::numeric_limits::digits10 + 1; - char digits[MAX_DIGITS]; // place-holder for digit chars - int digits_idx = 0; - while (value != 0) { - assert(digits_idx < MAX_DIGITS); - digits[digits_idx++] = '0' + abs(value % base); - // next digit - value = value / base; - } - size_type const bytes = digits_idx + static_cast(is_negative); - - char* ptr = d_buffer; - if (is_negative) *ptr++ = '-'; - // digits are backwards, reverse the string into the output - while (digits_idx-- > 0) *ptr++ = digits[digits_idx]; - return bytes; - } - - } // namespace detail - } // namespace strings - } // namespace cudf +#include + +#include +#include + +namespace cudf { +namespace strings { +namespace detail { + +/** + * Copied from cudf/cpp/include/cudf/strings/detail/convert/int_to_string.cuh + * Dependencies there cannot be compiled by jitify. + */ +template +__device__ inline size_type integer_to_string(IntegerType value, char* d_buffer) +{ + if (value == 0) { + *d_buffer = '0'; + return 1; + } + bool const is_negative = std::is_signed() ? (value < 0) : false; + + constexpr IntegerType base = 10; + // largest 64-bit integer is 20 digits; largest 128-bit integer is 39 digits + constexpr int MAX_DIGITS = std::numeric_limits::digits10 + 1; + char digits[MAX_DIGITS]; // place-holder for digit chars + int digits_idx = 0; + while (value != 0) { + assert(digits_idx < MAX_DIGITS); + digits[digits_idx++] = '0' + abs(value % base); + // next digit + value = value / base; + } + size_type const bytes = digits_idx + static_cast(is_negative); + + char* ptr = d_buffer; + if (is_negative) *ptr++ = '-'; + // digits are backwards, reverse the string into the output + while (digits_idx-- > 0) + *ptr++ = digits[digits_idx]; + return bytes; +} + +} // namespace detail +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh index 813547d6a55..c2509422513 100644 --- a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh @@ -14,108 +14,108 @@ * limitations under the License. */ - #include +#include - namespace cudf { - namespace strings { - namespace detail { - - // JIT has trouble including thrust/pair.h - using position_pair = struct { - size_type first; - size_type second; - }; - - /** - * @brief Instantiated for each string to manage navigating tokens from - * the beginning or the end of that string. - */ - struct whitespace_string_tokenizer { - /** - * @brief Identifies the position range of the next token in the given - * string at the specified iterator position. - * - * Tokens are delimited by one or more whitespace characters. - * - * @return true if a token has been found - */ - __device__ bool next_token() - { - if (itr != d_str.begin()) { // skip these 2 lines the first time through - ++itr; - start_position = itr.byte_offset(); // end_position + 1; - } - if (start_position >= d_str.size_bytes()) return false; - // continue search for the next token - end_position = d_str.size_bytes(); - for (; itr < d_str.end(); ++itr) { - if (spaces == (*itr <= ' ')) { - if (spaces) - start_position = (itr + 1).byte_offset(); - else - end_position = (itr + 1).byte_offset(); - continue; - } - spaces = !spaces; - if (spaces) { - end_position = itr.byte_offset(); - break; - } - } - return start_position < end_position; - } - - /** - * @brief Identifies the position range of the previous token in the given - * string at the specified iterator position. - * - * Tokens are delimited by one or more whitespace characters. - * - * @return true if a token has been found - */ - __device__ bool prev_token() - { - end_position = start_position - 1; - --itr; - if (end_position <= 0) return false; - // continue search for the next token - start_position = 0; - for (; itr >= d_str.begin(); --itr) { - if (spaces == (*itr <= ' ')) { - if (spaces) - end_position = itr.byte_offset(); - else - start_position = itr.byte_offset(); - continue; - } - spaces = !spaces; - if (spaces) { - start_position = (itr + 1).byte_offset(); - break; - } - } - return start_position < end_position; - } - - __device__ position_pair get_token() const { return position_pair{start_position, end_position}; } - - __device__ whitespace_string_tokenizer(string_view const& d_str, bool reverse = false) - : d_str{d_str}, - spaces(true), - start_position{reverse ? d_str.size_bytes() + 1 : 0}, - end_position{d_str.size_bytes()}, - itr{reverse ? d_str.end() : d_str.begin()} - { - } - - private: - string_view const d_str; - bool spaces; // true if current position is whitespace - cudf::string_view::const_iterator itr; - size_type start_position; - size_type end_position; - }; - - } // namespace detail - } // namespace strings - } // namespace cudf +namespace cudf { +namespace strings { +namespace detail { + +// JIT has trouble including thrust/pair.h +using position_pair = struct { + size_type first; + size_type second; +}; + +/** + * @brief Instantiated for each string to manage navigating tokens from + * the beginning or the end of that string. + */ +struct whitespace_string_tokenizer { + /** + * @brief Identifies the position range of the next token in the given + * string at the specified iterator position. + * + * Tokens are delimited by one or more whitespace characters. + * + * @return true if a token has been found + */ + __device__ bool next_token() + { + if (itr != d_str.begin()) { // skip these 2 lines the first time through + ++itr; + start_position = itr.byte_offset(); // end_position + 1; + } + if (start_position >= d_str.size_bytes()) return false; + // continue search for the next token + end_position = d_str.size_bytes(); + for (; itr < d_str.end(); ++itr) { + if (spaces == (*itr <= ' ')) { + if (spaces) + start_position = (itr + 1).byte_offset(); + else + end_position = (itr + 1).byte_offset(); + continue; + } + spaces = !spaces; + if (spaces) { + end_position = itr.byte_offset(); + break; + } + } + return start_position < end_position; + } + + /** + * @brief Identifies the position range of the previous token in the given + * string at the specified iterator position. + * + * Tokens are delimited by one or more whitespace characters. + * + * @return true if a token has been found + */ + __device__ bool prev_token() + { + end_position = start_position - 1; + --itr; + if (end_position <= 0) return false; + // continue search for the next token + start_position = 0; + for (; itr >= d_str.begin(); --itr) { + if (spaces == (*itr <= ' ')) { + if (spaces) + end_position = itr.byte_offset(); + else + start_position = itr.byte_offset(); + continue; + } + spaces = !spaces; + if (spaces) { + start_position = (itr + 1).byte_offset(); + break; + } + } + return start_position < end_position; + } + + __device__ position_pair get_token() const { return position_pair{start_position, end_position}; } + + __device__ whitespace_string_tokenizer(string_view const& d_str, bool reverse = false) + : d_str{d_str}, + spaces(true), + start_position{reverse ? d_str.size_bytes() + 1 : 0}, + end_position{d_str.size_bytes()}, + itr{reverse ? d_str.end() : d_str.begin()} + { + } + + private: + string_view const d_str; + bool spaces; // true if current position is whitespace + cudf::string_view::const_iterator itr; + size_type start_position; + size_type end_position; +}; + +} // namespace detail +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh index 091db225637..4ac4c8aa826 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh @@ -15,7 +15,6 @@ */ #pragma once - #include #include #include diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh index 32ed98b6aa2..8ee8603caa7 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh @@ -14,42 +14,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - #pragma once +#pragma once - - #include - #include - #include - - namespace cudf { - namespace strings { - namespace udf { - - /** - * @brief Converts a string into an integer. - * - * The '+' and '-' are allowed but only at the beginning of the string. - * The string is expected to contain base-10 [0-9] characters only. - * Any other character will end the parse. - * Overflow of the int64 type is not detected. - */ - __device__ inline int64_t stoi(string_view const& d_str) - { - return cudf::strings::detail::string_to_integer(d_str); - } - - - /** - * @brief Converts a string into a double. - * - * Support scientific notation as well. - * Overflow goes to inf or -inf and underflow may go to 0. - */ - __device__ inline double stod(string_view const& d_str) - { - return cudf::strings::detail::stod(d_str); - } - - } // namespace udf - } // namespace strings - } // namespace cudf +#include +#include +#include + +namespace cudf { +namespace strings { +namespace udf { + +/** + * @brief Converts a string into an integer. + * + * The '+' and '-' are allowed but only at the beginning of the string. + * The string is expected to contain base-10 [0-9] characters only. + * Any other character will end the parse. + * Overflow of the int64 type is not detected. + */ +__device__ inline int64_t stoi(string_view const& d_str) +{ + return cudf::strings::detail::string_to_integer(d_str); +} + +/** + * @brief Converts a string into a double. + * + * Support scientific notation as well. + * Overflow goes to inf or -inf and underflow may go to 0. + */ +__device__ inline double stod(string_view const& d_str) +{ + return cudf::strings::detail::stod(d_str); +} + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index f1fe03dc29f..ab5b2fcf030 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -16,7 +16,6 @@ */ #pragma once - #include namespace cudf { @@ -57,7 +56,6 @@ __device__ inline cudf::size_type count(string_view const source, return count; } - } // namespace udf } // namespace strings } // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh index 73374d64ae5..38c609ae505 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/starts_with.cuh @@ -71,7 +71,6 @@ __device__ inline bool ends_with(cudf::string_view const dstr, return end_str.compare(tgt, bytes) == 0; } - /** * @brief Returns true if the end of the specified string * matches the given target` string. diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp index 36b7576aa0e..2d13b2c03e5 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -22,8 +22,6 @@ #include - - /** * @brief Return a cudf::string_view array for the given strings column * diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu index 774b1c7fd36..c9aaca0a121 100644 --- a/python/strings_udf/cpp/src/strings/udf/shim.cu +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -14,9 +14,9 @@ * limitations under the License. */ -#include #include #include +#include using namespace cudf::strings::udf; @@ -24,255 +24,262 @@ using namespace cudf::strings::udf; len */ -extern "C" -__device__ int len(int* nb_retval, void* str) { - cudf::string_view* sv = reinterpret_cast(str); - *nb_retval = sv->length(); - return 0; +extern "C" __device__ int len(int* nb_retval, void* str) +{ + cudf::string_view* sv = reinterpret_cast(str); + *nb_retval = sv->length(); + return 0; } - /* startswith */ -extern "C" -__device__ int startswith(bool* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); - - *nb_retval = starts_with(*str_view, *substr_view); - return 0; +extern "C" __device__ int startswith(bool* nb_retval, void* str, void* substr) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = starts_with(*str_view, *substr_view); + return 0; } -extern "C" -__device__ int endswith(bool* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); - - *nb_retval = ends_with(*str_view, *substr_view); - return 0; +extern "C" __device__ int endswith(bool* nb_retval, void* str, void* substr) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = ends_with(*str_view, *substr_view); + return 0; } /* contains */ -extern "C" -__device__ int contains(bool* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); +extern "C" __device__ int contains(bool* nb_retval, void* str, void* substr) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); - *nb_retval = (str_view->find(*substr_view) != cudf::string_view::npos); - return 0; + *nb_retval = (str_view->find(*substr_view) != cudf::string_view::npos); + return 0; } /* find */ -extern "C" -__device__ int find(int* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); - - *nb_retval = str_view->find(*substr_view); - return 0; +extern "C" __device__ int find(int* nb_retval, void* str, void* substr) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = str_view->find(*substr_view); + return 0; } /* rfind */ -extern "C" -__device__ int rfind(int* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); - - *nb_retval = str_view->rfind(*substr_view); - return 0; +extern "C" __device__ int rfind(int* nb_retval, void* str, void* substr) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); + + *nb_retval = str_view->rfind(*substr_view); + return 0; } /* == */ -extern "C" -__device__ int eq(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); +extern "C" __device__ int eq(bool* nb_retval, void* str, void* rhs) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); - *nb_retval = (*str_view == *rhs_view); - return 0; + *nb_retval = (*str_view == *rhs_view); + return 0; } /* != */ -extern "C" -__device__ int ne(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); +extern "C" __device__ int ne(bool* nb_retval, void* str, void* rhs) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); - *nb_retval = (*str_view != *rhs_view); - return 0; + *nb_retval = (*str_view != *rhs_view); + return 0; } /* >= */ -extern "C" -__device__ int ge(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); +extern "C" __device__ int ge(bool* nb_retval, void* str, void* rhs) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); - *nb_retval = (*str_view >= *rhs_view); - return 0; + *nb_retval = (*str_view >= *rhs_view); + return 0; } /* <= */ -extern "C" -__device__ int le(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); +extern "C" __device__ int le(bool* nb_retval, void* str, void* rhs) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); - *nb_retval = (*str_view <= *rhs_view); - return 0; + *nb_retval = (*str_view <= *rhs_view); + return 0; } /* > */ -extern "C" -__device__ int gt(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); +extern "C" __device__ int gt(bool* nb_retval, void* str, void* rhs) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); - *nb_retval = (*str_view > *rhs_view); - return 0; + *nb_retval = (*str_view > *rhs_view); + return 0; } /* < */ -extern "C" -__device__ int lt(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); +extern "C" __device__ int lt(bool* nb_retval, void* str, void* rhs) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* rhs_view = reinterpret_cast(rhs); - *nb_retval = (*str_view < *rhs_view); - return 0; + *nb_retval = (*str_view < *rhs_view); + return 0; } /* islower */ -extern "C" -__device__ int pyislower(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyislower(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_lower(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_lower( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isupper */ -extern "C" -__device__ int pyisupper(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisupper(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_upper(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_upper( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isspace */ -extern "C" -__device__ int pyisspace(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisspace(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_space(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_space( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isdecimal */ -extern "C" -__device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_decimal(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_decimal( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isnumeric */ -extern "C" -__device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_numeric(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_numeric( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isdigit */ -extern "C" -__device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_digit(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_digit( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isalnum */ -extern "C" -__device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_alpha_numeric(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_alpha_numeric( + reinterpret_cast(chars_table), *str_view); + return 0; } /* isalpha */ -extern "C" -__device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); +extern "C" __device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t chars_table) +{ + cudf::string_view* str_view = reinterpret_cast(str); - *nb_retval = is_alpha(reinterpret_cast(chars_table), *str_view); - return 0; + *nb_retval = is_alpha( + reinterpret_cast(chars_table), *str_view); + return 0; } /* count */ -extern "C" -__device__ int pycount(int* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); +extern "C" __device__ int pycount(int* nb_retval, void* str, void* substr) +{ + cudf::string_view* str_view = reinterpret_cast(str); + cudf::string_view* substr_view = reinterpret_cast(substr); - *nb_retval = count(*str_view, *substr_view); - return 0; + *nb_retval = count(*str_view, *substr_view); + return 0; } diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu index 3b11c73cfbe..c06a58d5eb3 100644 --- a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -1,19 +1,18 @@ /* -* Copyright (c) 2021-2022, NVIDIA CORPORATION. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include @@ -30,15 +29,15 @@ #include std::unique_ptr to_string_view_array(cudf::column_view const input, - rmm::cuda_stream_view stream) + rmm::cuda_stream_view stream) { -return std::make_unique( -std::move(cudf::strings::detail::create_string_vector_from_column( -cudf::strings_column_view(input), stream) -.release())); + return std::make_unique( + std::move(cudf::strings::detail::create_string_vector_from_column( + cudf::strings_column_view(input), stream) + .release())); } std::unique_ptr to_string_view_array(cudf::column_view const input) { -return to_string_view_array(input, rmm::cuda_stream_default); + return to_string_view_array(input, rmm::cuda_stream_default); } From 30b1a4593d1e9ab6c04a87c9721930596f68bc63 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Fri, 2 Sep 2022 16:44:42 -0400 Subject: [PATCH 095/212] Update python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh --- python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh | 1 + 1 file changed, 1 insertion(+) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh index 4ac4c8aa826..a006718c35b 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh @@ -18,6 +18,7 @@ #include #include #include +#include namespace cudf { namespace strings { From 6a51daa54a49c7943d41485a93927d7f6ee893cc Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Tue, 6 Sep 2022 09:21:21 -0500 Subject: [PATCH 096/212] Apply suggestions from code review Co-authored-by: Bradley Dice --- conda/recipes/strings_udf/meta.yaml | 2 +- python/cudf/cudf/core/udf/masked_typing.py | 3 +-- python/cudf/cudf/core/udf/row_function.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index 18dd0cbea0d..4f6c30849a0 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -2,7 +2,7 @@ {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} {% set minor_version = version.split('.')[0] + '.' + version.split('.')[1] %} -{% set py_version=environ.get('CONDA_PY', 36) %} +{% set py_version=environ.get('CONDA_PY', 38) %} {% set cuda_version='.'.join(environ.get('CUDA', '11.5').split('.')[:2]) %} {% set cuda_major=cuda_version.split('.')[0] %} diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 558fbfdf4e2..a77d7cbf734 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -55,7 +55,7 @@ "\n" + redstart + "strings_udf library required for usage of string dtypes " - "inside user defined functions. try conda install strings_udf" + "inside user defined functions. Try conda install strings_udf." + redend + "\n" ) @@ -68,7 +68,6 @@ def _type_to_masked_type(t): if isinstance(t, SUPPORTED_NUMBA_TYPES): return t else: - breakpoint() return types.Poison( # Unsupported Dtype. Numba tends to print out the type info # for whatever operands and operation failed to type and then diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index f9d08033bbf..db863e8dd38 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -25,7 +25,7 @@ _supported_dtypes_from_frame, ) -itemsizes: Dict[Any, Any] = {} +itemsizes: Dict[Any, int] = {} def _get_frame_row_type(dtype): From fe1cddc8861edf15b88028fa8830fa839d0a9c08 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 6 Sep 2022 08:32:49 -0700 Subject: [PATCH 097/212] address reviews --- python/cudf/cudf/core/indexed_frame.py | 16 ++----- python/cudf/cudf/core/udf/masked_typing.py | 45 ++++++++----------- python/cudf/cudf/core/udf/strings_typing.py | 26 ++++------- python/cudf/cudf/core/udf/utils.py | 20 +++++++++ python/strings_udf/strings_udf/tests/utils.py | 1 + 5 files changed, 52 insertions(+), 56 deletions(-) diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index c609d4f8b7a..2de6fa3d3a6 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -53,10 +53,9 @@ from cudf.core.resample import _Resampler from cudf.core.udf.utils import ( _compile_or_get, - _launch_arg_from_col, + _get_input_args_from_frame, _post_process_output_col, _return_col_from_dtype, - _supported_cols_from_frame, ) from cudf.utils import docutils from cudf.utils.utils import _cudf_nvtx_annotate @@ -1807,16 +1806,9 @@ def _apply(self, func, kernel_getter, *args, **kwargs): # Mask and data column preallocated ans_col = _return_col_from_dtype(retty, len(self)) ans_mask = cudf.core.column.column_empty(len(self), dtype="bool") - launch_args = [(ans_col, ans_mask), len(self)] - offsets = [] - - # if _compile_or_get succeeds, it is safe to create a kernel that only - # consumes the columns that are of supported dtype - for col in _supported_cols_from_frame(self).values(): - launch_args.append(_launch_arg_from_col(col)) - offsets.append(col.offset) - launch_args += offsets - launch_args += list(args) + output_args = [(ans_col, ans_mask), len(self)] + input_args = _get_input_args_from_frame(self) + launch_args = output_args + input_args + list(args) try: kernel.forall(len(self))(*launch_args) diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index a77d7cbf734..b08df0ba32f 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -45,21 +45,11 @@ NUMERIC_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES | STRING_TYPES ) supported_type_str = "\n".join(sorted(list(SUPPORTED_NUMPY_TYPES) + ["bool"])) +MASKED_INIT_MAP: Dict[Any, Any] = {} -redstart = "\033[91m" -redend = "\033[0m" - -MASKED_INIT_MAP: Dict[Any, Any] = { - types.pyobject: types.Poison( - "\n" - + redstart - + "strings_udf library required for usage of string dtypes " - "inside user defined functions. Try conda install strings_udf." - + redend - + "\n" - ) -} +def _format_error_string(err): + return "\033[91m" + "\n" + err + "\n" + "\033[0m" def _type_to_masked_type(t): @@ -68,21 +58,28 @@ def _type_to_masked_type(t): if isinstance(t, SUPPORTED_NUMBA_TYPES): return t else: - return types.Poison( - # Unsupported Dtype. Numba tends to print out the type info - # for whatever operands and operation failed to type and then - # output its own error message. Putting the message in the repr - # then is one way of getting the true cause to the user - "\n" - + redstart - + "Unsupported MaskedType. This is usually caused by " + # Unsupported Dtype. Numba tends to print out the type info + # for whatever operands and operation failed to type and then + # output its own error message. Putting the message in the repr + # then is one way of getting the true cause to the user + err = _format_error_string( + "Unsupported MaskedType. This is usually caused by " "attempting to use a column of unsupported dtype in a UDF. " - f"Supported dtypes are:\n{supported_type_str}" + redend + f"Supported dtypes are:\n{supported_type_str}" ) + return types.Poison(err) else: return result +MASKED_INIT_MAP[types.pyobject] = types.Poison( + _format_error_string( + "strings_udf library required for usage of string dtypes " + "inside user defined functions. Try conda install strings_udf." + ) +) + + # Masked scalars of all types class MaskedType(types.Type): """ @@ -171,11 +168,7 @@ def typeof_masked(val, c): # type in a kernel. def register_masked_constructor(supported_masked_types): class MaskedConstructor(ConcreteTemplate): - key = api.Masked - units = ["ns", "ms", "us", "s"] - datetime_cases = {types.NPDatetime(u) for u in units} - timedelta_cases = {types.NPTimedelta(u) for u in units} cases = [ nb_signature(MaskedType(t), t, types.boolean) for t in supported_masked_types diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 91e38cb99ad..84bb2f9a1f6 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -18,6 +18,12 @@ masked_typing.MASKED_INIT_MAP[string_view] = string_view +def _is_valid_string_arg(ty): + return ( + isinstance(ty, MaskedType) and isinstance(ty.value_type, StringView) + ) or isinstance(ty, types.StringLiteral) + + # String functions @cuda_decl_registry.register_global(len) class MaskedStringViewLength(AbstractTemplate): @@ -39,15 +45,7 @@ class MaskedStringViewContains(AbstractTemplate): """ def generic(self, args, kws): - if ( - isinstance(args[0], MaskedType) - and isinstance(args[0].value_type, StringView) - or isinstance(args[0], types.StringLiteral) - ) and ( - isinstance(args[1], MaskedType) - and isinstance(args[1].value_type, StringView) - or isinstance(args[1], types.StringLiteral) - ): + if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): return nb_signature( MaskedType(types.boolean), MaskedType(string_view), @@ -63,15 +61,7 @@ class MaskedStringViewCmpOp(AbstractTemplate): """ def generic(self, args, kws): - if ( - isinstance(args[0], MaskedType) - and isinstance(args[0].value_type, StringView) - or isinstance(args[0], types.StringLiteral) - ) and ( - isinstance(args[1], MaskedType) - and isinstance(args[1].value_type, StringView) - or isinstance(args[1], types.StringLiteral) - ): + if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): return nb_signature( MaskedType(types.boolean), MaskedType(string_view), diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 90262906fbb..3c0724343c1 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -252,6 +252,26 @@ def _launch_arg_from_col(col): return data, mask +def _get_input_args_from_frame(fr): + args = [] + offsets = [] + for col in _supported_cols_from_frame(fr).values(): + getter = launch_arg_getters.get(col.dtype) + if getter: + data = getter(col) + else: + data = col.data + if col.mask is not None: + # argument is a tuple of data, mask + args.append((data, col.mask)) + else: + # argument is just the data pointer + args.append(data) + offsets.append(col.offset) + + return args + offsets + + def _return_col_from_dtype(dt, size): return cp.empty(size, dtype=dt) diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 01ed86eb497..24f17c8eaba 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -16,6 +16,7 @@ def run_udf_test(data, func, dtype): + breakpoint() dtype = np.dtype(dtype) cudf_column = cudf.Series(data)._column str_view_ary = to_string_view_array(cudf_column) From 8b2c1e7158aa0b29fbef4cdd605e18526bd179d6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 6 Sep 2022 08:57:10 -0700 Subject: [PATCH 098/212] merge test files --- .../strings_udf/tests/test_cmpops.py | 83 ------ .../strings_udf/tests/test_contains.py | 18 -- .../strings_udf/tests/test_count.py | 18 -- .../strings_udf/tests/test_endswith.py | 18 -- .../strings_udf/tests/test_find.py | 18 -- .../strings_udf/tests/test_isalnum.py | 15 - .../strings_udf/tests/test_isalpha.py | 17 -- .../strings_udf/tests/test_isdecimal.py | 15 - .../strings_udf/tests/test_isdigit.py | 15 - .../strings_udf/tests/test_islower.py | 17 -- .../strings_udf/tests/test_isnumeric.py | 15 - .../strings_udf/tests/test_isspace.py | 15 - .../strings_udf/tests/test_isupper.py | 17 -- .../strings_udf/tests/test_length.py | 15 - .../strings_udf/tests/test_rfind.py | 18 -- .../strings_udf/tests/test_startswith.py | 18 -- .../strings_udf/tests/test_string_udfs.py | 257 ++++++++++++++++++ python/strings_udf/strings_udf/tests/utils.py | 1 - 18 files changed, 257 insertions(+), 333 deletions(-) delete mode 100644 python/strings_udf/strings_udf/tests/test_cmpops.py delete mode 100644 python/strings_udf/strings_udf/tests/test_contains.py delete mode 100644 python/strings_udf/strings_udf/tests/test_count.py delete mode 100644 python/strings_udf/strings_udf/tests/test_endswith.py delete mode 100644 python/strings_udf/strings_udf/tests/test_find.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isalnum.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isalpha.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isdecimal.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isdigit.py delete mode 100644 python/strings_udf/strings_udf/tests/test_islower.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isnumeric.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isspace.py delete mode 100644 python/strings_udf/strings_udf/tests/test_isupper.py delete mode 100644 python/strings_udf/strings_udf/tests/test_length.py delete mode 100644 python/strings_udf/strings_udf/tests/test_rfind.py delete mode 100644 python/strings_udf/strings_udf/tests/test_startswith.py create mode 100644 python/strings_udf/strings_udf/tests/test_string_udfs.py diff --git a/python/strings_udf/strings_udf/tests/test_cmpops.py b/python/strings_udf/strings_udf/tests/test_cmpops.py deleted file mode 100644 index b82adb5fbe8..00000000000 --- a/python/strings_udf/strings_udf/tests/test_cmpops.py +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) -def test_string_udf_eq(data, rhs): - # tests the `==` operator in string udfs - - def func(st): - return st == rhs - - run_udf_test(data, func, "bool") - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) -def test_string_udf_ne(data, rhs): - # tests the `!=` operator in string udfs - - def func(st): - return st != rhs - - run_udf_test(data, func, "bool") - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) -def test_string_udf_ge(data, rhs): - # tests the `>=` operator in string udfs - - def func(st): - return st >= rhs - - run_udf_test(data, func, "bool") - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) -def test_string_udf_le(data, rhs): - # tests the `<=` operator in string udfs - - def func(st): - return st <= rhs - - run_udf_test(data, func, "bool") - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) -def test_string_udf_gt(data, rhs): - # tests the `>` operator in string udfs - - def func(st): - return st > rhs - - run_udf_test(data, func, "bool") - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) -def test_string_udf_lt(data, rhs): - # tests the `<` operator in string udfs - - def func(st): - return st < rhs - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_contains.py b/python/strings_udf/strings_udf/tests/test_contains.py deleted file mode 100644 index 562a4d2535f..00000000000 --- a/python/strings_udf/strings_udf/tests/test_contains.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) -def test_string_udf_contains(data, substr): - # Tests contains for string UDFs - - def func(st): - return substr in st - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_count.py b/python/strings_udf/strings_udf/tests/test_count.py deleted file mode 100644 index faa70b43450..00000000000 --- a/python/strings_udf/strings_udf/tests/test_count.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) -def test_string_udf_count(data, substr): - # tests the `count` function in string udfs - - def func(st): - return st.count(substr) - - run_udf_test(data, func, "int32") diff --git a/python/strings_udf/strings_udf/tests/test_endswith.py b/python/strings_udf/strings_udf/tests/test_endswith.py deleted file mode 100644 index 5a09077d5f7..00000000000 --- a/python/strings_udf/strings_udf/tests/test_endswith.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) -def test_string_udf_endswith(data, substr): - # tests the `endswith` function in string udfs - - def func(st): - return st.endswith(substr) - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_find.py b/python/strings_udf/strings_udf/tests/test_find.py deleted file mode 100644 index 59c03a74f28..00000000000 --- a/python/strings_udf/strings_udf/tests/test_find.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) -def test_string_udf_find(data, substr): - # tests the `find` function in string udfs - - def func(st): - return st.find(substr) - - run_udf_test(data, func, "int32") diff --git a/python/strings_udf/strings_udf/tests/test_isalnum.py b/python/strings_udf/strings_udf/tests/test_isalnum.py deleted file mode 100644 index 38059eeb1f4..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isalnum.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize("data", [["1", "1@2", "123abc", "2.1", "", "0003"]]) -def test_string_udf_isalnum(data): - # tests the `rfind` function in string udfs - - def func(st): - return st.isalnum() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isalpha.py b/python/strings_udf/strings_udf/tests/test_isalpha.py deleted file mode 100644 index 222beb1cf4c..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isalpha.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]] -) -def test_string_udf_isalpha(data): - # tests the `isalpha` function in string udfs - - def func(st): - return st.isalpha() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isdecimal.py b/python/strings_udf/strings_udf/tests/test_isdecimal.py deleted file mode 100644 index a1f6ad55376..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isdecimal.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) -def test_string_udf_isdecimal(data): - # tests the `isdecimal` function in string udfs - - def func(st): - return st.isdecimal() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isdigit.py b/python/strings_udf/strings_udf/tests/test_isdigit.py deleted file mode 100644 index 5c32b9570de..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isdigit.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) -def test_string_udf_isdigit(data): - # tests the `isdigit` function in string udfs - - def func(st): - return st.isdigit() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_islower.py b/python/strings_udf/strings_udf/tests/test_islower.py deleted file mode 100644 index 993cd73e51f..00000000000 --- a/python/strings_udf/strings_udf/tests/test_islower.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["1", "12", "123abc", "2.1", "", "0003", "abc", "b a", "AbC"]] -) -def test_string_udf_islower(data): - # tests the `islower` function in string udfs - - def func(st): - return st.islower() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isnumeric.py b/python/strings_udf/strings_udf/tests/test_isnumeric.py deleted file mode 100644 index b4df15180a9..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isnumeric.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) -def test_string_udf_isnumeric(data): - # tests the `isnumeric` function in string udfs - - def func(st): - return st.isnumeric() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isspace.py b/python/strings_udf/strings_udf/tests/test_isspace.py deleted file mode 100644 index 3d9a52b081b..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isspace.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize("data", [["1", " x ", " ", "2.1", "", "0003"]]) -def test_string_udf_isspace(data): - # tests the `isspace` function in string udfs - - def func(st): - return st.isspace() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_isupper.py b/python/strings_udf/strings_udf/tests/test_isupper.py deleted file mode 100644 index bdc2283521b..00000000000 --- a/python/strings_udf/strings_udf/tests/test_isupper.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]] -) -def test_string_udf_isupper(data): - # tests the `isupper` function in string udfs - - def func(st): - return st.isupper() - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_length.py b/python/strings_udf/strings_udf/tests/test_length.py deleted file mode 100644 index 53f57d9510e..00000000000 --- a/python/strings_udf/strings_udf/tests/test_length.py +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2021-2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022"]]) -def test_string_udf_len(data): - # tests the `len` function in string udfs - - def func(st): - return len(st) - - run_udf_test(data, func, "int64") diff --git a/python/strings_udf/strings_udf/tests/test_rfind.py b/python/strings_udf/strings_udf/tests/test_rfind.py deleted file mode 100644 index 8aeb59edd9e..00000000000 --- a/python/strings_udf/strings_udf/tests/test_rfind.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) -def test_string_udf_rfind(data, substr): - # tests the `rfind` function in string udfs - - def func(st): - return st.rfind(substr) - - run_udf_test(data, func, "int32") diff --git a/python/strings_udf/strings_udf/tests/test_startswith.py b/python/strings_udf/strings_udf/tests/test_startswith.py deleted file mode 100644 index 6193f81bab8..00000000000 --- a/python/strings_udf/strings_udf/tests/test_startswith.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import pytest - -from .utils import run_udf_test - - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) -def test_string_udf_startswith(data, substr): - # tests the `startswith` function in string udfs - - def func(st): - return st.startswith(substr) - - run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py new file mode 100644 index 00000000000..a67da7f5831 --- /dev/null +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -0,0 +1,257 @@ +# Copyright (c) 2022, NVIDIA CORPORATION. + +import pytest + +from .utils import run_udf_test + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_eq(data, rhs): + # tests the `==` operator in string udfs + + def func(st): + return st == rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_ne(data, rhs): + # tests the `!=` operator in string udfs + + def func(st): + return st != rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_ge(data, rhs): + # tests the `>=` operator in string udfs + + def func(st): + return st >= rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_le(data, rhs): + # tests the `<=` operator in string udfs + + def func(st): + return st <= rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_gt(data, rhs): + # tests the `>` operator in string udfs + + def func(st): + return st > rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) +def test_string_udf_lt(data, rhs): + # tests the `<` operator in string udfs + + def func(st): + return st < rhs + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) +def test_string_udf_contains(data, substr): + # Tests contains for string UDFs + + def func(st): + return substr in st + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) +def test_string_udf_count(data, substr): + # tests the `count` function in string udfs + + def func(st): + return st.count(substr) + + run_udf_test(data, func, "int32") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) +def test_string_udf_find(data, substr): + # tests the `find` function in string udfs + + def func(st): + return st.find(substr) + + run_udf_test(data, func, "int32") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) +def test_string_udf_endswith(data, substr): + # tests the `endswith` function in string udfs + + def func(st): + return st.endswith(substr) + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["1", "1@2", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isalnum(data): + # tests the `rfind` function in string udfs + + def func(st): + return st.isalnum() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]] +) +def test_string_udf_isalpha(data): + # tests the `isalpha` function in string udfs + + def func(st): + return st.isalpha() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isdecimal(data): + # tests the `isdecimal` function in string udfs + + def func(st): + return st.isdecimal() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isdigit(data): + # tests the `isdigit` function in string udfs + + def func(st): + return st.isdigit() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["1", "12", "123abc", "2.1", "", "0003", "abc", "b a", "AbC"]] +) +def test_string_udf_islower(data): + # tests the `islower` function in string udfs + + def func(st): + return st.islower() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +def test_string_udf_isnumeric(data): + # tests the `isnumeric` function in string udfs + + def func(st): + return st.isnumeric() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["1", " x ", " ", "2.1", "", "0003"]]) +def test_string_udf_isspace(data): + # tests the `isspace` function in string udfs + + def func(st): + return st.isspace() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize( + "data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]] +) +def test_string_udf_isupper(data): + # tests the `isupper` function in string udfs + + def func(st): + return st.isupper() + + run_udf_test(data, func, "bool") + + +@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022"]]) +def test_string_udf_len(data): + # tests the `len` function in string udfs + + def func(st): + return len(st) + + run_udf_test(data, func, "int64") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) +def test_string_udf_rfind(data, substr): + # tests the `rfind` function in string udfs + + def func(st): + return st.rfind(substr) + + run_udf_test(data, func, "int32") + + +@pytest.mark.parametrize( + "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] +) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) +def test_string_udf_startswith(data, substr): + # tests the `startswith` function in string udfs + + def func(st): + return st.startswith(substr) + + run_udf_test(data, func, "bool") diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 24f17c8eaba..01ed86eb497 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -16,7 +16,6 @@ def run_udf_test(data, func, dtype): - breakpoint() dtype = np.dtype(dtype) cudf_column = cudf.Series(data)._column str_view_ary = to_string_view_array(cudf_column) From f19ead6723b7a9bb6cfcc54c92818d2590906ab8 Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Tue, 6 Sep 2022 20:19:31 -0500 Subject: [PATCH 099/212] Apply suggestions from code review Co-authored-by: Bradley Dice --- python/strings_udf/strings_udf/_typing.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index d7d33a90046..84b63a232f5 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -41,11 +41,11 @@ class stringview_model(models.StructModel): # const char* _data{} # Pointer to device memory contain char array for this string ("data", types.CPointer(types.char)), - # size_type _bytes{}; - # Number of bytes in _data for this string + # size_type _bytes{}; + # Number of bytes in _data for this string ("bytes", types.int32), - # mutable size_type _length{}; - # Number of characters in this string (computed) + # mutable size_type _length{}; + # Number of characters in this string (computed) ("length", types.int32), ) @@ -77,15 +77,14 @@ def __init__(self, dmm, fe_type): class StrViewArgHandler: """ - As part of Numbas preprocessing step incoming function arguments are + As part of Numba's preprocessing step, incoming function arguments are modified based on the associated type for that argument that was used to JIT the kernel. However it only knows how to handle built in array types natively. With string UDFs, the jitted type is string_view*, which numba does not know how to handle. - This small piece of code implements the necessary handling. Really all - it does is funnel the handling of string_view* to the handling - of raw pointer arguments, which numba knows how to use. + This class converts string_view* to raw pointer arguments, which Numba + knows how to use. See numba.cuda.compiler._prepare_args for details. """ From b3eeb9ff56dfa074ae31909d332269888a7d9ce5 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 6 Sep 2022 18:23:17 -0700 Subject: [PATCH 100/212] prune cython files --- python/strings_udf/strings_udf/_lib/__init__.pxd | 0 python/strings_udf/strings_udf/_lib/cpp/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 python/strings_udf/strings_udf/_lib/__init__.pxd delete mode 100644 python/strings_udf/strings_udf/_lib/cpp/__init__.py diff --git a/python/strings_udf/strings_udf/_lib/__init__.pxd b/python/strings_udf/strings_udf/_lib/__init__.pxd deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/python/strings_udf/strings_udf/_lib/cpp/__init__.py b/python/strings_udf/strings_udf/_lib/cpp/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 From c4b4c7b38b01e1aa3616c079cd3c6ad55a5e434e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 7 Sep 2022 07:09:33 -0700 Subject: [PATCH 101/212] prune imports and correct use of gil --- .../strings_udf/_lib/cpp/strings_udf.pxd | 2 +- .../strings_udf/_lib/cudf_jit_udf.pyx | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index 7695951d5e5..a8886501ac8 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -11,7 +11,7 @@ from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -cdef extern from "cudf/strings/udf/udf_apis.hpp": +cdef extern from "cudf/strings/udf/udf_apis.hpp" nogil: cdef unique_ptr[device_buffer] to_string_view_array(column_view) cdef extern from "cudf/strings/detail/char_tables.hpp" namespace \ diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 2b7dcd81637..1c6f254afc3 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -1,35 +1,24 @@ # Copyright (c) 2021-2022, NVIDIA CORPORATION. -# -# distutils: language = c++ -# cython: c_string_type=unicode, c_string_encoding=utf8 - -import os from libcpp.memory cimport unique_ptr -from libcpp.string cimport string from libcpp.utility cimport move -from libcpp.vector cimport vector from cudf.core.buffer import Buffer from cudf._lib.column cimport Column -from cudf._lib.cpp.column.column cimport column -from cudf._lib.cpp.column.column_view cimport column_view -from cudf._lib.cpp.types cimport size_type +from cudf._lib.cpp.column.column cimport column, column_view from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer from strings_udf._lib.cpp.strings_udf cimport ( to_string_view_array as cpp_to_string_view_array, ) -import numpy as np - def to_string_view_array(Column strings_col): cdef unique_ptr[device_buffer] c_buffer - - # with nogil: - c_buffer = move(cpp_to_string_view_array(strings_col.view())) + cdef column_view input_view = strings_col.view() + with nogil: + c_buffer = move(cpp_to_string_view_array(input_view)) buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) buffer = Buffer(buffer) From 9231469a3b188c00e8a8099761e7867e3ffdd1b1 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 7 Sep 2022 07:27:39 -0700 Subject: [PATCH 102/212] define size_type = types.int32 and use throughout strings_udf and cudf libraries --- python/cudf/cudf/core/udf/masked_typing.py | 3 +++ python/cudf/cudf/core/udf/strings_lowering.py | 8 +++---- python/cudf/cudf/core/udf/strings_typing.py | 10 ++++----- python/strings_udf/strings_udf/_typing.py | 19 +++++++++------- python/strings_udf/strings_udf/lowering.py | 22 +++++++++---------- 5 files changed, 34 insertions(+), 28 deletions(-) diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index b08df0ba32f..4a990e27466 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -49,6 +49,9 @@ def _format_error_string(err): + """ + Wrap an error message in newlines and color it red. + """ return "\033[91m" + "\n" + err + "\n" + "\033[0m" diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index 02850dae2b2..d36ee5ccbee 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -6,7 +6,7 @@ from numba.core import cgutils from numba.cuda.cudaimpl import lower as cuda_lower -from strings_udf._typing import string_view +from strings_udf._typing import size_type, string_view from strings_udf.lowering import ( string_view_contains_impl, string_view_endswith_impl, @@ -34,7 +34,7 @@ def masked_string_view_len_impl(context, builder, sig, args): context, builder, value=args[0] ) result = string_view_len_impl( - context, builder, types.int32(string_view), (masked_sv.value,) + context, builder, size_type(string_view), (masked_sv.value,) ) ret.value = result ret.valid = masked_sv.valid @@ -105,7 +105,7 @@ def masked_string_view_find_impl(context, builder, sig, args): result = string_view_find_impl( context, builder, - types.boolean(string_view, string_view), + size_type(string_view, string_view), (masked_sv_str.value, masked_sv_substr.value), ) @@ -129,7 +129,7 @@ def masked_string_view_rfind_impl(context, builder, sig, args): result = string_view_rfind_impl( context, builder, - types.boolean(string_view, string_view), + size_type(string_view, string_view), (masked_sv_str.value, masked_sv_substr.value), ) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 84bb2f9a1f6..ce6dbfb4946 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -8,7 +8,7 @@ from numba.core.typing.templates import AbstractTemplate, AttributeTemplate from numba.cuda.cudadecl import registry as cuda_decl_registry -from strings_udf._typing import StringView, string_view +from strings_udf._typing import StringView, size_type, string_view from cudf.core.udf import masked_typing from cudf.core.udf._ops import comparison_ops @@ -35,7 +35,7 @@ def generic(self, args, kws): if isinstance(args[0], MaskedType) and isinstance( args[0].value_type, StringView ): - return nb_signature(MaskedType(types.int32), args[0]) + return nb_signature(MaskedType(size_type), args[0]) @cuda_decl_registry.register_global(operator.contains) @@ -78,7 +78,7 @@ class StringLiteralLength(AbstractTemplate): def generic(self, args, kws): if isinstance(args[0], types.StringLiteral) and len(args) == 1: - return nb_signature(types.int32, args[0]) + return nb_signature(size_type, args[0]) class MaskedStringViewStartsWith(AbstractTemplate): @@ -104,7 +104,7 @@ class MaskedStringViewFind(AbstractTemplate): def generic(self, args, kws): return nb_signature( - MaskedType(types.int32), MaskedType(string_view), recvr=self.this + MaskedType(size_type), MaskedType(string_view), recvr=self.this ) @@ -113,7 +113,7 @@ class MaskedStringViewRFind(AbstractTemplate): def generic(self, args, kws): return nb_signature( - MaskedType(types.int32), MaskedType(string_view), recvr=self.this + MaskedType(size_type), MaskedType(string_view), recvr=self.this ) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index 84b63a232f5..ee8bef6d21a 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -13,6 +13,9 @@ data_layout = nvvm.data_layout +# libcudf size_type +size_type = types.int32 + # workaround for numba < 0.56 if isinstance(data_layout, dict): data_layout = data_layout[64] @@ -43,10 +46,10 @@ class stringview_model(models.StructModel): ("data", types.CPointer(types.char)), # size_type _bytes{}; # Number of bytes in _data for this string - ("bytes", types.int32), + ("bytes", size_type), # mutable size_type _length{}; # Number of characters in this string (computed) - ("length", types.int32), + ("length", size_type), ) def __init__(self, dmm, fe_type): @@ -63,8 +66,8 @@ class dstring_model(models.StructModel): _members = ( ("m_data", types.CPointer(types.char)), - ("m_bytes", types.int32), - ("m_size", types.int32), + ("m_bytes", size_type), + ("m_size", size_type), ) def __init__(self, dmm, fe_type): @@ -112,7 +115,7 @@ def generic(self, args, kws): # string_view -> int32 # dstring -> int32 # literal -> int32 - return nb_signature(types.int32, args[0]) + return nb_signature(size_type, args[0]) @cuda_decl_registry.register_global(operator.contains) @@ -236,14 +239,14 @@ class StringViewFind(AbstractTemplate): key = "StringView.find" def generic(self, args, kws): - return nb_signature(types.int32, string_view, recvr=self.this) + return nb_signature(size_type, string_view, recvr=self.this) class StringViewRFind(AbstractTemplate): key = "StringView.rfind" def generic(self, args, kws): - return nb_signature(types.int32, string_view, recvr=self.this) + return nb_signature(size_type, string_view, recvr=self.this) class StringViewIsAlnum(AbstractTemplate): @@ -306,7 +309,7 @@ class StringViewCount(AbstractTemplate): key = "StringView.count" def generic(self, args, kws): - return nb_signature(types.int32, string_view, recvr=self.this) + return nb_signature(size_type, string_view, recvr=self.this) @cuda_decl_registry.register_attr diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 7d1996b6978..b85bc5175a7 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -12,13 +12,13 @@ ) from strings_udf._lib.tables import get_character_flags_table_ptr -from strings_udf._typing import string_view +from strings_udf._typing import size_type, string_view character_flags_table_ptr = get_character_flags_table_ptr() _string_view_len = cuda.declare_device( - "len", types.int32(types.CPointer(string_view)) + "len", size_type(types.CPointer(string_view)) ) _string_view_contains = cuda.declare_device( @@ -67,12 +67,12 @@ _string_view_find = cuda.declare_device( "find", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), + size_type(types.CPointer(string_view), types.CPointer(string_view)), ) _string_view_rfind = cuda.declare_device( "rfind", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), + size_type(types.CPointer(string_view), types.CPointer(string_view)), ) _string_view_isdigit = cuda.declare_device( @@ -110,7 +110,7 @@ _string_view_count = cuda.declare_device( "pycount", - types.int32(types.CPointer(string_view), types.CPointer(string_view)), + size_type(types.CPointer(string_view), types.CPointer(string_view)), ) @@ -126,7 +126,7 @@ def string_view_len_impl(context, builder, sig, args): result = context.compile_internal( builder, call_len_string_view, - nb_signature(types.int32, types.CPointer(string_view)), + nb_signature(size_type, types.CPointer(string_view)), (sv_ptr,), ) @@ -334,9 +334,9 @@ def cast_string_literal_to_string_view(context, builder, fromty, toty, val): sv.data = context.insert_addrspace_conv( builder, s, nvvm.ADDRSPACE_CONSTANT ) - sv.length = context.get_constant(types.int32, len(fromty.literal_value)) + sv.length = context.get_constant(size_type, len(fromty.literal_value)) sv.bytes = context.get_constant( - types.int32, len(fromty.literal_value.encode("UTF-8")) + size_type, len(fromty.literal_value.encode("UTF-8")) ) return sv._getvalue() @@ -413,7 +413,7 @@ def string_view_coount_impl(context, builder, sig, args): builder, call_string_view_count, nb_signature( - types.int32, + size_type, types.CPointer(string_view), types.CPointer(string_view), ), @@ -440,7 +440,7 @@ def string_view_find_impl(context, builder, sig, args): builder, call_string_view_find, nb_signature( - types.int32, + size_type, types.CPointer(string_view), types.CPointer(string_view), ), @@ -467,7 +467,7 @@ def string_view_rfind_impl(context, builder, sig, args): builder, call_string_view_rfind, nb_signature( - types.int32, + size_type, types.CPointer(string_view), types.CPointer(string_view), ), From 985572f829bb3aab4d863ad931a263795ef43ede Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 7 Sep 2022 07:37:57 -0700 Subject: [PATCH 103/212] move functions around in tests/utils.py --- python/strings_udf/strings_udf/tests/utils.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 01ed86eb497..9e9f5733165 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -15,20 +15,6 @@ from strings_udf._typing import str_view_arg_handler, string_view -def run_udf_test(data, func, dtype): - dtype = np.dtype(dtype) - cudf_column = cudf.Series(data)._column - str_view_ary = to_string_view_array(cudf_column) - - output_ary = cudf.core.column.column_empty(len(data), dtype=dtype) - - kernel = get_kernel(func, dtype) - kernel.forall(len(data))(str_view_ary, output_ary) - got = cudf.Series(output_ary, dtype=dtype) - expect = pd.Series(data).apply(func) - assert_eq(expect, got, check_dtype=False) - - def get_kernel(func, dtype): func = cuda.jit(device=True)(func) @@ -46,3 +32,17 @@ def execute_function(input_strings, output_col): ) return kernel + + +def run_udf_test(data, func, dtype): + dtype = np.dtype(dtype) + cudf_column = cudf.Series(data)._column + str_view_ary = to_string_view_array(cudf_column) + + output_ary = cudf.core.column.column_empty(len(data), dtype=dtype) + + kernel = get_kernel(func, dtype) + kernel.forall(len(data))(str_view_ary, output_ary) + got = cudf.Series(output_ary, dtype=dtype) + expect = pd.Series(data).apply(func) + assert_eq(expect, got, check_dtype=False) From bfcb0ec63d58e1f3bf2be650a8e1bc6156a88b4b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 7 Sep 2022 07:56:15 -0700 Subject: [PATCH 104/212] add tests and bindings for MaskedType(string_view).count() --- python/cudf/cudf/core/udf/strings_lowering.py | 25 +++++++++++++++++++ python/cudf/cudf/core/udf/strings_typing.py | 14 +++++++++++ python/cudf/cudf/tests/test_udf_masked_ops.py | 14 +++++++++++ python/strings_udf/strings_udf/lowering.py | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index d36ee5ccbee..7ec4c8b6828 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -9,6 +9,7 @@ from strings_udf._typing import size_type, string_view from strings_udf.lowering import ( string_view_contains_impl, + string_view_count_impl, string_view_endswith_impl, string_view_find_impl, string_view_isalnum_impl, @@ -138,6 +139,30 @@ def masked_string_view_rfind_impl(context, builder, sig, args): return ret._getvalue() +@cuda_lower( + "MaskedType.count", MaskedType(string_view), MaskedType(string_view) +) +def masked_string_view_count_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_sv_ty = sig.args[0] + masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[0] + ) + masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( + context, builder, value=args[1] + ) + result = string_view_count_impl( + context, + builder, + size_type(string_view, string_view), + (masked_sv_str.value, masked_sv_substr.value), + ) + + ret.value = result + ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) + return ret._getvalue() + + @cuda_lower( operator.contains, MaskedType(string_view), MaskedType(string_view) ) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index ce6dbfb4946..cc97ee20555 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -117,6 +117,15 @@ def generic(self, args, kws): ) +class MaskedStringViewCount(AbstractTemplate): + key = "MaskedType.count" + + def generic(self, args, kws): + return nb_signature( + MaskedType(size_type), MaskedType(string_view), recvr=self.this + ) + + class MaskedStringViewIsAlnum(AbstractTemplate): key = "MaskedType.isalnum" @@ -190,6 +199,11 @@ def resolve_rfind(self, mod): MaskedStringViewRFind, MaskedType(string_view) ) + def resolve_count(self, mod): + return types.BoundFunction( + MaskedStringViewCount, MaskedType(string_view) + ) + def resolve_isalnum(self, mod): return types.BoundFunction( MaskedStringViewIsAlnum, MaskedType(string_view) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 5834cfd23a5..5d5ff97d96c 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -1061,6 +1061,20 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) +@pytest.mark.parametrize( + "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022", "cuda"]}] +) +@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) +def test_string_udf_count(data, substr): + data = cudf.DataFrame(data) + + def func(row): + st = row["str_col"] + return st.count(substr) + + run_masked_udf_test(func, data, check_dtype=False) + + @pytest.mark.parametrize( "data", [[1.0, 0.0, 1.5], [1, 0, 2], [True, False, True]] ) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index b85bc5175a7..70d6650a4c1 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -401,7 +401,7 @@ def call_string_view_count(st, substr): @cuda_lower("StringView.count", string_view, string_view) -def string_view_coount_impl(context, builder, sig, args): +def string_view_count_impl(context, builder, sig, args): sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( args[1].type ) From 795815051a81558405aace599de96d5f968257c6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 7 Sep 2022 09:13:18 -0700 Subject: [PATCH 105/212] move .clang-format to repo root --- cpp/.clang-format => .clang-format | 0 python/strings_udf/cpp/.clang-format | 155 --------------------------- 2 files changed, 155 deletions(-) rename cpp/.clang-format => .clang-format (100%) delete mode 100644 python/strings_udf/cpp/.clang-format diff --git a/cpp/.clang-format b/.clang-format similarity index 100% rename from cpp/.clang-format rename to .clang-format diff --git a/python/strings_udf/cpp/.clang-format b/python/strings_udf/cpp/.clang-format deleted file mode 100644 index 6019a6f3d5c..00000000000 --- a/python/strings_udf/cpp/.clang-format +++ /dev/null @@ -1,155 +0,0 @@ ---- -# Refer to the following link for the explanation of each params: -# http://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html -Language: Cpp -# BasedOnStyle: Google -AccessModifierOffset: -1 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: true -AlignConsecutiveBitFields: true -AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: true -AlignEscapedNewlines: Left -AlignOperands: true -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: true -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: true -AllowShortCaseLabelsOnASingleLine: true -AllowShortEnumsOnASingleLine: true -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: true -AllowShortLambdasOnASingleLine: true -AllowShortLoopsOnASingleLine: false -# This is deprecated -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: false - BeforeElse: false - IndentBraces: false - # disabling the below splits, else, they'll just add to the vertical length of source files! - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakAfterJavaFieldAnnotations: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: WebKit -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon -BreakStringLiterals: true -ColumnLimit: 100 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true -# Kept the below 2 to be the same as `IndentWidth` to keep everything uniform -ConstructorInitializerIndentWidth: 2 -ContinuationIndentWidth: 2 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IncludeBlocks: Preserve -IncludeIsMainRegex: '([-_](test|unittest))?$' -IndentCaseLabels: true -IndentPPDirectives: None -IndentWidth: 2 -IndentWrappedFunctionNames: false -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Never -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 1 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Left -RawStringFormats: - - Language: Cpp - Delimiters: - - cc - - CC - - cpp - - Cpp - - CPP - - 'c++' - - 'C++' - CanonicalDelimiter: '' - - Language: TextProto - Delimiters: - - pb - - PB - - proto - - PROTO - EnclosingFunctions: - - EqualsProto - - EquivToProto - - PARSE_PARTIAL_TEXT_PROTO - - PARSE_TEST_PROTO - - PARSE_TEXT_PROTO - - ParseTextOrDie - - ParseTextProtoOrDie - CanonicalDelimiter: '' - BasedOnStyle: google -# Enabling comment reflow causes doxygen comments to be messed up in their formats! -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInConditionalStatement: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: c++17 -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -# Be consistent with indent-width, even for people who use tab for indentation! -TabWidth: 2 -UseTab: Never From 1183e8c3ffdf2cfefa095a7e3db1f409248e2bd2 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 7 Sep 2022 09:53:56 -0700 Subject: [PATCH 106/212] search for cuda version using re --- python/strings_udf/strings_udf/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index f9f1d78efcc..f7729e4ad02 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,9 +1,9 @@ # Copyright (c) 2022, NVIDIA CORPORATION. from ptxcompiler.patch import patch_needed, CMD import os -import warnings import sys import subprocess +import re def versions_compatible(path): @@ -18,7 +18,11 @@ def versions_compatible(path): """ # obtain the cuda version used to compile this PTX file file = open(path).read() - major, minor = file.split("\n")[4].split(" ")[-2][:-1].split(".") + major, minor = ( + re.search("Cuda compilation tools, release ([0-9\.]+)", f) + .group(1) + .split(".") + ) # adapted from patch_needed() cp = subprocess.run([sys.executable, "-c", CMD], capture_output=True) @@ -34,7 +38,6 @@ def versions_compatible(path): ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" ENABLED = versions_compatible(ptxpath) -warnings.warn(f"String UDFs are enabled: {ENABLED}") from . import _version From 6e152ff1cba63eb327942f1b4dfbfc8fd9e1e01d Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Thu, 8 Sep 2022 08:18:33 -0500 Subject: [PATCH 107/212] Apply suggestions from code review Co-authored-by: Bradley Dice --- python/cudf/cudf/core/udf/masked_typing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/masked_typing.py b/python/cudf/cudf/core/udf/masked_typing.py index 4a990e27466..a815a9f6dae 100644 --- a/python/cudf/cudf/core/udf/masked_typing.py +++ b/python/cudf/cudf/core/udf/masked_typing.py @@ -78,7 +78,7 @@ def _type_to_masked_type(t): MASKED_INIT_MAP[types.pyobject] = types.Poison( _format_error_string( "strings_udf library required for usage of string dtypes " - "inside user defined functions. Try conda install strings_udf." + "inside user defined functions." ) ) From 66cbc3d92dd9a2661d5153e10666b12c228a16e5 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Thu, 8 Sep 2022 06:53:19 -0700 Subject: [PATCH 108/212] address reviews --- ci/release/update-version.sh | 3 + python/cudf/cudf/core/udf/utils.py | 14 -- python/cudf/cudf/tests/test_udf_masked_ops.py | 217 ++++-------------- python/strings_udf/strings_udf/__init__.py | 2 +- .../strings_udf/tests/test_string_udfs.py | 139 ++++------- 5 files changed, 89 insertions(+), 286 deletions(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 34783a414bd..96f2eb7935d 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -37,6 +37,9 @@ sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' # Python update sed_runner 's/'"cudf_version .*)"'/'"cudf_version ${NEXT_FULL_TAG})"'/g' python/cudf/CMakeLists.txt +# strings_udf update +sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/strings_udf/cpp/CMakeLists.txt + # cpp libcudf_kafka update sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' cpp/libcudf_kafka/CMakeLists.txt diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 3c0724343c1..7ff24f2476e 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -238,20 +238,6 @@ def _get_kernel(kernel_string, globals_, sig, func): launch_arg_getters: Dict[Any, Any] = {} -def _launch_arg_from_col(col): - getter = launch_arg_getters.get(col.dtype) - if getter: - data = getter(col) - else: - data = col.data - - mask = col.mask - if mask is None: - return data - else: - return data, mask - - def _get_input_args_from_frame(fr): args = [] offsets = [] diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index 5d5ff97d96c..da3e5cd3733 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -31,6 +31,30 @@ def string_udf_test(f): return pytest.mark.skip(reason="String UDFs not enabled")(f) +string_data = [ + "abc", + "ABC", + "AbC", + "123", + "123aBc", + "123@.!", + "", + "rapids ai", + "gpu", + "True", + "False", + "1.234", + ".123a", + "0.013", + "1.0", + "01", + "20010101", + "cudf", + "cuda", + "gpu", +] + + def run_masked_udf_test(func, data, args=(), **kwargs): gdf = data pdf = data.to_pandas(nullable=True) @@ -691,11 +715,8 @@ def f(x): @string_udf_test -@pytest.mark.parametrize( - "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022"]}] -) +@pytest.mark.parametrize("data", [{"str_col": string_data}]) def test_string_udf_len(data): - # tests the `len` function in string udfs data = cudf.DataFrame(data) def func(row): @@ -706,12 +727,10 @@ def func(row): @string_udf_test -@pytest.mark.parametrize( - "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022", "cuDF"]}] -) +@pytest.mark.parametrize("data", [{"str_col": string_data}]) @pytest.mark.parametrize("substr", ["a", "cu", "2"]) def test_string_udf_startswith(data, substr): - # tests the `startswith` method of strings + data = cudf.DataFrame(data) def func(row): @@ -724,23 +743,10 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "gpu", - "2022", - "cuDF", - "again_gpu", - ] - } - ], + [{"str_col": string_data}], ) @pytest.mark.parametrize("substr", ["a", "gpu", "2"]) def test_string_udf_endswith(data, substr): - # tests the `endswith` method of strings data = cudf.DataFrame(data) def func(row): @@ -753,23 +759,10 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "gpu", - "2022", - "cuDF", - "again_gpu", - ] - } - ], + [{"str_col": string_data}], ) @pytest.mark.parametrize("substr", ["u", "gpu", "a"]) def test_string_udf_find(data, substr): - # tests the `find` method of strings data = cudf.DataFrame(data) def func(row): @@ -782,23 +775,10 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "gpu", - "2022", - "cuDF", - "again_gpu", - ] - } - ], + [{"str_col": string_data}], ) @pytest.mark.parametrize("substr", ["u", "gpu", "a"]) def test_string_udf_rfind(data, substr): - # tests the `find` method of strings data = cudf.DataFrame(data) def func(row): @@ -811,23 +791,10 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "gpu", - "2022", - "cuDF", - "again_gpu", - ] - } - ], + [{"str_col": string_data}], ) @pytest.mark.parametrize("substr", ["a", "cu", "", "12"]) def test_string_udf_contains(data, substr): - # tests the boolean operation `substr in str` data = cudf.DataFrame(data) def func(row): @@ -840,19 +807,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "gpu", - "2022", - "cuDF", - "again_gpu", - ] - } - ], + [{"str_col": string_data}], ) @pytest.mark.parametrize("other", ["cudf", "123", "", " "]) @pytest.mark.parametrize("cmpop", comparison_ops) @@ -869,19 +824,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "gpu", - "2022", - "cuDF", - "again_gpu", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_isalnum(data): data = cudf.DataFrame(data) @@ -896,19 +839,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "", - " ", - "12 ab", - "@2a", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_isalpha(data): data = cudf.DataFrame(data) @@ -923,19 +854,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "123", - "", - " ", - "12 ab", - "@2a", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_isdigit(data): data = cudf.DataFrame(data) @@ -950,22 +869,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "", - " ", - "12 ab", - "@2a", - "12.34", - "0.123", - ".123" ".12abc", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_isdecimal(data): data = cudf.DataFrame(data) @@ -980,21 +884,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "", - "rApIdS", - "12 ab", - "@2a", - "12.34", - "ABC DEF", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_isupper(data): data = cudf.DataFrame(data) @@ -1009,21 +899,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "rapids", - "AI", - "", - "rApIdS", - "12 ab", - "@2a", - "12.34", - "abc def", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_islower(data): data = cudf.DataFrame(data) @@ -1038,18 +914,7 @@ def func(row): @string_udf_test @pytest.mark.parametrize( "data", - [ - { - "str_col": [ - "cudf", - "", - " ", - " 123 ", - "2022 2222", - "cuDF", - ] - } - ], + [{"str_col": string_data}], ) def test_string_udf_isspace(data): data = cudf.DataFrame(data) @@ -1061,9 +926,7 @@ def func(row): run_masked_udf_test(func, data, check_dtype=False) -@pytest.mark.parametrize( - "data", [{"str_col": ["cudf", "rapids", "AI", "gpu", "2022", "cuda"]}] -) +@pytest.mark.parametrize("data", [{"str_col": string_data}]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(data, substr): data = cudf.DataFrame(data) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index f7729e4ad02..087be552df8 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -19,7 +19,7 @@ def versions_compatible(path): # obtain the cuda version used to compile this PTX file file = open(path).read() major, minor = ( - re.search("Cuda compilation tools, release ([0-9\.]+)", f) + re.search("Cuda compilation tools, release ([0-9\.]+)", file) .group(1) .split(".") ) diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index a67da7f5831..532c82449bf 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -4,253 +4,204 @@ from .utils import run_udf_test - -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +string_data = [ + "abc", + "ABC", + "AbC", + "123", + "123aBc", + "123@.!", + "", + "rapids ai", + "gpu", + "True", + "False", + "1.234", + ".123a", + "0.013", + "1.0", + "01", + "20010101", + "cudf", + "cuda", + "gpu", +] + + +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_eq(data, rhs): - # tests the `==` operator in string udfs - def func(st): return st == rhs run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ne(data, rhs): - # tests the `!=` operator in string udfs - def func(st): return st != rhs run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ge(data, rhs): - # tests the `>=` operator in string udfs - def func(st): return st >= rhs run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_le(data, rhs): - # tests the `<=` operator in string udfs - def func(st): return st <= rhs run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_gt(data, rhs): - # tests the `>` operator in string udfs - def func(st): return st > rhs run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_lt(data, rhs): - # tests the `<` operator in string udfs - def func(st): return st < rhs run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) def test_string_udf_contains(data, substr): - # Tests contains for string UDFs - def func(st): return substr in st run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(data, substr): - # tests the `count` function in string udfs - def func(st): return st.count(substr) run_udf_test(data, func, "int32") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_find(data, substr): - # tests the `find` function in string udfs - def func(st): return st.find(substr) run_udf_test(data, func, "int32") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_endswith(data, substr): - # tests the `endswith` function in string udfs - def func(st): return st.endswith(substr) run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["1", "1@2", "123abc", "2.1", "", "0003"]]) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isalnum(data): - # tests the `rfind` function in string udfs - def func(st): return st.isalnum() run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["abc", "1@2", "123abc", "2.1", "@Aa", "ABC"]] -) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isalpha(data): - # tests the `isalpha` function in string udfs - def func(st): return st.isalpha() run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isdecimal(data): - # tests the `isdecimal` function in string udfs - def func(st): return st.isdecimal() run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isdigit(data): - # tests the `isdigit` function in string udfs - def func(st): return st.isdigit() run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["1", "12", "123abc", "2.1", "", "0003", "abc", "b a", "AbC"]] -) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_islower(data): - # tests the `islower` function in string udfs - def func(st): return st.islower() run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["1", "12", "123abc", "2.1", "", "0003"]]) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isnumeric(data): - # tests the `isnumeric` function in string udfs - def func(st): return st.isnumeric() run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["1", " x ", " ", "2.1", "", "0003"]]) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isspace(data): - # tests the `isspace` function in string udfs - def func(st): return st.isspace() run_udf_test(data, func, "bool") -@pytest.mark.parametrize( - "data", [["1", "12", "123abc", "2.1", "", "0003", "ABC", "AbC", " 123ABC"]] -) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isupper(data): - # tests the `isupper` function in string udfs - def func(st): return st.isupper() run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [["cudf", "rapids", "AI", "gpu", "2022"]]) +@pytest.mark.parametrize("data", [string_data]) def test_string_udf_len(data): - # tests the `len` function in string udfs - def func(st): return len(st) run_udf_test(data, func, "int64") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_rfind(data, substr): - # tests the `rfind` function in string udfs - def func(st): return st.rfind(substr) run_udf_test(data, func, "int32") -@pytest.mark.parametrize( - "data", [["cudf", "rapids", "AI", "gpu", "2022", "cuda"]] -) +@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_startswith(data, substr): - # tests the `startswith` function in string udfs - def func(st): return st.startswith(substr) From b99ddd6755af389967d6ce0a4fc1f99bdfa07b30 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Thu, 8 Sep 2022 13:57:02 -0400 Subject: [PATCH 109/212] Update count() logic --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index ab5b2fcf030..072e0795853 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -38,8 +38,8 @@ __device__ inline cudf::size_type count(string_view const source, cudf::size_type end = -1) { auto const tgt_length = target.length(); - if (tgt_length == 0) return 0; auto const src_length = source.length(); + if (tgt_length == 0) return src_length + 1; start = start < 0 ? 0 : start; end = end < 0 || end > src_length ? src_length : end; From 11a35d7dd56c38f360b0749111b25a8af95a2f7d Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Thu, 8 Sep 2022 23:11:58 -0400 Subject: [PATCH 110/212] add more parenthesis Co-authored-by: Vyas Ramasubramani --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index 072e0795853..e2644d2e431 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -42,7 +42,7 @@ __device__ inline cudf::size_type count(string_view const source, if (tgt_length == 0) return src_length + 1; start = start < 0 ? 0 : start; - end = end < 0 || end > src_length ? src_length : end; + end = (end < 0 || end > src_length) ? src_length : end; cudf::size_type count = 0; cudf::size_type pos = start; From 1f78b057f2cd1d85d153a2359b952fc9b25fc23b Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Thu, 8 Sep 2022 23:12:50 -0400 Subject: [PATCH 111/212] remove blank line Co-authored-by: Vyas Ramasubramani --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 1 - 1 file changed, 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index e2644d2e431..1ee6c778b22 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -1,4 +1,3 @@ - /* * Copyright (c) 2022, NVIDIA CORPORATION. * From 0d3f7614618523c7735c51b49b345a5d045d935b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 06:42:05 -0700 Subject: [PATCH 112/212] include install guard in build.sh --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 020acfa3371..5c2d67b3d4f 100755 --- a/build.sh +++ b/build.sh @@ -339,10 +339,11 @@ if buildAll || hasArg strings_udf; then # do not separately expose strings_udf c++ library # always build python and c++ at the same time and include into the same conda package cd ${REPODIR}/python/strings_udf/cpp - ls cmake -S ./ -B build -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ cmake --build build - cmake --install ./build + if [[ ${INSTALL_TARGET} != "" ]]; then + cmake --install build + fi cd ${REPODIR}/python/strings_udf python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} if [[ ${INSTALL_TARGET} != "" ]]; then From c3e174c51efc7c965d8e85f8547c0e32f270d238 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 06:42:48 -0700 Subject: [PATCH 113/212] revert changes to update-version.sh --- ci/release/update-version.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/ci/release/update-version.sh b/ci/release/update-version.sh index 96f2eb7935d..34783a414bd 100755 --- a/ci/release/update-version.sh +++ b/ci/release/update-version.sh @@ -37,9 +37,6 @@ sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' # Python update sed_runner 's/'"cudf_version .*)"'/'"cudf_version ${NEXT_FULL_TAG})"'/g' python/cudf/CMakeLists.txt -# strings_udf update -sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' python/strings_udf/cpp/CMakeLists.txt - # cpp libcudf_kafka update sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' cpp/libcudf_kafka/CMakeLists.txt From 2bca928f1c8ee2f1bff03b5d68f543658cad9315 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 06:43:15 -0700 Subject: [PATCH 114/212] prune meta.yaml --- conda/recipes/strings_udf/meta.yaml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index 4f6c30849a0..0e9d8c56bda 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -33,38 +33,24 @@ requirements: - {{ compiler('cuda') }} {{ cuda_version }} - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - protobuf>=3.20.1,<3.21.0a0 - python - cython >=0.29,<0.30 - scikit-build>=0.13.1 - setuptools - numba >=0.54 - - dlpack>=0.5,<0.6.0a0 - - pyarrow =9 - libcudf ={{ version }} - cudf ={{ version }} - - rmm ={{ minor_version }} - cudatoolkit ={{ cuda_version }} run: - - protobuf>=3.20.1,<3.21.0a0 - python - typing_extensions - - pandas >=1.0,<1.5.0dev0 - - cupy >=9.5.0,<11.0.0a0 - numba >=0.54 - numpy - - {{ pin_compatible('pyarrow', max_pin='x.x.x') }} - libcudf {{ version }} - cudf ={{ version }} - - fastavro >=0.22.0 - - {{ pin_compatible('rmm', max_pin='x.x') }} - - fsspec>=0.6.0 - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - - nvtx >=0.2.1 - - packaging - cachetools - ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler - - cuda-python >=11.5,<11.7.1 test: # [linux64] requires: # [linux64] - cudatoolkit {{ cuda_version }}.* # [linux64] From 35e159e18cda970f5cec9a4f03e4ff78d6297b82 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 06:44:03 -0700 Subject: [PATCH 115/212] delete strings_udf from namespace if not enabled --- python/cudf/cudf/core/udf/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 0b473375f08..af768e829c5 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -54,6 +54,9 @@ row_function.itemsizes[dtype("O")] = string_view.size_bytes _STRING_UDFS_ENABLED = True + else: + del strings_udf + except ImportError: # allow cuDF to work without strings_udf pass From 25c4a7cf4c7be3bc486786da588891894a1a6ebd Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Fri, 9 Sep 2022 08:44:36 -0500 Subject: [PATCH 116/212] Apply suggestions from code review Co-authored-by: Vyas Ramasubramani --- python/cudf/cudf/core/udf/row_function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index db863e8dd38..818cd7a2f1a 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -66,7 +66,7 @@ def _get_frame_row_type(dtype): fields.append((name, infos)) # increment offset by itemsize plus one byte for validity - itemsize = itemsizes.get(elemdtype) or elemdtype.itemsize + itemsize = itemsizes.get(elemdtype, elemdtype.itemsize) offset += itemsize + 1 # Align the next member of the struct to be a multiple of the From 99b7f3b757f884d90bf16893b97ec5109eb77ce6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 08:07:51 -0700 Subject: [PATCH 117/212] use a decorator to create lowerings dynamically --- python/strings_udf/strings_udf/lowering.py | 545 +++++---------------- 1 file changed, 127 insertions(+), 418 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 70d6650a4c1..ca8eae323cf 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -17,6 +17,14 @@ character_flags_table_ptr = get_character_flags_table_ptr() +# read-only functions +# We will provide only one overload for this set of functions, which will +# expect a string_view. When a literal is encountered, numba will promote it to +# a string_view whereas when a dstring is encountered, numba will convert it to +# a view via its native view() method. + + +# CUDA function declarations _string_view_len = cuda.declare_device( "len", size_type(types.CPointer(string_view)) ) @@ -26,7 +34,6 @@ types.boolean(types.CPointer(string_view), types.CPointer(string_view)), ) - _string_view_eq = cuda.declare_device( "eq", types.boolean(types.CPointer(string_view), types.CPointer(string_view)), @@ -114,6 +121,28 @@ ) +# casts +@cuda_lowering_registry.lower_cast(types.StringLiteral, string_view) +def cast_string_literal_to_string_view(context, builder, fromty, toty, val): + """ + Cast a literal to a string_view + """ + # create an empty string_view + sv = cgutils.create_struct_proxy(string_view)(context, builder) + + # set the empty strview data pointer to point to the literal value + s = context.insert_const_string(builder.module, fromty.literal_value) + sv.data = context.insert_addrspace_conv( + builder, s, nvvm.ADDRSPACE_CONSTANT + ) + sv.length = context.get_constant(size_type, len(fromty.literal_value)) + sv.bytes = context.get_constant( + size_type, len(fromty.literal_value.encode("UTF-8")) + ) + + return sv._getvalue() + + # String function implementations def call_len_string_view(st): return _string_view_len(st) @@ -133,505 +162,185 @@ def string_view_len_impl(context, builder, sig, args): return result -def call_string_view_contains(st, substr): - return _string_view_contains(st, substr) - - -@cuda_lower(operator.contains, string_view, string_view) -def string_view_contains_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - substr_ptr = builder.alloca(args[1].type) - - builder.store(args[0], sv_ptr) - builder.store(args[1], substr_ptr) - result = context.compile_internal( - builder, - call_string_view_contains, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, substr_ptr), - ) +def create_binary_string_func(binary_func, signature): + def deco(cuda_func): + @cuda_lower(binary_func, string_view, string_view) + def binary_func_impl(context, builder, sig, args): + lhs_ptr = builder.alloca(args[0].type) + rhs_ptr = builder.alloca(args[1].type) - return result + builder.store(args[0], lhs_ptr) + builder.store(args[1], rhs_ptr) + result = context.compile_internal( + builder, + cuda_func, + nb_signature(*signature), + (lhs_ptr, rhs_ptr), + ) + return result -def call_string_view_eq(st, rhs): - return _string_view_eq(st, rhs) + return binary_func_impl + return deco -@cuda_lower(operator.eq, string_view, string_view) -def string_view_eq_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - rhs_ptr = builder.alloca(args[1].type) - builder.store(args[0], sv_ptr) - builder.store(args[1], rhs_ptr) +@create_binary_string_func( + operator.contains, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) +def call_string_view_contains(st, substr): + return _string_view_contains(st, substr) - result = context.compile_internal( - builder, - call_string_view_eq, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, rhs_ptr), - ) - return result +@create_binary_string_func( + operator.eq, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) +def call_string_view_eq(st, rhs): + return _string_view_eq(st, rhs) +@create_binary_string_func( + operator.ne, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_ne(st, rhs): return _string_view_ne(st, rhs) -@cuda_lower(operator.ne, string_view, string_view) -def string_view_ne_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - rhs_ptr = builder.alloca(args[1].type) - - builder.store(args[0], sv_ptr) - builder.store(args[1], rhs_ptr) - - result = context.compile_internal( - builder, - call_string_view_ne, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, rhs_ptr), - ) - - return result - - +@create_binary_string_func( + operator.ge, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_ge(st, rhs): return _string_view_ge(st, rhs) -@cuda_lower(operator.ge, string_view, string_view) -def string_view_ge_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - rhs_ptr = builder.alloca(args[1].type) - - builder.store(args[0], sv_ptr) - builder.store(args[1], rhs_ptr) - - result = context.compile_internal( - builder, - call_string_view_ge, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, rhs_ptr), - ) - - return result - - +@create_binary_string_func( + operator.le, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_le(st, rhs): return _string_view_le(st, rhs) -@cuda_lower(operator.le, string_view, string_view) -def string_view_le_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - rhs_ptr = builder.alloca(args[1].type) - - builder.store(args[0], sv_ptr) - builder.store(args[1], rhs_ptr) - - result = context.compile_internal( - builder, - call_string_view_le, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, rhs_ptr), - ) - - return result - - +@create_binary_string_func( + operator.gt, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_gt(st, rhs): return _string_view_gt(st, rhs) -@cuda_lower(operator.gt, string_view, string_view) -def string_view_gt_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - rhs_ptr = builder.alloca(args[1].type) - - builder.store(args[0], sv_ptr) - builder.store(args[1], rhs_ptr) - - result = context.compile_internal( - builder, - call_string_view_gt, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, rhs_ptr), - ) - - return result - - +@create_binary_string_func( + operator.lt, + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_lt(st, rhs): return _string_view_lt(st, rhs) -@cuda_lower(operator.lt, string_view, string_view) -def string_view_lt_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - rhs_ptr = builder.alloca(args[1].type) - - builder.store(args[0], sv_ptr) - builder.store(args[1], rhs_ptr) - - result = context.compile_internal( - builder, - call_string_view_lt, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, rhs_ptr), - ) - - return result - - -# read-only functions -# We will provide only one overload for this set of functions, which will -# expect a string_view. When a literal is encountered, numba will promote it to -# a string_view whereas when a dstring is encountered, numba will convert it to -# a view via its native view() method. - -# casts -@cuda_lowering_registry.lower_cast(types.StringLiteral, string_view) -def cast_string_literal_to_string_view(context, builder, fromty, toty, val): - """ - Cast a literal to a string_view - """ - # create an empty string_view - sv = cgutils.create_struct_proxy(string_view)(context, builder) - - # set the empty strview data pointer to point to the literal value - s = context.insert_const_string(builder.module, fromty.literal_value) - sv.data = context.insert_addrspace_conv( - builder, s, nvvm.ADDRSPACE_CONSTANT - ) - sv.length = context.get_constant(size_type, len(fromty.literal_value)) - sv.bytes = context.get_constant( - size_type, len(fromty.literal_value.encode("UTF-8")) - ) - - return sv._getvalue() - - +@create_binary_string_func( + "StringView.startswith", + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_startswith(sv, substr): return _string_view_startswith(sv, substr) -@cuda_lower("StringView.startswith", string_view, string_view) -def string_view_startswith_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( - args[1].type - ) - - builder.store(args[0], sv_ptr) - builder.store(args[1], substr_ptr) - - result = context.compile_internal( - builder, - call_string_view_startswith, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, substr_ptr), - ) - - return result - - +@create_binary_string_func( + "StringView.endswith", + (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_endswith(sv, substr): return _string_view_endswith(sv, substr) -@cuda_lower("StringView.endswith", string_view, string_view) -def string_view_endswith_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( - args[1].type - ) - - builder.store(args[0], sv_ptr) - builder.store(args[1], substr_ptr) - - result = context.compile_internal( - builder, - call_string_view_endswith, - nb_signature( - types.boolean, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, substr_ptr), - ) - - return result - - +@create_binary_string_func( + "StringView.count", + (size_type, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_count(st, substr): return _string_view_count(st, substr) -@cuda_lower("StringView.count", string_view, string_view) -def string_view_count_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( - args[1].type - ) - - builder.store(args[0], sv_ptr) - builder.store(args[1], substr_ptr) - - result = context.compile_internal( - builder, - call_string_view_count, - nb_signature( - size_type, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, substr_ptr), - ) - - return result - - +@create_binary_string_func( + "StringView.find", + (size_type, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_find(sv, substr): return _string_view_find(sv, substr) -@cuda_lower("StringView.find", string_view, string_view) -def string_view_find_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( - args[1].type - ) - - builder.store(args[0], sv_ptr) - builder.store(args[1], substr_ptr) - - result = context.compile_internal( - builder, - call_string_view_find, - nb_signature( - size_type, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, substr_ptr), - ) - - return result - - +@create_binary_string_func( + "StringView.rfind", + (size_type, types.CPointer(string_view), types.CPointer(string_view)), +) def call_string_view_rfind(sv, substr): return _string_view_rfind(sv, substr) -@cuda_lower("StringView.rfind", string_view, string_view) -def string_view_rfind_impl(context, builder, sig, args): - sv_ptr, substr_ptr = builder.alloca(args[0].type), builder.alloca( - args[1].type - ) +def create_unary_identifier_func(id_func): + def deco(cuda_func): + @cuda_lower(id_func, string_view) + def id_func_impl(context, builder, sig, args): + str_ptr = builder.alloca(args[0].type) + builder.store(args[0], str_ptr) + tbl_ptr = context.get_constant( + types.int64, character_flags_table_ptr + ) + result = context.compile_internal( + builder, + cuda_func, + nb_signature( + types.boolean, types.CPointer(string_view), types.int64 + ), + (str_ptr, tbl_ptr), + ) - builder.store(args[0], sv_ptr) - builder.store(args[1], substr_ptr) + return result - result = context.compile_internal( - builder, - call_string_view_rfind, - nb_signature( - size_type, - types.CPointer(string_view), - types.CPointer(string_view), - ), - (sv_ptr, substr_ptr), - ) + return id_func_impl - return result + return deco +@create_unary_identifier_func("StringView.isdigit") def call_string_view_isdigit(st, tbl): return _string_view_isdigit(st, tbl) -@cuda_lower("StringView.isdigit", string_view) -def string_view_isdigit_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isdigit, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.isalnum") def call_string_view_isalnum(st, tbl): return _string_view_isalnum(st, tbl) -@cuda_lower("StringView.isalnum", string_view) -def string_view_isalnum_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isalnum, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.isalpha") def call_string_view_isalpha(st, tbl): return _string_view_isalpha(st, tbl) -@cuda_lower("StringView.isalpha", string_view) -def string_view_isalpha_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isalpha, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.isnumeric") def call_string_view_isnumeric(st, tbl): return _string_view_isnumeric(st, tbl) -@cuda_lower("StringView.isnumeric", string_view) -def string_view_isnumeric_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isnumeric, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.isdecimal") def call_string_view_isdecimal(st, tbl): return _string_view_isdecimal(st, tbl) -@cuda_lower("StringView.isdecimal", string_view) -def string_view_isdecimal_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isdecimal, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.isspace") def call_string_view_isspace(st, tbl): return _string_view_isspace(st, tbl) -@cuda_lower("StringView.isspace", string_view) -def string_view_isspace_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isspace, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.isupper") def call_string_view_isupper(st, tbl): return _string_view_isupper(st, tbl) -@cuda_lower("StringView.isupper", string_view) -def string_view_isupper_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_isupper, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result - - +@create_unary_identifier_func("StringView.islower") def call_string_view_islower(st, tbl): return _string_view_islower(st, tbl) - - -@cuda_lower("StringView.islower", string_view) -def string_view_islower_impl(context, builder, sig, args): - sv_ptr = builder.alloca(args[0].type) - builder.store(args[0], sv_ptr) - tbl_ptr = context.get_constant(types.int64, character_flags_table_ptr) - - result = context.compile_internal( - builder, - call_string_view_islower, - nb_signature(types.boolean, types.CPointer(string_view), types.int64), - (sv_ptr, tbl_ptr), - ) - - return result From c44c575ad7510ec3aa8c9286eb73d8eaf0e8565f Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 08:54:07 -0700 Subject: [PATCH 118/212] dynamically generate typing --- python/strings_udf/strings_udf/_typing.py | 251 ++++++---------------- 1 file changed, 65 insertions(+), 186 deletions(-) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index ee8bef6d21a..e5841621a5d 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -118,191 +118,44 @@ def generic(self, args, kws): return nb_signature(size_type, args[0]) -@cuda_decl_registry.register_global(operator.contains) -class StringViewContains(AbstractTemplate): - """ - Return True if a string view contains a substring view - """ - - def generic(self, args, kws): - if isinstance(args[0], any_string_ty) and isinstance( - args[1], any_string_ty - ): - return nb_signature(types.boolean, string_view, string_view) - - -@cuda_decl_registry.register_global(operator.eq) -class StringViewEq(AbstractTemplate): - """ - Compare two cudf::string_view with == - """ - - def generic(self, args, kws): - if ( - isinstance(args[0], any_string_ty) - and isinstance(args[1], any_string_ty) - and len(args) == 2 - ): - return nb_signature(types.boolean, string_view, string_view) - - -@cuda_decl_registry.register_global(operator.ne) -class StringViewNe(AbstractTemplate): - """ - Compare two cudf::string_view with != - """ - - def generic(self, args, kws): - if ( - isinstance(args[0], any_string_ty) - and isinstance(args[1], any_string_ty) - and len(args) == 2 - ): - return nb_signature(types.boolean, string_view, string_view) - - -@cuda_decl_registry.register_global(operator.ge) -class StringViewGe(AbstractTemplate): - """ - Compare two cudf::string_view with >= - """ +def register_stringview_binaryop(op, retty): + class StringViewBinaryOp(AbstractTemplate): + def generic(self, args, kws): + if isinstance(args[0], any_string_ty) and isinstance( + args[1], any_string_ty + ): + return nb_signature(retty, string_view, string_view) - def generic(self, args, kws): - if ( - isinstance(args[0], any_string_ty) - and isinstance(args[1], any_string_ty) - and len(args) == 2 - ): - return nb_signature(types.boolean, string_view, string_view) - - -@cuda_decl_registry.register_global(operator.le) -class StringViewLe(AbstractTemplate): - """ - Compare two cudf::string_view with <= - """ - - def generic(self, args, kws): - if ( - isinstance(args[0], any_string_ty) - and isinstance(args[1], any_string_ty) - and len(args) == 2 - ): - return nb_signature(types.boolean, string_view, string_view) - - -@cuda_decl_registry.register_global(operator.gt) -class StringViewGt(AbstractTemplate): - """ - Compare two cudf::string_view with > - """ - - def generic(self, args, kws): - if ( - isinstance(args[0], any_string_ty) - and isinstance(args[1], any_string_ty) - and len(args) == 2 - ): - return nb_signature(types.boolean, string_view, string_view) - - -@cuda_decl_registry.register_global(operator.lt) -class StringViewLt(AbstractTemplate): - """ - Compare two cudf::string_view with < - """ + cuda_decl_registry.register_global(op)(StringViewBinaryOp) - def generic(self, args, kws): - if ( - isinstance(args[0], any_string_ty) - and isinstance(args[1], any_string_ty) - and len(args) == 2 - ): - return nb_signature(types.boolean, string_view, string_view) +register_stringview_binaryop(operator.eq, types.boolean) +register_stringview_binaryop(operator.ne, types.boolean) +register_stringview_binaryop(operator.lt, types.boolean) +register_stringview_binaryop(operator.gt, types.boolean) +register_stringview_binaryop(operator.le, types.boolean) +register_stringview_binaryop(operator.ge, types.boolean) +register_stringview_binaryop(operator.contains, types.boolean) -class StringViewStartsWith(AbstractTemplate): - key = "StringView.startswith" - def generic(self, args, kws): - return nb_signature(types.boolean, string_view, recvr=self.this) +def create_binary_attribute(attrname, retty): + class StringViewBinaryAttr(AbstractTemplate): + key = attrname + def generic(self, args, kws): + return nb_signature(retty, string_view, recvr=self.this) -class StringViewEndsWith(AbstractTemplate): - key = "StringView.endswith" + return StringViewBinaryAttr - def generic(self, args, kws): - return nb_signature(types.boolean, string_view, recvr=self.this) +def create_identifier_attr(attrname): + class StringViewIdentifierAttr(AbstractTemplate): + key = attrname -class StringViewFind(AbstractTemplate): - key = "StringView.find" + def generic(self, args, kws): + return nb_signature(types.boolean, recvr=self.this) - def generic(self, args, kws): - return nb_signature(size_type, string_view, recvr=self.this) - - -class StringViewRFind(AbstractTemplate): - key = "StringView.rfind" - - def generic(self, args, kws): - return nb_signature(size_type, string_view, recvr=self.this) - - -class StringViewIsAlnum(AbstractTemplate): - key = "StringView.isalnum" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsAlpha(AbstractTemplate): - key = "StringView.isalpha" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsDecimal(AbstractTemplate): - key = "StringView.isdecimal" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsDigit(AbstractTemplate): - key = "StringView.isdigit" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsNumeric(AbstractTemplate): - key = "StringView.isnumeric" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsUpper(AbstractTemplate): - key = "StringView.isupper" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsLower(AbstractTemplate): - key = "StringView.islower" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) - - -class StringViewIsSpace(AbstractTemplate): - key = "StringView.isspace" - - def generic(self, args, kws): - return nb_signature(types.boolean, recvr=self.this) + return StringViewIdentifierAttr class StringViewCount(AbstractTemplate): @@ -317,40 +170,66 @@ class StringViewAttrs(AttributeTemplate): key = string_view def resolve_startswith(self, mod): - return types.BoundFunction(StringViewStartsWith, string_view) + return types.BoundFunction( + create_binary_attribute("StringView.startswith", types.boolean), + string_view, + ) def resolve_endswith(self, mod): - return types.BoundFunction(StringViewEndsWith, string_view) + return types.BoundFunction( + create_binary_attribute("StringView.endswith", types.boolean), + string_view, + ) def resolve_find(self, mod): - return types.BoundFunction(StringViewFind, string_view) + return types.BoundFunction( + create_binary_attribute("StringView.find", size_type), string_view + ) def resolve_rfind(self, mod): - return types.BoundFunction(StringViewRFind, string_view) + return types.BoundFunction( + create_binary_attribute("StringView.rfind", size_type), string_view + ) def resolve_isalnum(self, mod): - return types.BoundFunction(StringViewIsAlnum, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isalnum"), string_view + ) def resolve_isalpha(self, mod): - return types.BoundFunction(StringViewIsAlpha, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isalpha"), string_view + ) def resolve_isdecimal(self, mod): - return types.BoundFunction(StringViewIsDecimal, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isdecimal"), string_view + ) def resolve_isdigit(self, mod): - return types.BoundFunction(StringViewIsDigit, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isdigit"), string_view + ) def resolve_isnumeric(self, mod): - return types.BoundFunction(StringViewIsNumeric, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isnumeric"), string_view + ) def resolve_islower(self, mod): - return types.BoundFunction(StringViewIsLower, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.islower"), string_view + ) def resolve_isupper(self, mod): - return types.BoundFunction(StringViewIsUpper, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isupper"), string_view + ) def resolve_isspace(self, mod): - return types.BoundFunction(StringViewIsSpace, string_view) + return types.BoundFunction( + create_identifier_attr("StringView.isspace"), string_view + ) def resolve_count(self, mod): return types.BoundFunction(StringViewCount, string_view) From cf118e910705f72a230718913cb4269e9c705aed Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 08:55:14 -0700 Subject: [PATCH 119/212] renaming --- python/strings_udf/strings_udf/_typing.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index e5841621a5d..73b9580863f 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -138,7 +138,7 @@ def generic(self, args, kws): register_stringview_binaryop(operator.contains, types.boolean) -def create_binary_attribute(attrname, retty): +def create_binary_attr(attrname, retty): class StringViewBinaryAttr(AbstractTemplate): key = attrname @@ -171,24 +171,24 @@ class StringViewAttrs(AttributeTemplate): def resolve_startswith(self, mod): return types.BoundFunction( - create_binary_attribute("StringView.startswith", types.boolean), + create_binary_attr("StringView.startswith", types.boolean), string_view, ) def resolve_endswith(self, mod): return types.BoundFunction( - create_binary_attribute("StringView.endswith", types.boolean), + create_binary_attr("StringView.endswith", types.boolean), string_view, ) def resolve_find(self, mod): return types.BoundFunction( - create_binary_attribute("StringView.find", size_type), string_view + create_binary_attr("StringView.find", size_type), string_view ) def resolve_rfind(self, mod): return types.BoundFunction( - create_binary_attribute("StringView.rfind", size_type), string_view + create_binary_attr("StringView.rfind", size_type), string_view ) def resolve_isalnum(self, mod): From 54a00132c4b663086055ff1ebd9724b4f7e37859 Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Fri, 9 Sep 2022 11:01:49 -0500 Subject: [PATCH 120/212] Update python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx Co-authored-by: Vyas Ramasubramani --- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 1c6f254afc3..75224d036b6 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -20,6 +20,6 @@ def to_string_view_array(Column strings_col): with nogil: c_buffer = move(cpp_to_string_view_array(input_view)) - buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) - buffer = Buffer(buffer) + device_buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) + buffer = Buffer(device_buffer) return buffer From c3f19688cd8e5e417c1b293b96dcd6627f1e8541 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 09:01:55 -0700 Subject: [PATCH 121/212] clean tables.pyx --- python/strings_udf/strings_udf/_lib/tables.pyx | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/tables.pyx b/python/strings_udf/strings_udf/_lib/tables.pyx index b24aa19155d..5443364a4a7 100644 --- a/python/strings_udf/strings_udf/_lib/tables.pyx +++ b/python/strings_udf/strings_udf/_lib/tables.pyx @@ -1,7 +1,4 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -# -# distutils: language = c++ -# cython: c_string_type=unicode, c_string_encoding=utf8 from libc.stdint cimport uint8_t, uintptr_t From 2dc437bbdd60b54d4f81734c8445bdb8e8365c6e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 09:10:07 -0700 Subject: [PATCH 122/212] relink imports from strings_udf library --- python/strings_udf/strings_udf/lowering.py | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index ca8eae323cf..ac7ce269dde 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -189,7 +189,7 @@ def binary_func_impl(context, builder, sig, args): operator.contains, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_contains(st, substr): +def string_view_contains_impl(st, substr): return _string_view_contains(st, substr) @@ -197,7 +197,7 @@ def call_string_view_contains(st, substr): operator.eq, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_eq(st, rhs): +def string_view_eq_impl(st, rhs): return _string_view_eq(st, rhs) @@ -205,7 +205,7 @@ def call_string_view_eq(st, rhs): operator.ne, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_ne(st, rhs): +def string_view_ne_impl(st, rhs): return _string_view_ne(st, rhs) @@ -213,7 +213,7 @@ def call_string_view_ne(st, rhs): operator.ge, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_ge(st, rhs): +def string_view_ge_impl(st, rhs): return _string_view_ge(st, rhs) @@ -221,7 +221,7 @@ def call_string_view_ge(st, rhs): operator.le, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_le(st, rhs): +def string_view_le_impl(st, rhs): return _string_view_le(st, rhs) @@ -229,7 +229,7 @@ def call_string_view_le(st, rhs): operator.gt, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_gt(st, rhs): +def string_view_gt_impl(st, rhs): return _string_view_gt(st, rhs) @@ -237,7 +237,7 @@ def call_string_view_gt(st, rhs): operator.lt, (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_lt(st, rhs): +def string_view_lt_impl(st, rhs): return _string_view_lt(st, rhs) @@ -245,7 +245,7 @@ def call_string_view_lt(st, rhs): "StringView.startswith", (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_startswith(sv, substr): +def string_view_startswith_impl(sv, substr): return _string_view_startswith(sv, substr) @@ -253,7 +253,7 @@ def call_string_view_startswith(sv, substr): "StringView.endswith", (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_endswith(sv, substr): +def string_view_endswith_impl(sv, substr): return _string_view_endswith(sv, substr) @@ -261,7 +261,7 @@ def call_string_view_endswith(sv, substr): "StringView.count", (size_type, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_count(st, substr): +def string_view_count_impl(st, substr): return _string_view_count(st, substr) @@ -269,7 +269,7 @@ def call_string_view_count(st, substr): "StringView.find", (size_type, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_find(sv, substr): +def string_view_find_impl(sv, substr): return _string_view_find(sv, substr) @@ -277,7 +277,7 @@ def call_string_view_find(sv, substr): "StringView.rfind", (size_type, types.CPointer(string_view), types.CPointer(string_view)), ) -def call_string_view_rfind(sv, substr): +def string_view_rfind_impl(sv, substr): return _string_view_rfind(sv, substr) @@ -307,40 +307,40 @@ def id_func_impl(context, builder, sig, args): @create_unary_identifier_func("StringView.isdigit") -def call_string_view_isdigit(st, tbl): +def string_view_isdigit_impl(st, tbl): return _string_view_isdigit(st, tbl) @create_unary_identifier_func("StringView.isalnum") -def call_string_view_isalnum(st, tbl): +def string_view_isalnum_impl(st, tbl): return _string_view_isalnum(st, tbl) @create_unary_identifier_func("StringView.isalpha") -def call_string_view_isalpha(st, tbl): +def string_view_isalpha_impl(st, tbl): return _string_view_isalpha(st, tbl) @create_unary_identifier_func("StringView.isnumeric") -def call_string_view_isnumeric(st, tbl): +def string_view_isnumeric_impl(st, tbl): return _string_view_isnumeric(st, tbl) @create_unary_identifier_func("StringView.isdecimal") -def call_string_view_isdecimal(st, tbl): +def string_view_isdecimal_impl(st, tbl): return _string_view_isdecimal(st, tbl) @create_unary_identifier_func("StringView.isspace") -def call_string_view_isspace(st, tbl): +def string_view_isspace_impl(st, tbl): return _string_view_isspace(st, tbl) @create_unary_identifier_func("StringView.isupper") -def call_string_view_isupper(st, tbl): +def string_view_isupper_impl(st, tbl): return _string_view_isupper(st, tbl) @create_unary_identifier_func("StringView.islower") -def call_string_view_islower(st, tbl): +def string_view_islower_impl(st, tbl): return _string_view_islower(st, tbl) From a64a745f8cf20b24c6c75ec8f1ee427e40f80e1b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 09:34:33 -0700 Subject: [PATCH 123/212] dynamically generate attributes of MaskedType(string_view) --- python/cudf/cudf/core/udf/strings_typing.py | 132 ++++++-------------- 1 file changed, 40 insertions(+), 92 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index cc97ee20555..9b5647bd133 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -69,6 +69,10 @@ def generic(self, args, kws): ) +for op in comparison_ops: + cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) + + @cuda_decl_registry.register_global(len) class StringLiteralLength(AbstractTemplate): """ @@ -81,40 +85,26 @@ def generic(self, args, kws): return nb_signature(size_type, args[0]) -class MaskedStringViewStartsWith(AbstractTemplate): - key = "MaskedType.startswith" - - def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), MaskedType(string_view), recvr=self.this - ) - - -class MaskedStringViewEndsWith(AbstractTemplate): - key = "MaskedType.endswith" - - def generic(self, args, kws): - return nb_signature( - MaskedType(types.boolean), MaskedType(string_view), recvr=self.this - ) +def create_masked_binary_attr(attrname, retty): + class MaskedStringViewBinaryAttr(AbstractTemplate): + key = attrname + def generic(self, args, kws): + return nb_signature( + MaskedType(retty), MaskedType(string_view), recvr=self.this + ) -class MaskedStringViewFind(AbstractTemplate): - key = "MaskedType.find" + return MaskedStringViewBinaryAttr - def generic(self, args, kws): - return nb_signature( - MaskedType(size_type), MaskedType(string_view), recvr=self.this - ) +def create_masked_identifier_attr(attrname): + class MaskedStringViewIdentifierAttr(AbstractTemplate): + key = attrname -class MaskedStringViewRFind(AbstractTemplate): - key = "MaskedType.rfind" + def generic(self, args, kws): + return nb_signature(MaskedType(types.boolean), recvr=self.this) - def generic(self, args, kws): - return nb_signature( - MaskedType(size_type), MaskedType(string_view), recvr=self.this - ) + return MaskedStringViewIdentifierAttr class MaskedStringViewCount(AbstractTemplate): @@ -126,77 +116,32 @@ def generic(self, args, kws): ) -class MaskedStringViewIsAlnum(AbstractTemplate): - key = "MaskedType.isalnum" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - -class MaskedStringViewIsAlpha(AbstractTemplate): - key = "MaskedType.isalpha" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - -class MaskedStringViewIsDecimal(AbstractTemplate): - key = "MaskedType.isdecimal" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - -class MaskedStringViewIsDigit(AbstractTemplate): - key = "MaskedType.isdigit" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - -class MaskedStringViewIsLower(AbstractTemplate): - key = "MaskedType.islower" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - -class MaskedStringViewIsUpper(AbstractTemplate): - key = "MaskedType.isupper" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - -class MaskedStringViewIsSpace(AbstractTemplate): - key = "MaskedType.isspace" - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - @cuda_decl_registry.register_attr class MaskedStringViewAttrs(AttributeTemplate): key = MaskedType(string_view) def resolve_startswith(self, mod): return types.BoundFunction( - MaskedStringViewStartsWith, MaskedType(string_view) + create_masked_binary_attr("MaskedType.startswith", types.boolean), + MaskedType(string_view), ) def resolve_endswith(self, mod): return types.BoundFunction( - MaskedStringViewEndsWith, MaskedType(string_view) + create_masked_binary_attr("MaskedType.endswith", types.boolean), + MaskedType(string_view), ) def resolve_find(self, mod): return types.BoundFunction( - MaskedStringViewFind, MaskedType(string_view) + create_masked_binary_attr("MaskedType.find", size_type), + MaskedType(string_view), ) def resolve_rfind(self, mod): return types.BoundFunction( - MaskedStringViewRFind, MaskedType(string_view) + create_masked_binary_attr("MaskedType.rfind", size_type), + MaskedType(string_view), ) def resolve_count(self, mod): @@ -206,37 +151,44 @@ def resolve_count(self, mod): def resolve_isalnum(self, mod): return types.BoundFunction( - MaskedStringViewIsAlnum, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.isalnum"), + MaskedType(string_view), ) def resolve_isalpha(self, mod): return types.BoundFunction( - MaskedStringViewIsAlpha, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.isalpha"), + MaskedType(string_view), ) def resolve_isdecimal(self, mod): return types.BoundFunction( - MaskedStringViewIsDecimal, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.isdecimal"), + MaskedType(string_view), ) def resolve_isdigit(self, mod): return types.BoundFunction( - MaskedStringViewIsDigit, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.isdigit"), + MaskedType(string_view), ) def resolve_islower(self, mod): return types.BoundFunction( - MaskedStringViewIsLower, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.islower"), + MaskedType(string_view), ) def resolve_isupper(self, mod): return types.BoundFunction( - MaskedStringViewIsUpper, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.isupper"), + MaskedType(string_view), ) def resolve_isspace(self, mod): return types.BoundFunction( - MaskedStringViewIsSpace, MaskedType(string_view) + create_masked_identifier_attr("MaskedType.isspace"), + MaskedType(string_view), ) def resolve_value(self, mod): @@ -244,7 +196,3 @@ def resolve_value(self, mod): def resolve_valid(self, mod): return types.boolean - - -for op in comparison_ops: - cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) From 8938f1b648f9e5caed94cbf5b2532a746d18c5c9 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 10:11:43 -0700 Subject: [PATCH 124/212] dynamically generated lowerings for MaskedType(string_view) --- python/cudf/cudf/core/udf/strings_lowering.py | 345 +++++------------- 1 file changed, 85 insertions(+), 260 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index 7ec4c8b6828..e1d8ecee4cb 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -4,6 +4,7 @@ from numba import types from numba.core import cgutils +from numba.core.typing import signature as nb_signature from numba.cuda.cudaimpl import lower as cuda_lower from strings_udf._typing import size_type, string_view @@ -43,285 +44,109 @@ def masked_string_view_len_impl(context, builder, sig, args): return ret._getvalue() -@cuda_lower( - "MaskedType.startswith", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_startswith_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_startswith_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value), - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() +def create_binary_string_func(op, cuda_func, signature): + def masked_binary_func_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + lhs_masked = cgutils.create_struct_proxy(sig.args[0])( + context, builder, value=args[0] + ) + rhs_masked = cgutils.create_struct_proxy(sig.args[0])( + context, builder, value=args[1] + ) -@cuda_lower( - "MaskedType.endswith", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_endswith_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_endswith_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value), - ) + result = cuda_func( + context, + builder, + nb_signature(*signature), + (lhs_masked.value, rhs_masked.value), + ) - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() + ret.value = result + ret.valid = builder.and_(lhs_masked.valid, rhs_masked.valid) + return ret._getvalue() -@cuda_lower( - "MaskedType.find", MaskedType(string_view), MaskedType(string_view) -) -def masked_string_view_find_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] + cuda_lower(op, MaskedType(string_view), MaskedType(string_view))( + masked_binary_func_impl ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_find_impl( - context, - builder, - size_type(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value), - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() -@cuda_lower( - "MaskedType.rfind", MaskedType(string_view), MaskedType(string_view) +create_binary_string_func( + "MaskedType.startswith", + string_view_startswith_impl, + (types.boolean, string_view, string_view), ) -def masked_string_view_rfind_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_rfind_impl( - context, - builder, - size_type(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value), - ) - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - - -@cuda_lower( - "MaskedType.count", MaskedType(string_view), MaskedType(string_view) +create_binary_string_func( + "MaskedType.endswith", + string_view_endswith_impl, + (types.boolean, string_view, string_view), ) -def masked_string_view_count_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_count_impl( - context, - builder, - size_type(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value), - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - -@cuda_lower( - operator.contains, MaskedType(string_view), MaskedType(string_view) +create_binary_string_func( + "MaskedType.find", + string_view_find_impl, + (size_type, string_view, string_view), ) -def masked_string_view_contains_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - masked_sv_substr = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[1] - ) - result = string_view_contains_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value, masked_sv_substr.value), - ) - - ret.value = result - ret.valid = builder.and_(masked_sv_str.valid, masked_sv_substr.valid) - return ret._getvalue() - - -@cuda_lower("MaskedType.isalnum", MaskedType(string_view)) -def masked_string_view_isalnum_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - - result = string_view_isalnum_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) - - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() +create_binary_string_func( + "MaskedType.rfind", + string_view_rfind_impl, + (size_type, string_view, string_view), +) -@cuda_lower("MaskedType.isalpha", MaskedType(string_view)) -def masked_string_view_isalpha_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - - result = string_view_isalpha_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) - - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() - - -@cuda_lower("MaskedType.isdigit", MaskedType(string_view)) -def masked_string_view_isdigit_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - - result = string_view_isdigit_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) - - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() - - -@cuda_lower("MaskedType.isdecimal", MaskedType(string_view)) -def masked_string_view_isdecimal_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - - result = string_view_isdecimal_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) - - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() - - -@cuda_lower("MaskedType.isupper", MaskedType(string_view)) -def masked_string_view_isupper_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - - result = string_view_isupper_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) +create_binary_string_func( + "MaskedType.count", + string_view_count_impl, + (size_type, string_view, string_view), +) - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() +create_binary_string_func( + operator.contains, + string_view_contains_impl, + (types.boolean, string_view, string_view), +) -@cuda_lower("MaskedType.islower", MaskedType(string_view)) -def masked_string_view_islower_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) +def create_masked_unary_identifier_func(op, cuda_func): + def masked_unary_func_impl(context, builder, sig, args): + ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) + masked_str = cgutils.create_struct_proxy(sig.args[0])( + context, builder, value=args[0] + ) - result = string_view_islower_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) + result = cuda_func( + context, + builder, + types.boolean(string_view, string_view), + (masked_str.value,), + ) + ret.value = result + ret.valid = masked_str.valid + return ret._getvalue() - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() + cuda_lower(op, MaskedType(string_view))(masked_unary_func_impl) -@cuda_lower("MaskedType.isspace", MaskedType(string_view)) -def masked_string_view_isspace_impl(context, builder, sig, args): - ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) - masked_sv_ty = sig.args[0] - masked_sv_str = cgutils.create_struct_proxy(masked_sv_ty)( - context, builder, value=args[0] - ) - - result = string_view_isspace_impl( - context, - builder, - types.boolean(string_view, string_view), - (masked_sv_str.value,), - ) - - ret.value = result - ret.valid = masked_sv_str.valid - return ret._getvalue() +create_masked_unary_identifier_func( + "MaskedType.isalnum", string_view_isalnum_impl +) +create_masked_unary_identifier_func( + "MaskedType.isalpha", string_view_isalpha_impl +) +create_masked_unary_identifier_func( + "MaskedType.isdigit", string_view_isdigit_impl +) +create_masked_unary_identifier_func( + "MaskedType.isupper", string_view_isupper_impl +) +create_masked_unary_identifier_func( + "MaskedType.islower", string_view_islower_impl +) +create_masked_unary_identifier_func( + "MaskedType.isspace", string_view_isspace_impl +) +create_masked_unary_identifier_func( + "MaskedType.isdecimal", string_view_isdecimal_impl +) From c4438c52287783ea0a7cf4aa9d0cb0063cbebc0c Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 12:07:20 -0700 Subject: [PATCH 125/212] simplify test suite using fixtures --- python/cudf/cudf/tests/test_udf_masked_ops.py | 148 +++++------------- 1 file changed, 36 insertions(+), 112 deletions(-) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index da3e5cd3733..d4de1a1557a 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -55,6 +55,11 @@ def string_udf_test(f): ] +@pytest.fixture(scope="module") +def str_data(): + return cudf.DataFrame({"str_col": string_data}) + + def run_masked_udf_test(func, data, args=(), **kwargs): gdf = data pdf = data.to_pandas(nullable=True) @@ -715,227 +720,146 @@ def f(x): @string_udf_test -@pytest.mark.parametrize("data", [{"str_col": string_data}]) -def test_string_udf_len(data): - data = cudf.DataFrame(data) - +def test_string_udf_len(str_data): def func(row): st = row["str_col"] return len(st) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize("data", [{"str_col": string_data}]) @pytest.mark.parametrize("substr", ["a", "cu", "2"]) -def test_string_udf_startswith(data, substr): - - data = cudf.DataFrame(data) - +def test_string_udf_startswith(str_data, substr): def func(row): st = row["str_col"] return st.startswith(substr) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) @pytest.mark.parametrize("substr", ["a", "gpu", "2"]) -def test_string_udf_endswith(data, substr): - data = cudf.DataFrame(data) - +def test_string_udf_endswith(str_data, substr): def func(row): st = row["str_col"] return st.endswith(substr) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) @pytest.mark.parametrize("substr", ["u", "gpu", "a"]) -def test_string_udf_find(data, substr): - data = cudf.DataFrame(data) - +def test_string_udf_find(str_data, substr): def func(row): st = row["str_col"] return st.find(substr) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) @pytest.mark.parametrize("substr", ["u", "gpu", "a"]) -def test_string_udf_rfind(data, substr): - data = cudf.DataFrame(data) - +def test_string_udf_rfind(str_data, substr): def func(row): st = row["str_col"] return st.rfind(substr) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) @pytest.mark.parametrize("substr", ["a", "cu", "", "12"]) -def test_string_udf_contains(data, substr): - data = cudf.DataFrame(data) - +def test_string_udf_contains(str_data, substr): def func(row): st = row["str_col"] return substr in st - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) @pytest.mark.parametrize("other", ["cudf", "123", "", " "]) @pytest.mark.parametrize("cmpop", comparison_ops) -def test_string_udf_cmpops(data, other, cmpop): - data = cudf.DataFrame(data) - +def test_string_udf_cmpops(str_data, other, cmpop): def func(row): st = row["str_col"] return cmpop(st, other) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_isalnum(data): - data = cudf.DataFrame(data) - +def test_string_udf_isalnum(str_data): def func(row): st = row["str_col"] return st.isalnum() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_isalpha(data): - data = cudf.DataFrame(data) - +def test_string_udf_isalpha(str_data): def func(row): st = row["str_col"] return st.isalpha() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_isdigit(data): - data = cudf.DataFrame(data) - +def test_string_udf_isdigit(str_data): def func(row): st = row["str_col"] return st.isdigit() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_isdecimal(data): - data = cudf.DataFrame(data) - +def test_string_udf_isdecimal(str_data): def func(row): st = row["str_col"] return st.isdecimal() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_isupper(data): - data = cudf.DataFrame(data) - +def test_string_udf_isupper(str_data): def func(row): st = row["str_col"] return st.isupper() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_islower(data): - data = cudf.DataFrame(data) - +def test_string_udf_islower(str_data): def func(row): st = row["str_col"] return st.islower() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize( - "data", - [{"str_col": string_data}], -) -def test_string_udf_isspace(data): - data = cudf.DataFrame(data) - +def test_string_udf_isspace(str_data): def func(row): st = row["str_col"] return st.isspace() - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) -@pytest.mark.parametrize("data", [{"str_col": string_data}]) +@string_udf_test @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) -def test_string_udf_count(data, substr): - data = cudf.DataFrame(data) - +def test_string_udf_count(str_data, substr): def func(row): st = row["str_col"] return st.count(substr) - run_masked_udf_test(func, data, check_dtype=False) + run_masked_udf_test(func, str_data, check_dtype=False) @pytest.mark.parametrize( From 1faf49dd8481c8800b168c96833577cb81166aa0 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 12:29:51 -0700 Subject: [PATCH 126/212] use a fixture in test_string_udfs --- .../strings_udf/tests/test_string_udfs.py | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index 532c82449bf..3adac581361 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -28,7 +28,11 @@ ] -@pytest.mark.parametrize("data", [string_data]) +@pytest.fixture(scope="module") +def data(): + return string_data + + @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_eq(data, rhs): def func(st): @@ -37,7 +41,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ne(data, rhs): def func(st): @@ -46,7 +49,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ge(data, rhs): def func(st): @@ -55,7 +57,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_le(data, rhs): def func(st): @@ -64,7 +65,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_gt(data, rhs): def func(st): @@ -73,7 +73,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_lt(data, rhs): def func(st): @@ -82,7 +81,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) def test_string_udf_contains(data, substr): def func(st): @@ -91,7 +89,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(data, substr): def func(st): @@ -100,7 +97,6 @@ def func(st): run_udf_test(data, func, "int32") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_find(data, substr): def func(st): @@ -109,7 +105,6 @@ def func(st): run_udf_test(data, func, "int32") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_endswith(data, substr): def func(st): @@ -118,7 +113,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isalnum(data): def func(st): return st.isalnum() @@ -126,7 +120,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isalpha(data): def func(st): return st.isalpha() @@ -134,7 +127,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isdecimal(data): def func(st): return st.isdecimal() @@ -142,7 +134,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isdigit(data): def func(st): return st.isdigit() @@ -150,7 +141,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_islower(data): def func(st): return st.islower() @@ -158,7 +148,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isnumeric(data): def func(st): return st.isnumeric() @@ -166,7 +155,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isspace(data): def func(st): return st.isspace() @@ -174,7 +162,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_isupper(data): def func(st): return st.isupper() @@ -182,7 +169,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("data", [string_data]) def test_string_udf_len(data): def func(st): return len(st) @@ -190,7 +176,6 @@ def func(st): run_udf_test(data, func, "int64") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_rfind(data, substr): def func(st): @@ -199,7 +184,6 @@ def func(st): run_udf_test(data, func, "int32") -@pytest.mark.parametrize("data", [string_data]) @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_startswith(data, substr): def func(st): From c0bd0f5d82f9d2a9efeb71145205fd46019b8deb Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 12:30:19 -0700 Subject: [PATCH 127/212] remove comments in shim.cu --- .../strings_udf/cpp/src/strings/udf/shim.cu | 77 ------------------- 1 file changed, 77 deletions(-) diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu index c9aaca0a121..862f462d840 100644 --- a/python/strings_udf/cpp/src/strings/udf/shim.cu +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -20,10 +20,6 @@ using namespace cudf::strings::udf; -/* -len -*/ - extern "C" __device__ int len(int* nb_retval, void* str) { cudf::string_view* sv = reinterpret_cast(str); @@ -31,10 +27,6 @@ extern "C" __device__ int len(int* nb_retval, void* str) return 0; } -/* -startswith -*/ - extern "C" __device__ int startswith(bool* nb_retval, void* str, void* substr) { cudf::string_view* str_view = reinterpret_cast(str); @@ -53,10 +45,6 @@ extern "C" __device__ int endswith(bool* nb_retval, void* str, void* substr) return 0; } -/* -contains -*/ - extern "C" __device__ int contains(bool* nb_retval, void* str, void* substr) { cudf::string_view* str_view = reinterpret_cast(str); @@ -66,9 +54,6 @@ extern "C" __device__ int contains(bool* nb_retval, void* str, void* substr) return 0; } -/* -find -*/ extern "C" __device__ int find(int* nb_retval, void* str, void* substr) { cudf::string_view* str_view = reinterpret_cast(str); @@ -78,9 +63,6 @@ extern "C" __device__ int find(int* nb_retval, void* str, void* substr) return 0; } -/* -rfind -*/ extern "C" __device__ int rfind(int* nb_retval, void* str, void* substr) { cudf::string_view* str_view = reinterpret_cast(str); @@ -90,10 +72,6 @@ extern "C" __device__ int rfind(int* nb_retval, void* str, void* substr) return 0; } -/* -== -*/ - extern "C" __device__ int eq(bool* nb_retval, void* str, void* rhs) { cudf::string_view* str_view = reinterpret_cast(str); @@ -103,10 +81,6 @@ extern "C" __device__ int eq(bool* nb_retval, void* str, void* rhs) return 0; } -/* -!= -*/ - extern "C" __device__ int ne(bool* nb_retval, void* str, void* rhs) { cudf::string_view* str_view = reinterpret_cast(str); @@ -116,10 +90,6 @@ extern "C" __device__ int ne(bool* nb_retval, void* str, void* rhs) return 0; } -/* ->= -*/ - extern "C" __device__ int ge(bool* nb_retval, void* str, void* rhs) { cudf::string_view* str_view = reinterpret_cast(str); @@ -129,10 +99,6 @@ extern "C" __device__ int ge(bool* nb_retval, void* str, void* rhs) return 0; } -/* -<= -*/ - extern "C" __device__ int le(bool* nb_retval, void* str, void* rhs) { cudf::string_view* str_view = reinterpret_cast(str); @@ -142,10 +108,6 @@ extern "C" __device__ int le(bool* nb_retval, void* str, void* rhs) return 0; } -/* -> -*/ - extern "C" __device__ int gt(bool* nb_retval, void* str, void* rhs) { cudf::string_view* str_view = reinterpret_cast(str); @@ -155,10 +117,6 @@ extern "C" __device__ int gt(bool* nb_retval, void* str, void* rhs) return 0; } -/* -< -*/ - extern "C" __device__ int lt(bool* nb_retval, void* str, void* rhs) { cudf::string_view* str_view = reinterpret_cast(str); @@ -168,10 +126,6 @@ extern "C" __device__ int lt(bool* nb_retval, void* str, void* rhs) return 0; } -/* -islower -*/ - extern "C" __device__ int pyislower(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -181,10 +135,6 @@ extern "C" __device__ int pyislower(bool* nb_retval, void* str, std::int64_t cha return 0; } -/* -isupper -*/ - extern "C" __device__ int pyisupper(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -194,10 +144,6 @@ extern "C" __device__ int pyisupper(bool* nb_retval, void* str, std::int64_t cha return 0; } -/* -isspace -*/ - extern "C" __device__ int pyisspace(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -207,10 +153,6 @@ extern "C" __device__ int pyisspace(bool* nb_retval, void* str, std::int64_t cha return 0; } -/* -isdecimal -*/ - extern "C" __device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -220,10 +162,6 @@ extern "C" __device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t c return 0; } -/* -isnumeric -*/ - extern "C" __device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -233,10 +171,6 @@ extern "C" __device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t c return 0; } -/* -isdigit -*/ - extern "C" __device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -246,10 +180,6 @@ extern "C" __device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t cha return 0; } -/* -isalnum -*/ - extern "C" __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -259,9 +189,6 @@ extern "C" __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t cha return 0; } -/* -isalpha -*/ extern "C" __device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t chars_table) { cudf::string_view* str_view = reinterpret_cast(str); @@ -271,10 +198,6 @@ extern "C" __device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t cha return 0; } -/* -count -*/ - extern "C" __device__ int pycount(int* nb_retval, void* str, void* substr) { cudf::string_view* str_view = reinterpret_cast(str); From 80b176ef8af0c9a5cf53a39127e8cc0069a9c728 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 12:40:34 -0700 Subject: [PATCH 128/212] prune setup.py --- python/strings_udf/setup.py | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index 3069a5e6ffb..a8a834c0051 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -11,30 +11,13 @@ import versioneer install_requires = [ - "cachetools", - "cuda-python>=11.5,<11.7.1", - "fsspec>=0.6.0", "numba>=0.53.1", "numpy", - "nvtx>=0.2.1", - "packaging", - "pandas>=1.0,<1.5.0dev0", - "protobuf>=3.20.1,<3.21.0a0", - "typing_extensions", ] extras_require = { "test": [ "pytest", - "pytest-benchmark", - "pytest-xdist", - "hypothesis", - "mimesis", - "fastavro>=0.22.9", - "python-snappy>=0.6.0", - "pyorc", - "msgpack", - "transformers<=4.10.3", ] } @@ -75,12 +58,6 @@ def get_cuda_version_from_header(cuda_include_dir, delimeter=""): raise OSError(f"Invalid CUDA_HOME: directory does not exist: {CUDA_HOME}") cuda_include_dir = os.path.join(CUDA_HOME, "include") -install_requires.append( - "cupy-cuda" - + get_cuda_version_from_header(cuda_include_dir) - + ">=9.5.0,<11.0.0a0" -) - cmdclass = versioneer.get_cmdclass() cmdclass["build_ext"] = build_ext From 67fada74c06af20fb8b273bad6a365dbbc6e2662 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 12:40:49 -0700 Subject: [PATCH 129/212] address reviews in __init__.py --- python/strings_udf/strings_udf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index 087be552df8..bc2d1283eeb 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -26,7 +26,7 @@ def versions_compatible(path): # adapted from patch_needed() cp = subprocess.run([sys.executable, "-c", CMD], capture_output=True) - if cp.returncode: + if cp.returncode != 0: # no driver return False From 45396fb625b27329abda1d03c0d852d48c0b2c22 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 12:43:16 -0700 Subject: [PATCH 130/212] more __init__ updates --- python/strings_udf/strings_udf/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index bc2d1283eeb..c366f31108d 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -4,6 +4,7 @@ import sys import subprocess import re +from . import _version def versions_compatible(path): @@ -39,6 +40,4 @@ def versions_compatible(path): ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" ENABLED = versions_compatible(ptxpath) -from . import _version - __version__ = _version.get_versions()["version"] From 7489e7f94ea7b34188a86dc0d23a921ed0b65bb6 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 13:29:12 -0700 Subject: [PATCH 131/212] update test utils in strings_udf library --- python/strings_udf/strings_udf/tests/utils.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py index 9e9f5733165..c95c4ae2839 100644 --- a/python/strings_udf/strings_udf/tests/utils.py +++ b/python/strings_udf/strings_udf/tests/utils.py @@ -16,25 +16,37 @@ def get_kernel(func, dtype): + """ + Create a kernel for testing a single scalar string function + Allocates an output vector with a dtype specified by the caller + The returned kernel executes the input function on each data + element of the input and returns the output into the output vector + """ + func = cuda.jit(device=True)(func) + outty = numba.np.numpy_support.from_dtype(dtype) + sig = nb_signature(void, CPointer(string_view), outty[::1]) - def execute_function(input_strings, output_col): + @cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler]) + def kernel(input_strings, output_col): id = cuda.grid(1) if id < len(output_col): st = input_strings[id] result = func(st) output_col[id] = result - outty = numba.np.numpy_support.from_dtype(dtype) - sig = nb_signature(void, CPointer(string_view), outty[::1]) - kernel = cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler])( - execute_function - ) - return kernel def run_udf_test(data, func, dtype): + """ + Run a test kernel on a set of input data + Converts the input data to a cuDF column and subsequently + to an array of cudf::string_view objects. It then creates + a CUDA kernel using get_kernel which calls the input function, + and then assembles the result back into a cuDF series before + comparing it with the equivalent pandas result + """ dtype = np.dtype(dtype) cudf_column = cudf.Series(data)._column str_view_ary = to_string_view_array(cudf_column) From 49db99659306564223975b3a8a39ae7b1739b852 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 13:30:40 -0700 Subject: [PATCH 132/212] merge test utils into test_string_udfs.py --- .../strings_udf/tests/test_string_udfs.py | 59 +++++++++++++++++- python/strings_udf/strings_udf/tests/utils.py | 60 ------------------- 2 files changed, 58 insertions(+), 61 deletions(-) delete mode 100644 python/strings_udf/strings_udf/tests/utils.py diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index 3adac581361..4ecfaab6d6e 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -1,8 +1,65 @@ # Copyright (c) 2022, NVIDIA CORPORATION. +import numba +import numpy as np +import pandas as pd import pytest +from numba import cuda +from numba.core.typing import signature as nb_signature +from numba.types import CPointer, void + +import cudf +from cudf.testing._utils import assert_eq + +from strings_udf import ptxpath +from strings_udf._lib.cudf_jit_udf import to_string_view_array +from strings_udf._typing import str_view_arg_handler, string_view + + +def get_kernel(func, dtype): + """ + Create a kernel for testing a single scalar string function + Allocates an output vector with a dtype specified by the caller + The returned kernel executes the input function on each data + element of the input and returns the output into the output vector + """ + + func = cuda.jit(device=True)(func) + outty = numba.np.numpy_support.from_dtype(dtype) + sig = nb_signature(void, CPointer(string_view), outty[::1]) + + @cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler]) + def kernel(input_strings, output_col): + id = cuda.grid(1) + if id < len(output_col): + st = input_strings[id] + result = func(st) + output_col[id] = result + + return kernel + + +def run_udf_test(data, func, dtype): + """ + Run a test kernel on a set of input data + Converts the input data to a cuDF column and subsequently + to an array of cudf::string_view objects. It then creates + a CUDA kernel using get_kernel which calls the input function, + and then assembles the result back into a cuDF series before + comparing it with the equivalent pandas result + """ + dtype = np.dtype(dtype) + cudf_column = cudf.Series(data)._column + str_view_ary = to_string_view_array(cudf_column) + + output_ary = cudf.core.column.column_empty(len(data), dtype=dtype) + + kernel = get_kernel(func, dtype) + kernel.forall(len(data))(str_view_ary, output_ary) + got = cudf.Series(output_ary, dtype=dtype) + expect = pd.Series(data).apply(func) + assert_eq(expect, got, check_dtype=False) -from .utils import run_udf_test string_data = [ "abc", diff --git a/python/strings_udf/strings_udf/tests/utils.py b/python/strings_udf/strings_udf/tests/utils.py deleted file mode 100644 index c95c4ae2839..00000000000 --- a/python/strings_udf/strings_udf/tests/utils.py +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022, NVIDIA CORPORATION. - -import numba -import numpy as np -import pandas as pd -from numba import cuda -from numba.core.typing import signature as nb_signature -from numba.types import CPointer, void - -import cudf -from cudf.testing._utils import assert_eq - -from strings_udf import ptxpath -from strings_udf._lib.cudf_jit_udf import to_string_view_array -from strings_udf._typing import str_view_arg_handler, string_view - - -def get_kernel(func, dtype): - """ - Create a kernel for testing a single scalar string function - Allocates an output vector with a dtype specified by the caller - The returned kernel executes the input function on each data - element of the input and returns the output into the output vector - """ - - func = cuda.jit(device=True)(func) - outty = numba.np.numpy_support.from_dtype(dtype) - sig = nb_signature(void, CPointer(string_view), outty[::1]) - - @cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler]) - def kernel(input_strings, output_col): - id = cuda.grid(1) - if id < len(output_col): - st = input_strings[id] - result = func(st) - output_col[id] = result - - return kernel - - -def run_udf_test(data, func, dtype): - """ - Run a test kernel on a set of input data - Converts the input data to a cuDF column and subsequently - to an array of cudf::string_view objects. It then creates - a CUDA kernel using get_kernel which calls the input function, - and then assembles the result back into a cuDF series before - comparing it with the equivalent pandas result - """ - dtype = np.dtype(dtype) - cudf_column = cudf.Series(data)._column - str_view_ary = to_string_view_array(cudf_column) - - output_ary = cudf.core.column.column_empty(len(data), dtype=dtype) - - kernel = get_kernel(func, dtype) - kernel.forall(len(data))(str_view_ary, output_ary) - got = cudf.Series(output_ary, dtype=dtype) - expect = pd.Series(data).apply(func) - assert_eq(expect, got, check_dtype=False) From 95b6f5e75a2427e4e98d5cec0b437619c08adc30 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 14:43:05 -0700 Subject: [PATCH 133/212] Change C++ strings_udf code to be built as part of the Python code. --- python/strings_udf/CMakeLists.txt | 11 ++- python/strings_udf/cpp/CMakeLists.txt | 90 ++++++++++------------ python/strings_udf/strings_udf/__init__.py | 3 +- 3 files changed, 53 insertions(+), 51 deletions(-) diff --git a/python/strings_udf/CMakeLists.txt b/python/strings_udf/CMakeLists.txt index a306eab826c..f9efc88df71 100644 --- a/python/strings_udf/CMakeLists.txt +++ b/python/strings_udf/CMakeLists.txt @@ -18,6 +18,13 @@ set(strings_udf_version 22.10.00) include(../../fetch_rapids.cmake) +include(rapids-cuda) + +# TODO: I believe this needs to come before the `project` call, but this is unfortunate because CUDA +# is really only required in the cpp subdirectory so this is a bit out of place. I'm not sure if +# there's a better solution here, though. +rapids_cuda_init_architectures(STRINGS_UDF) + project( strings-udf-python VERSION ${strings_udf_version} @@ -25,11 +32,13 @@ project( # language to be enabled here. The test project that is built in scikit-build to verify # various linking options for the python library is hardcoded to build with C, so until # that is fixed we need to keep C. - C CXX + C CXX CUDA ) find_package(cudf ${strings_udf_version} REQUIRED) +add_subdirectory(cpp) + include(rapids-cython) rapids_cython_init() diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 908889b8d98..82658caa4a8 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -14,11 +14,6 @@ cmake_minimum_required(VERSION 3.20.1) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.08/RAPIDS.cmake - ${CMAKE_BINARY_DIR}/RAPIDS.cmake -) -include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) - include(rapids-cmake) include(rapids-cpm) include(rapids-cuda) @@ -27,51 +22,30 @@ include(rapids-find) rapids_cpm_init() -# set the project name and version -project( - cudf_strings_udf - VERSION 0.1 - DESCRIPTION "cudf strings-udf library" - LANGUAGES C CXX CUDA +rapids_find_package( + CUDAToolkit REQUIRED + BUILD_EXPORT_SET strings-udf-exports + INSTALL_EXPORT_SET strings-udf-exports ) -if(NOT CONDA_PREFIX) - message(FATAL_ERROR " CONDA_PREFIX must be set") -endif() - -message(STATUS "CONDA_PREFIX=${CONDA_PREFIX}") - -find_package(CUDAToolkit REQUIRED) - -# depends on an installed cudf dev env -set(UDF_INCLUDES ${CONDA_PREFIX}/include) -list(APPEND UDF_INCLUDES ${CONDA_PREFIX}/include/rapids/libcudacxx) - -set(UDF_LIBS ${CONDA_PREFIX}/lib/libcudf.so nvrtc) +include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) +rapids_cpm_libcudacxx(BUILD_EXPORT_SET cudf-exports INSTALL_EXPORT_SET cudf-exports) set(UDF_CXX_FLAGS "") set(UDF_CUDA_FLAGS "") set(SHIM_CUDA_FLAGS "") list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) -list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true -keep) +list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) +# TODO: Will need to create separate shim libraries for different architectures. add_library(shim OBJECT src/strings/udf/shim.cu) set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) -target_include_directories( - shim - PRIVATE include - PUBLIC ${CMAKE_SOURCE_DIR}/include -) - -target_include_directories( - shim - PRIVATE include - PUBLIC ${CONDA_PREFIX}/include -) +target_include_directories(shim PUBLIC include) +target_include_directories(cudf_strings_udf PUBLIC include) set_target_properties( cudf_strings_udf @@ -93,16 +67,34 @@ target_compile_options( target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") -target_include_directories( - cudf_strings_udf - PRIVATE include - PUBLIC ${UDF_INCLUDES} -) -target_link_libraries(cudf_strings_udf PUBLIC ${UDF_LIBS}) - -install(TARGETS cudf_strings_udf - PUBLIC_HEADER DESTINATION ${CONDA_PREFIX}/include/cudf/strings/udf/ -) -install(FILES ${CMAKE_SOURCE_DIR}/build/CMakeFiles/shim.dir/src/strings/udf/shim.ptx - DESTINATION ${CONDA_PREFIX}/lib -) +target_link_libraries(cudf_strings_udf PUBLIC cudf::cudf CUDA::nvrtc) +target_link_libraries(shim PUBLIC cudf::cudf) + +# install(TARGETS cudf_strings_udf PUBLIC_HEADER DESTINATION +# ${CONDA_PREFIX}/include/cudf/strings/udf/ ) + +# This function will copy the generated PTX file from its generator-specific location in the build +# tree into a specified location in the build tree from which we can install it. +function(copy_ptx_to_location target destination) + set(cmake_generated_file + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cp_${target}_$>_ptx.cmake" + ) + file( + GENERATE + OUTPUT "${cmake_generated_file}" + CONTENT + " +set(ptx_paths \"$\") +file(COPY \${ptx_paths} DESTINATION \"${destination}\")" + ) + + add_custom_target( + ${target}_cp_ptx ALL + COMMAND ${CMAKE_COMMAND} -P "${cmake_generated_file}" + DEPENDS $ + COMMENT "Copying PTX files to '${destination}'" + ) +endfunction() + +copy_ptx_to_location(shim "${CMAKE_CURRENT_BINARY_DIR}/../strings_udf") +install(FILES $ DESTINATION ./strings_udf) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index 087be552df8..e74a1be2d76 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -36,7 +36,8 @@ def versions_compatible(path): return driver_version >= (int(major), int(minor)) and not patch_needed() -ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" +# ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" +ptxpath = os.path.join(os.path.dirname(__file__), "shim.ptx") ENABLED = versions_compatible(ptxpath) from . import _version From 62723273305fc364a57d6c91a8c8fabd162779ca Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 14:53:54 -0700 Subject: [PATCH 134/212] Simplify CUDA handling. --- python/strings_udf/CMakeLists.txt | 16 +++++++--------- python/strings_udf/cpp/CMakeLists.txt | 10 ++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/python/strings_udf/CMakeLists.txt b/python/strings_udf/CMakeLists.txt index f9efc88df71..59d8ae795f2 100644 --- a/python/strings_udf/CMakeLists.txt +++ b/python/strings_udf/CMakeLists.txt @@ -18,21 +18,19 @@ set(strings_udf_version 22.10.00) include(../../fetch_rapids.cmake) -include(rapids-cuda) - -# TODO: I believe this needs to come before the `project` call, but this is unfortunate because CUDA -# is really only required in the cpp subdirectory so this is a bit out of place. I'm not sure if -# there's a better solution here, though. -rapids_cuda_init_architectures(STRINGS_UDF) - project( strings-udf-python VERSION ${strings_udf_version} - LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + LANGUAGES CXX + # TODO: Building Python extension modules via the python_extension_module requires the C # language to be enabled here. The test project that is built in scikit-build to verify # various linking options for the python library is hardcoded to build with C, so until # that is fixed we need to keep C. - C CXX CUDA + C + # TODO: Enabling CUDA will not be necessary once we upgrade to CMake 3.22, which will + # pull in the required languages for the C++ project even if this project does not + # require those languges. + CUDA ) find_package(cudf ${strings_udf_version} REQUIRED) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 82658caa4a8..c867fa7d587 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -22,6 +22,16 @@ include(rapids-find) rapids_cpm_init() +project( + strings-udf-cpp + VERSION ${strings_udf_version} + LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C + # language to be enabled here. The test project that is built in scikit-build to verify + # various linking options for the python library is hardcoded to build with C, so until + # that is fixed we need to keep C. + CUDA +) + rapids_find_package( CUDAToolkit REQUIRED BUILD_EXPORT_SET strings-udf-exports From d003e85630f3eddbb78dd055125fe8782c082b27 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 15:12:14 -0700 Subject: [PATCH 135/212] Reorganize to clearly separate the C++ functionality from the shim code. --- python/cudf/cudf/core/udf/__init__.py | 4 ++-- python/strings_udf/cpp/CMakeLists.txt | 24 +++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index af768e829c5..2daa5dfcd78 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -57,8 +57,8 @@ else: del strings_udf -except ImportError: +except ImportError as e: # allow cuDF to work without strings_udf - pass + raise masked_typing.register_masked_constructor(supported_masked_types) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index c867fa7d587..c003eee4d0e 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -22,6 +22,8 @@ include(rapids-find) rapids_cpm_init() +rapids_cuda_init_architectures(STRINGS_UDF) + project( strings-udf-cpp VERSION ${strings_udf_version} @@ -43,18 +45,10 @@ rapids_cpm_libcudacxx(BUILD_EXPORT_SET cudf-exports INSTALL_EXPORT_SET cudf-expo set(UDF_CXX_FLAGS "") set(UDF_CUDA_FLAGS "") -set(SHIM_CUDA_FLAGS "") list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) -list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) -# TODO: Will need to create separate shim libraries for different architectures. -add_library(shim OBJECT src/strings/udf/shim.cu) - -set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) - -target_include_directories(shim PUBLIC include) target_include_directories(cudf_strings_udf PUBLIC include) set_target_properties( @@ -74,14 +68,18 @@ target_compile_options( cudf_strings_udf PRIVATE "$<$:${UDF_CXX_FLAGS}>" "$<$:${UDF_CUDA_FLAGS}>" ) +target_link_libraries(cudf_strings_udf PUBLIC cudf::cudf CUDA::nvrtc) -target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") +# Shim libraries. TODO: Will need to create separate shim libraries for different architectures. +add_library(shim OBJECT src/strings/udf/shim.cu) +set(SHIM_CUDA_FLAGS "") +list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) -target_link_libraries(cudf_strings_udf PUBLIC cudf::cudf CUDA::nvrtc) -target_link_libraries(shim PUBLIC cudf::cudf) +set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) -# install(TARGETS cudf_strings_udf PUBLIC_HEADER DESTINATION -# ${CONDA_PREFIX}/include/cudf/strings/udf/ ) +target_include_directories(shim PUBLIC include) +target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") +target_link_libraries(shim PUBLIC cudf::cudf) # This function will copy the generated PTX file from its generator-specific location in the build # tree into a specified location in the build tree from which we can install it. From cc017075626aad6727ca1ef87c0252cc6d222a1d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 15:19:38 -0700 Subject: [PATCH 136/212] Install the C++ lib. --- python/strings_udf/cpp/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index c003eee4d0e..5124c6e11df 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -69,6 +69,7 @@ target_compile_options( "$<$:${UDF_CUDA_FLAGS}>" ) target_link_libraries(cudf_strings_udf PUBLIC cudf::cudf CUDA::nvrtc) +install(TARGETS cudf_strings_udf DESTINATION ./strings_udf/_lib/) # Shim libraries. TODO: Will need to create separate shim libraries for different architectures. add_library(shim OBJECT src/strings/udf/shim.cu) From 10f3379d5788668c20ac0b6f0b49a7b977405021 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 15:54:00 -0700 Subject: [PATCH 137/212] Compile shims for every architecture. --- python/strings_udf/cpp/CMakeLists.txt | 34 +++++++++++++--------- python/strings_udf/strings_udf/__init__.py | 16 ++++++++-- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 5124c6e11df..cec87fb4f9c 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -71,17 +71,6 @@ target_compile_options( target_link_libraries(cudf_strings_udf PUBLIC cudf::cudf CUDA::nvrtc) install(TARGETS cudf_strings_udf DESTINATION ./strings_udf/_lib/) -# Shim libraries. TODO: Will need to create separate shim libraries for different architectures. -add_library(shim OBJECT src/strings/udf/shim.cu) -set(SHIM_CUDA_FLAGS "") -list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) - -set_property(TARGET shim PROPERTY CUDA_PTX_COMPILATION ON) - -target_include_directories(shim PUBLIC include) -target_compile_options(shim PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") -target_link_libraries(shim PUBLIC cudf::cudf) - # This function will copy the generated PTX file from its generator-specific location in the build # tree into a specified location in the build tree from which we can install it. function(copy_ptx_to_location target destination) @@ -105,5 +94,24 @@ file(COPY \${ptx_paths} DESTINATION \"${destination}\")" ) endfunction() -copy_ptx_to_location(shim "${CMAKE_CURRENT_BINARY_DIR}/../strings_udf") -install(FILES $ DESTINATION ./strings_udf) +# Create the shim library for each architecture. +foreach(arch IN LISTS CMAKE_CUDA_ARCHITECTURES) + set(tgt shim_${arch}) + + add_library(${tgt} OBJECT src/strings/udf/shim.cu) + set(SHIM_CUDA_FLAGS "") + list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) + + set_target_properties(${tgt} PROPERTIES CUDA_ARCHITECTURES ${arch} CUDA_PTX_COMPILATION ON) + + target_include_directories(${tgt} PUBLIC include) + target_compile_options(${tgt} PRIVATE "$<$:${SHIM_CUDA_FLAGS}>") + target_link_libraries(${tgt} PUBLIC cudf::cudf) + + copy_ptx_to_location(${tgt} "${CMAKE_CURRENT_BINARY_DIR}/../strings_udf") + install( + FILES $ + DESTINATION ./strings_udf + RENAME ${tgt}.ptx + ) +endforeach() diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index e74a1be2d76..4f74469edb0 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,10 +1,13 @@ # Copyright (c) 2022, NVIDIA CORPORATION. from ptxcompiler.patch import patch_needed, CMD +import glob import os import sys import subprocess import re +from numba import cuda + def versions_compatible(path): """ @@ -19,7 +22,7 @@ def versions_compatible(path): # obtain the cuda version used to compile this PTX file file = open(path).read() major, minor = ( - re.search("Cuda compilation tools, release ([0-9\.]+)", file) + re.search(r"Cuda compilation tools, release ([0-9\.]+)", file) .group(1) .split(".") ) @@ -36,8 +39,15 @@ def versions_compatible(path): return driver_version >= (int(major), int(minor)) and not patch_needed() -# ptxpath = os.getenv("CONDA_PREFIX") + "/lib/shim.ptx" -ptxpath = os.path.join(os.path.dirname(__file__), "shim.ptx") +# Load the highest compute capability file available that is less than the +# current device's. +dev = cuda.get_current_device() +cc = "".join(str(x) for x in dev.compute_capability) +files = glob.glob(os.path.join(os.path.dirname(__file__), "shim_*.ptx")) +sms = [os.path.basename(f).rstrip(".ptx").lstrip("shim_") for f in files] +selected_sm = max(sm for sm in sms if sm < cc) +ptxpath = os.path.join(os.path.dirname(__file__), f"shim_{selected_sm}.ptx") + ENABLED = versions_compatible(ptxpath) from . import _version From d204a066305b4ebb635d5a7311bb0f0c4ece8aba Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 15:58:13 -0700 Subject: [PATCH 138/212] Minor cleanup. --- python/strings_udf/cpp/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index cec87fb4f9c..203bce72123 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -24,6 +24,7 @@ rapids_cpm_init() rapids_cuda_init_architectures(STRINGS_UDF) +# Create a project so that we can enable CUDA architectures in this file. project( strings-udf-cpp VERSION ${strings_udf_version} @@ -95,12 +96,12 @@ file(COPY \${ptx_paths} DESTINATION \"${destination}\")" endfunction() # Create the shim library for each architecture. +set(SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) + foreach(arch IN LISTS CMAKE_CUDA_ARCHITECTURES) set(tgt shim_${arch}) add_library(${tgt} OBJECT src/strings/udf/shim.cu) - set(SHIM_CUDA_FLAGS "") - list(APPEND SHIM_CUDA_FLAGS --expt-relaxed-constexpr -rdc=true) set_target_properties(${tgt} PROPERTIES CUDA_ARCHITECTURES ${arch} CUDA_PTX_COMPILATION ON) From 3a9be149ddafbb9c1c854743a1b55c70d6dea362 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Fri, 9 Sep 2022 17:33:09 -0700 Subject: [PATCH 139/212] remove cpp build step from build.sh --- build.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 5c2d67b3d4f..ac283d01fc9 100755 --- a/build.sh +++ b/build.sh @@ -336,14 +336,7 @@ if buildAll || hasArg cudf; then fi if buildAll || hasArg strings_udf; then - # do not separately expose strings_udf c++ library - # always build python and c++ at the same time and include into the same conda package - cd ${REPODIR}/python/strings_udf/cpp - cmake -S ./ -B build -DCONDA_PREFIX=${INSTALL_PREFIX} -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}/ - cmake --build build - if [[ ${INSTALL_TARGET} != "" ]]; then - cmake --install build - fi + cd ${REPODIR}/python/strings_udf python setup.py build_ext --inplace -- -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} -DCMAKE_LIBRARY_PATH=${LIBCUDF_BUILD_DIR} ${EXTRA_CMAKE_ARGS} -- -j${PARALLEL_LEVEL:-1} if [[ ${INSTALL_TARGET} != "" ]]; then From 8189f71d43ccdc91dfd5302357c982eaa0662037 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 21:03:13 -0700 Subject: [PATCH 140/212] Remove unnecessary files. --- .../cudf/strings/detail/strip_utils.cuh | 101 --------------- .../cudf/strings/split/split_utils.cuh | 121 ------------------ .../cpp/include/cudf/strings/udf/numeric.cuh | 53 -------- 3 files changed, 275 deletions(-) delete mode 100644 python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh delete mode 100644 python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh deleted file mode 100644 index 5d8d9240988..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/detail/strip_utils.cuh +++ /dev/null @@ -1,101 +0,0 @@ - -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include - -namespace cudf { -namespace strings { - -enum class strip_type { - LEFT, ///< strip characters from the beginning of the string - RIGHT, ///< strip characters from the end of the string - BOTH ///< strip characters from the beginning and end of the string -}; - -namespace detail { - -__device__ cudf::string_view strip(cudf::string_view const d_str, - cudf::string_view const d_to_strip, - strip_type stype = strip_type::BOTH) -{ - auto is_strip_character = [d_to_strip = d_to_strip](char_utf8 chr) -> bool { - if (d_to_strip.empty()) return chr <= ' '; // whitespace check - for (auto c : d_to_strip) { - if (c == chr) return true; - } - return false; - }; - - size_type const left_offset = [&] { - if (stype != strip_type::LEFT && stype != strip_type::BOTH) return 0; - for (auto itr = d_str.begin(); itr < d_str.end(); ++itr) { - if (!is_strip_character(*itr)) return itr.byte_offset(); - } - return d_str.size_bytes(); - }(); - - size_type const right_offset = [&] { - if (stype != strip_type::RIGHT && stype != strip_type::BOTH) return d_str.size_bytes(); - for (auto itr = d_str.end(); itr > d_str.begin(); --itr) { - if (!is_strip_character(*(itr - 1))) return itr.byte_offset(); - } - return 0; - }(); - - auto const bytes = (right_offset > left_offset) ? right_offset - left_offset : 0; - return cudf::string_view{d_str.data() + left_offset, bytes}; -} - -__device__ cudf::string_view strip(cudf::string_view const d_str, - char const* to_strip, - cudf::size_type bytes, - strip_type stype = strip_type::BOTH) -{ - auto const sv = cudf::string_view{to_strip, bytes}; - return strip(d_str, sv, stype); -} - -__device__ cudf::string_view lstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) -{ - return strip(d_str, d_to_strip, strip_type::LEFT); -} - -__device__ cudf::string_view lstrip(cudf::string_view const d_str, - char const* to_strip, - cudf::size_type bytes) -{ - auto const sv = cudf::string_view{to_strip, bytes}; - return strip(d_str, sv, strip_type::LEFT); -} - -__device__ cudf::string_view rstrip(cudf::string_view const d_str, cudf::string_view d_to_strip) -{ - return strip(d_str, d_to_strip, strip_type::RIGHT); -} - -__device__ cudf::string_view rstrip(cudf::string_view const d_str, - char const* to_strip, - cudf::size_type bytes) -{ - auto const sv = cudf::string_view{to_strip, bytes}; - return strip(d_str, sv, strip_type::RIGHT); -} - -} // namespace detail -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh b/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh deleted file mode 100644 index c2509422513..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/split/split_utils.cuh +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2020-2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -namespace cudf { -namespace strings { -namespace detail { - -// JIT has trouble including thrust/pair.h -using position_pair = struct { - size_type first; - size_type second; -}; - -/** - * @brief Instantiated for each string to manage navigating tokens from - * the beginning or the end of that string. - */ -struct whitespace_string_tokenizer { - /** - * @brief Identifies the position range of the next token in the given - * string at the specified iterator position. - * - * Tokens are delimited by one or more whitespace characters. - * - * @return true if a token has been found - */ - __device__ bool next_token() - { - if (itr != d_str.begin()) { // skip these 2 lines the first time through - ++itr; - start_position = itr.byte_offset(); // end_position + 1; - } - if (start_position >= d_str.size_bytes()) return false; - // continue search for the next token - end_position = d_str.size_bytes(); - for (; itr < d_str.end(); ++itr) { - if (spaces == (*itr <= ' ')) { - if (spaces) - start_position = (itr + 1).byte_offset(); - else - end_position = (itr + 1).byte_offset(); - continue; - } - spaces = !spaces; - if (spaces) { - end_position = itr.byte_offset(); - break; - } - } - return start_position < end_position; - } - - /** - * @brief Identifies the position range of the previous token in the given - * string at the specified iterator position. - * - * Tokens are delimited by one or more whitespace characters. - * - * @return true if a token has been found - */ - __device__ bool prev_token() - { - end_position = start_position - 1; - --itr; - if (end_position <= 0) return false; - // continue search for the next token - start_position = 0; - for (; itr >= d_str.begin(); --itr) { - if (spaces == (*itr <= ' ')) { - if (spaces) - end_position = itr.byte_offset(); - else - start_position = itr.byte_offset(); - continue; - } - spaces = !spaces; - if (spaces) { - start_position = (itr + 1).byte_offset(); - break; - } - } - return start_position < end_position; - } - - __device__ position_pair get_token() const { return position_pair{start_position, end_position}; } - - __device__ whitespace_string_tokenizer(string_view const& d_str, bool reverse = false) - : d_str{d_str}, - spaces(true), - start_position{reverse ? d_str.size_bytes() + 1 : 0}, - end_position{d_str.size_bytes()}, - itr{reverse ? d_str.end() : d_str.begin()} - { - } - - private: - string_view const d_str; - bool spaces; // true if current position is whitespace - cudf::string_view::const_iterator itr; - size_type start_position; - size_type end_position; -}; - -} // namespace detail -} // namespace strings -} // namespace cudf diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh deleted file mode 100644 index 8ee8603caa7..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/numeric.cuh +++ /dev/null @@ -1,53 +0,0 @@ - -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include -#include -#include - -namespace cudf { -namespace strings { -namespace udf { - -/** - * @brief Converts a string into an integer. - * - * The '+' and '-' are allowed but only at the beginning of the string. - * The string is expected to contain base-10 [0-9] characters only. - * Any other character will end the parse. - * Overflow of the int64 type is not detected. - */ -__device__ inline int64_t stoi(string_view const& d_str) -{ - return cudf::strings::detail::string_to_integer(d_str); -} - -/** - * @brief Converts a string into a double. - * - * Support scientific notation as well. - * Overflow goes to inf or -inf and underflow may go to 0. - */ -__device__ inline double stod(string_view const& d_str) -{ - return cudf::strings::detail::stod(d_str); -} - -} // namespace udf -} // namespace strings -} // namespace cudf From 138dd9a96305c529a257b149649f48911a7cb847 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 21:15:50 -0700 Subject: [PATCH 141/212] Define some more fixtures. --- .../strings_udf/tests/test_string_udfs.py | 69 +++++++++---------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index 4ecfaab6d6e..29d1b0a8b88 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -61,36 +61,42 @@ def run_udf_test(data, func, dtype): assert_eq(expect, got, check_dtype=False) -string_data = [ - "abc", - "ABC", - "AbC", - "123", - "123aBc", - "123@.!", - "", - "rapids ai", - "gpu", - "True", - "False", - "1.234", - ".123a", - "0.013", - "1.0", - "01", - "20010101", - "cudf", - "cuda", - "gpu", -] - - @pytest.fixture(scope="module") def data(): - return string_data + return [ + "abc", + "ABC", + "AbC", + "123", + "123aBc", + "123@.!", + "", + "rapids ai", + "gpu", + "True", + "False", + "1.234", + ".123a", + "0.013", + "1.0", + "01", + "20010101", + "cudf", + "cuda", + "gpu", + ] + + +@pytest.fixture(params=["cudf", "cuda", "gpucudf", "abc"]) +def rhs(request): + return request.param + + +@pytest.fixture(params=["c", "cu", "2", "abc", "", "gpu"]) +def substr(request): + return request.param -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_eq(data, rhs): def func(st): return st == rhs @@ -98,7 +104,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ne(data, rhs): def func(st): return st != rhs @@ -106,7 +111,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_ge(data, rhs): def func(st): return st >= rhs @@ -114,7 +118,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_le(data, rhs): def func(st): return st <= rhs @@ -122,7 +125,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_gt(data, rhs): def func(st): return st > rhs @@ -130,7 +132,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("rhs", ["cudf", "cuda", "gpucudf", "abc"]) def test_string_udf_lt(data, rhs): def func(st): return st < rhs @@ -138,7 +139,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("substr", ["a", "cu", "2", "abc"]) def test_string_udf_contains(data, substr): def func(st): return substr in st @@ -146,7 +146,6 @@ def func(st): run_udf_test(data, func, "bool") -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(data, substr): def func(st): return st.count(substr) @@ -154,7 +153,6 @@ def func(st): run_udf_test(data, func, "int32") -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_find(data, substr): def func(st): return st.find(substr) @@ -162,7 +160,6 @@ def func(st): run_udf_test(data, func, "int32") -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_endswith(data, substr): def func(st): return st.endswith(substr) @@ -233,7 +230,6 @@ def func(st): run_udf_test(data, func, "int64") -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", "", "gpu"]) def test_string_udf_rfind(data, substr): def func(st): return st.rfind(substr) @@ -241,7 +237,6 @@ def func(st): run_udf_test(data, func, "int32") -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc"]) def test_string_udf_startswith(data, substr): def func(st): return st.startswith(substr) From 9eb3bfd9604d7e442755f25e9df95e9572070fe1 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 21:45:33 -0700 Subject: [PATCH 142/212] Simplify binary func lowering. --- python/strings_udf/strings_udf/lowering.py | 68 ++++++---------------- 1 file changed, 19 insertions(+), 49 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index ac7ce269dde..36f020d73d0 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -162,7 +162,13 @@ def string_view_len_impl(context, builder, sig, args): return result -def create_binary_string_func(binary_func, signature): +def create_binary_string_func(binary_func, retty): + signature = ( + retty, + types.CPointer(string_view), + types.CPointer(string_view), + ) + def deco(cuda_func): @cuda_lower(binary_func, string_view, string_view) def binary_func_impl(context, builder, sig, args): @@ -185,98 +191,62 @@ def binary_func_impl(context, builder, sig, args): return deco -@create_binary_string_func( - operator.contains, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.contains, types.boolean) def string_view_contains_impl(st, substr): return _string_view_contains(st, substr) -@create_binary_string_func( - operator.eq, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.eq, types.boolean) def string_view_eq_impl(st, rhs): return _string_view_eq(st, rhs) -@create_binary_string_func( - operator.ne, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.ne, types.boolean) def string_view_ne_impl(st, rhs): return _string_view_ne(st, rhs) -@create_binary_string_func( - operator.ge, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.ge, types.boolean) def string_view_ge_impl(st, rhs): return _string_view_ge(st, rhs) -@create_binary_string_func( - operator.le, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.le, types.boolean) def string_view_le_impl(st, rhs): return _string_view_le(st, rhs) -@create_binary_string_func( - operator.gt, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.gt, types.boolean) def string_view_gt_impl(st, rhs): return _string_view_gt(st, rhs) -@create_binary_string_func( - operator.lt, - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func(operator.lt, types.boolean) def string_view_lt_impl(st, rhs): return _string_view_lt(st, rhs) -@create_binary_string_func( - "StringView.startswith", - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func("StringView.startswith", types.boolean) def string_view_startswith_impl(sv, substr): return _string_view_startswith(sv, substr) -@create_binary_string_func( - "StringView.endswith", - (types.boolean, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func("StringView.endswith", types.boolean) def string_view_endswith_impl(sv, substr): return _string_view_endswith(sv, substr) -@create_binary_string_func( - "StringView.count", - (size_type, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func("StringView.count", size_type) def string_view_count_impl(st, substr): return _string_view_count(st, substr) -@create_binary_string_func( - "StringView.find", - (size_type, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func("StringView.find", size_type) def string_view_find_impl(sv, substr): return _string_view_find(sv, substr) -@create_binary_string_func( - "StringView.rfind", - (size_type, types.CPointer(string_view), types.CPointer(string_view)), -) +@create_binary_string_func("StringView.rfind", size_type) def string_view_rfind_impl(sv, substr): return _string_view_rfind(sv, substr) From f0d3c90b013f12e412b9adb6cdb28caa2a377012 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 21:47:04 -0700 Subject: [PATCH 143/212] Pass signature params directly. --- python/strings_udf/strings_udf/lowering.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 36f020d73d0..e7ab187471b 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -163,12 +163,6 @@ def string_view_len_impl(context, builder, sig, args): def create_binary_string_func(binary_func, retty): - signature = ( - retty, - types.CPointer(string_view), - types.CPointer(string_view), - ) - def deco(cuda_func): @cuda_lower(binary_func, string_view, string_view) def binary_func_impl(context, builder, sig, args): @@ -180,7 +174,11 @@ def binary_func_impl(context, builder, sig, args): result = context.compile_internal( builder, cuda_func, - nb_signature(*signature), + nb_signature( + retty, + types.CPointer(string_view), + types.CPointer(string_view), + ), (lhs_ptr, rhs_ptr), ) From 2bce019a7e37db4054506a7b6ec87fd55df2e72c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 21:49:26 -0700 Subject: [PATCH 144/212] Define alias for CPointer to string_view. --- python/strings_udf/strings_udf/lowering.py | 58 ++++++++++------------ 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index e7ab187471b..af363ccc7b6 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -23,101 +23,101 @@ # a string_view whereas when a dstring is encountered, numba will convert it to # a view via its native view() method. +_STR_VIEW_PTR = types.CPointer(string_view) + # CUDA function declarations -_string_view_len = cuda.declare_device( - "len", size_type(types.CPointer(string_view)) -) +_string_view_len = cuda.declare_device("len", size_type(_STR_VIEW_PTR)) _string_view_contains = cuda.declare_device( "contains", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_eq = cuda.declare_device( "eq", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_ne = cuda.declare_device( "ne", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_ge = cuda.declare_device( "ge", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_le = cuda.declare_device( "le", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_gt = cuda.declare_device( "gt", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_lt = cuda.declare_device( "lt", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_startswith = cuda.declare_device( "startswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_endswith = cuda.declare_device( "endswith", - types.boolean(types.CPointer(string_view), types.CPointer(string_view)), + types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_find = cuda.declare_device( "find", - size_type(types.CPointer(string_view), types.CPointer(string_view)), + size_type(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_rfind = cuda.declare_device( "rfind", - size_type(types.CPointer(string_view), types.CPointer(string_view)), + size_type(_STR_VIEW_PTR, _STR_VIEW_PTR), ) _string_view_isdigit = cuda.declare_device( - "pyisdigit", types.boolean(types.CPointer(string_view), types.int64) + "pyisdigit", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_isalnum = cuda.declare_device( - "pyisalnum", types.boolean(types.CPointer(string_view), types.int64) + "pyisalnum", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_isalpha = cuda.declare_device( - "pyisalpha", types.boolean(types.CPointer(string_view), types.int64) + "pyisalpha", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_isdecimal = cuda.declare_device( - "pyisdecimal", types.boolean(types.CPointer(string_view), types.int64) + "pyisdecimal", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_isnumeric = cuda.declare_device( - "pyisnumeric", types.boolean(types.CPointer(string_view), types.int64) + "pyisnumeric", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_isspace = cuda.declare_device( - "pyisspace", types.boolean(types.CPointer(string_view), types.int64) + "pyisspace", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_isupper = cuda.declare_device( - "pyisupper", types.boolean(types.CPointer(string_view), types.int64) + "pyisupper", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_islower = cuda.declare_device( - "pyislower", types.boolean(types.CPointer(string_view), types.int64) + "pyislower", types.boolean(_STR_VIEW_PTR, types.int64) ) _string_view_count = cuda.declare_device( "pycount", - size_type(types.CPointer(string_view), types.CPointer(string_view)), + size_type(_STR_VIEW_PTR, _STR_VIEW_PTR), ) @@ -155,7 +155,7 @@ def string_view_len_impl(context, builder, sig, args): result = context.compile_internal( builder, call_len_string_view, - nb_signature(size_type, types.CPointer(string_view)), + nb_signature(size_type, _STR_VIEW_PTR), (sv_ptr,), ) @@ -174,11 +174,7 @@ def binary_func_impl(context, builder, sig, args): result = context.compile_internal( builder, cuda_func, - nb_signature( - retty, - types.CPointer(string_view), - types.CPointer(string_view), - ), + nb_signature(retty, _STR_VIEW_PTR, _STR_VIEW_PTR), (lhs_ptr, rhs_ptr), ) @@ -261,9 +257,7 @@ def id_func_impl(context, builder, sig, args): result = context.compile_internal( builder, cuda_func, - nb_signature( - types.boolean, types.CPointer(string_view), types.int64 - ), + nb_signature(types.boolean, _STR_VIEW_PTR, types.int64), (str_ptr, tbl_ptr), ) From 5fa1ccd370b1681602b95e7b5bc7876b8b250199 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 22:14:43 -0700 Subject: [PATCH 145/212] Some more boilerplate reduction. --- python/strings_udf/strings_udf/lowering.py | 106 +++++++-------------- 1 file changed, 33 insertions(+), 73 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index af363ccc7b6..8a0f6ccf760 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -1,6 +1,7 @@ # Copyright (c) 2022, NVIDIA CORPORATION. import operator +from functools import partial from numba import cuda, types from numba.core import cgutils @@ -29,91 +30,50 @@ # CUDA function declarations _string_view_len = cuda.declare_device("len", size_type(_STR_VIEW_PTR)) -_string_view_contains = cuda.declare_device( - "contains", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) - -_string_view_eq = cuda.declare_device( - "eq", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) -_string_view_ne = cuda.declare_device( - "ne", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) - -_string_view_ge = cuda.declare_device( - "ge", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) - -_string_view_le = cuda.declare_device( - "le", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) -_string_view_gt = cuda.declare_device( - "gt", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) - -_string_view_lt = cuda.declare_device( - "lt", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) -_string_view_startswith = cuda.declare_device( - "startswith", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) - -_string_view_endswith = cuda.declare_device( - "endswith", - types.boolean(_STR_VIEW_PTR, _STR_VIEW_PTR), -) +def _declare_binary_func(lhs, rhs, out, name): + # Declare a binary function + return cuda.declare_device( + name, + out(lhs, rhs), + ) -_string_view_find = cuda.declare_device( - "find", - size_type(_STR_VIEW_PTR, _STR_VIEW_PTR), -) -_string_view_rfind = cuda.declare_device( - "rfind", - size_type(_STR_VIEW_PTR, _STR_VIEW_PTR), +# A binary function of the form f(string, string) -> bool +_declare_bool_str_str_func = partial( + _declare_binary_func, _STR_VIEW_PTR, _STR_VIEW_PTR, types.boolean ) -_string_view_isdigit = cuda.declare_device( - "pyisdigit", types.boolean(_STR_VIEW_PTR, types.int64) -) +_string_view_contains = _declare_bool_str_str_func("contains") +_string_view_eq = _declare_bool_str_str_func("eq") +_string_view_ne = _declare_bool_str_str_func("ne") +_string_view_ge = _declare_bool_str_str_func("ge") +_string_view_le = _declare_bool_str_str_func("le") +_string_view_gt = _declare_bool_str_str_func("gt") +_string_view_lt = _declare_bool_str_str_func("lt") +_string_view_startswith = _declare_bool_str_str_func("startswith") +_string_view_endswith = _declare_bool_str_str_func("endswith") +_string_view_find = _declare_bool_str_str_func("find") +_string_view_rfind = _declare_bool_str_str_func("rfind") +_string_view_contains = _declare_bool_str_str_func("contains") -_string_view_isalnum = cuda.declare_device( - "pyisalnum", types.boolean(_STR_VIEW_PTR, types.int64) -) -_string_view_isalpha = cuda.declare_device( - "pyisalpha", types.boolean(_STR_VIEW_PTR, types.int64) +# A binary function of the form f(string, int) -> bool +_declare_bool_str_int_func = partial( + _declare_binary_func, _STR_VIEW_PTR, types.int64, types.boolean ) -_string_view_isdecimal = cuda.declare_device( - "pyisdecimal", types.boolean(_STR_VIEW_PTR, types.int64) -) -_string_view_isnumeric = cuda.declare_device( - "pyisnumeric", types.boolean(_STR_VIEW_PTR, types.int64) -) - -_string_view_isspace = cuda.declare_device( - "pyisspace", types.boolean(_STR_VIEW_PTR, types.int64) -) +_string_view_isdigit = _declare_bool_str_int_func("pyisdigit") +_string_view_isalnum = _declare_bool_str_int_func("pypyisalnum") +_string_view_isalpha = _declare_bool_str_int_func("pypyisalpha") +_string_view_isdecimal = _declare_bool_str_int_func("pypyisdecimal") +_string_view_isnumeric = _declare_bool_str_int_func("pypyisnumeric") +_string_view_isspace = _declare_bool_str_int_func("pypyisspace") +_string_view_isupper = _declare_bool_str_int_func("pypyisupper") +_string_view_islower = _declare_bool_str_int_func("pypyislower") -_string_view_isupper = cuda.declare_device( - "pyisupper", types.boolean(_STR_VIEW_PTR, types.int64) -) - -_string_view_islower = cuda.declare_device( - "pyislower", types.boolean(_STR_VIEW_PTR, types.int64) -) _string_view_count = cuda.declare_device( "pycount", From 3db5b9176353c57ca45b2a22b7b56d88ee0beb8b Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 22:22:30 -0700 Subject: [PATCH 146/212] Remove one more unnecessary file. --- .../cudf/strings/detail/convert/integers.cuh | 63 ------------------- 1 file changed, 63 deletions(-) delete mode 100644 python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh diff --git a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh b/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh deleted file mode 100644 index 5727cc40471..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/detail/convert/integers.cuh +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#pragma once - -#include - -#include -#include - -namespace cudf { -namespace strings { -namespace detail { - -/** - * Copied from cudf/cpp/include/cudf/strings/detail/convert/int_to_string.cuh - * Dependencies there cannot be compiled by jitify. - */ -template -__device__ inline size_type integer_to_string(IntegerType value, char* d_buffer) -{ - if (value == 0) { - *d_buffer = '0'; - return 1; - } - bool const is_negative = std::is_signed() ? (value < 0) : false; - - constexpr IntegerType base = 10; - // largest 64-bit integer is 20 digits; largest 128-bit integer is 39 digits - constexpr int MAX_DIGITS = std::numeric_limits::digits10 + 1; - char digits[MAX_DIGITS]; // place-holder for digit chars - int digits_idx = 0; - while (value != 0) { - assert(digits_idx < MAX_DIGITS); - digits[digits_idx++] = '0' + abs(value % base); - // next digit - value = value / base; - } - size_type const bytes = digits_idx + static_cast(is_negative); - - char* ptr = d_buffer; - if (is_negative) *ptr++ = '-'; - // digits are backwards, reverse the string into the output - while (digits_idx-- > 0) - *ptr++ = digits[digits_idx]; - return bytes; -} - -} // namespace detail -} // namespace strings -} // namespace cudf From acadf53649c595fde62f60053e8a40431fa4a855 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 22:51:37 -0700 Subject: [PATCH 147/212] Remove extra new line. --- python/cudf/cudf/core/udf/strings_typing.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 9b5647bd133..b436c2d2eaa 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -1,6 +1,5 @@ # Copyright (c) 2022, NVIDIA CORPORATION. - import operator from numba import types From c945aa1d3b30a82b193090813cb81c171dafd9f4 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Fri, 9 Sep 2022 23:06:33 -0700 Subject: [PATCH 148/212] Minor CMake cleanup. --- python/strings_udf/cpp/CMakeLists.txt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 203bce72123..89908698c4c 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -17,7 +17,6 @@ cmake_minimum_required(VERSION 3.20.1) include(rapids-cmake) include(rapids-cpm) include(rapids-cuda) -include(rapids-export) include(rapids-find) rapids_cpm_init() @@ -42,12 +41,7 @@ rapids_find_package( ) include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) -rapids_cpm_libcudacxx(BUILD_EXPORT_SET cudf-exports INSTALL_EXPORT_SET cudf-exports) - -set(UDF_CXX_FLAGS "") -set(UDF_CUDA_FLAGS "") - -list(APPEND UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) +rapids_cpm_libcudacxx(BUILD_EXPORT_SET strings-udf-exports INSTALL_EXPORT_SET strings-udf-exports) add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) target_include_directories(cudf_strings_udf PUBLIC include) @@ -62,9 +56,10 @@ set_target_properties( CUDA_STANDARD_REQUIRED ON POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON - PUBLIC_HEADER "include/cudf/strings/udf/udf_apis.hpp" ) +set(UDF_CXX_FLAGS) +set(UDF_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) target_compile_options( cudf_strings_udf PRIVATE "$<$:${UDF_CXX_FLAGS}>" "$<$:${UDF_CUDA_FLAGS}>" From a8b6cf470e3e0723cdbd454918260100f4ab753b Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:01:04 -0400 Subject: [PATCH 149/212] update copyright Co-authored-by: Vyas Ramasubramani --- python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp index 2d13b2c03e5..7b64e43b056 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 17598d6e6e2293131eb5808f47721d19e058f476 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 07:02:58 -0700 Subject: [PATCH 150/212] fix small bugs in cuda function declarations --- python/strings_udf/strings_udf/lowering.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 8a0f6ccf760..610e8f7062e 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -66,13 +66,13 @@ def _declare_binary_func(lhs, rhs, out, name): _string_view_isdigit = _declare_bool_str_int_func("pyisdigit") -_string_view_isalnum = _declare_bool_str_int_func("pypyisalnum") -_string_view_isalpha = _declare_bool_str_int_func("pypyisalpha") -_string_view_isdecimal = _declare_bool_str_int_func("pypyisdecimal") -_string_view_isnumeric = _declare_bool_str_int_func("pypyisnumeric") -_string_view_isspace = _declare_bool_str_int_func("pypyisspace") -_string_view_isupper = _declare_bool_str_int_func("pypyisupper") -_string_view_islower = _declare_bool_str_int_func("pypyislower") +_string_view_isalnum = _declare_bool_str_int_func("pyisalnum") +_string_view_isalpha = _declare_bool_str_int_func("pyisalpha") +_string_view_isdecimal = _declare_bool_str_int_func("pyisdecimal") +_string_view_isnumeric = _declare_bool_str_int_func("pyisnumeric") +_string_view_isspace = _declare_bool_str_int_func("pyisspace") +_string_view_isupper = _declare_bool_str_int_func("pyisupper") +_string_view_islower = _declare_bool_str_int_func("pyislower") _string_view_count = cuda.declare_device( From 7c55deb20b0727cb97b7f07a3e246dac55a49392 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 07:04:11 -0700 Subject: [PATCH 151/212] rework __init__ such that a CPU machine may import strings_udf --- python/strings_udf/strings_udf/__init__.py | 51 ++++++++++++++-------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index b398fca871c..b48da082f8e 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -9,8 +9,11 @@ from numba import cuda +ENABLED = False +ptxpath = None -def versions_compatible(path): + +def compiler_from_ptx_file(path): """ Example PTX header: @@ -20,35 +23,47 @@ def versions_compatible(path): // Cuda compilation tools, release 11.5, V11.5.119 // Based on NVVM 7 """ - # obtain the cuda version used to compile this PTX file file = open(path).read() major, minor = ( re.search(r"Cuda compilation tools, release ([0-9\.]+)", file) .group(1) .split(".") ) + return int(major), int(minor) - # adapted from patch_needed() - cp = subprocess.run([sys.executable, "-c", CMD], capture_output=True) - if cp.returncode != 0: - # no driver - return False +# adapted from PTXCompiler +cp = subprocess.run([sys.executable, "-c", CMD], capture_output=True) +if cp.returncode == 0: + # must have a driver to proceed versions = [int(s) for s in cp.stdout.strip().split()] driver_version = tuple(versions[:2]) + runtime_version = tuple(versions[2:]) - return driver_version >= (int(major), int(minor)) and not patch_needed() - + # CUDA enhanced compatibility not yet enabled + if driver_version >= runtime_version: + # Load the highest compute capability file available that is less than the + # current device's. + files = glob.glob( + os.path.join(os.path.dirname(__file__), "shim_*.ptx") + ) + dev = cuda.get_current_device() + cc = "".join(str(x) for x in dev.compute_capability) + files = glob.glob( + os.path.join(os.path.dirname(__file__), "shim_*.ptx") + ) + sms = [ + os.path.basename(f).rstrip(".ptx").lstrip("shim_") for f in files + ] + selected_sm = max(sm for sm in sms if sm < cc) + ptxpath = os.path.join( + os.path.dirname(__file__), f"shim_{selected_sm}.ptx" + ) -# Load the highest compute capability file available that is less than the -# current device's. -dev = cuda.get_current_device() -cc = "".join(str(x) for x in dev.compute_capability) -files = glob.glob(os.path.join(os.path.dirname(__file__), "shim_*.ptx")) -sms = [os.path.basename(f).rstrip(".ptx").lstrip("shim_") for f in files] -selected_sm = max(sm for sm in sms if sm < cc) -ptxpath = os.path.join(os.path.dirname(__file__), f"shim_{selected_sm}.ptx") + if driver_version >= compiler_from_ptx_file(ptxpath): + ENABLED = True -ENABLED = versions_compatible(ptxpath) +if not ENABLED: + del ptxpath __version__ = _version.get_versions()["version"] From 5ab660d5977c719888f8e99b741fa55ffc15dd32 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:05:41 -0400 Subject: [PATCH 152/212] Fix return calculation for zero-length target in count() --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index 1ee6c778b22..7f701d460c9 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -38,11 +38,12 @@ __device__ inline cudf::size_type count(string_view const source, { auto const tgt_length = target.length(); auto const src_length = source.length(); - if (tgt_length == 0) return src_length + 1; start = start < 0 ? 0 : start; end = (end < 0 || end > src_length) ? src_length : end; + if (tgt_length == 0) { return (end - start) + 1; } + cudf::size_type count = 0; cudf::size_type pos = start; while (pos != cudf::string_view::npos) { From 6f67b697fe3e11839ccdfd135cc44242280a9970 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 07:09:52 -0700 Subject: [PATCH 153/212] find and rfind return size_type --- python/strings_udf/strings_udf/lowering.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 610e8f7062e..df2c921456a 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -44,6 +44,9 @@ def _declare_binary_func(lhs, rhs, out, name): _declare_binary_func, _STR_VIEW_PTR, _STR_VIEW_PTR, types.boolean ) +_declare_size_type_str_str_func = partial( + _declare_binary_func, _STR_VIEW_PTR, _STR_VIEW_PTR, size_type +) _string_view_contains = _declare_bool_str_str_func("contains") _string_view_eq = _declare_bool_str_str_func("eq") @@ -54,8 +57,8 @@ def _declare_binary_func(lhs, rhs, out, name): _string_view_lt = _declare_bool_str_str_func("lt") _string_view_startswith = _declare_bool_str_str_func("startswith") _string_view_endswith = _declare_bool_str_str_func("endswith") -_string_view_find = _declare_bool_str_str_func("find") -_string_view_rfind = _declare_bool_str_str_func("rfind") +_string_view_find = _declare_size_type_str_str_func("find") +_string_view_rfind = _declare_size_type_str_str_func("rfind") _string_view_contains = _declare_bool_str_str_func("contains") From 3be55cb03c230015c0866349e645c51cfbf48171 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 07:11:01 -0700 Subject: [PATCH 154/212] add ptx files in the strings_udf directory to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c8f02da027d..b80676fac2f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ python/cudf_kafka/*/_lib/**/*.h python/custreamz/*/_lib/**/*\.cpp python/custreamz/*/_lib/**/*.h python/strings_udf/strings_udf/_lib/*.cpp +python/strings_udf/strings_udf/*.ptx .Python env/ develop-eggs/ From 9aaea65c9fd87b73ec010df296c73f42ee084a34 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Mon, 12 Sep 2022 10:30:50 -0400 Subject: [PATCH 155/212] Fix style check --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 1 - 1 file changed, 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index 7f701d460c9..670c29132a4 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -43,7 +43,6 @@ __device__ inline cudf::size_type count(string_view const source, end = (end < 0 || end > src_length) ? src_length : end; if (tgt_length == 0) { return (end - start) + 1; } - cudf::size_type count = 0; cudf::size_type pos = start; while (pos != cudf::string_view::npos) { From 4ed60fb3b7a70eddbceb9a85096b7b4fef30fdcc Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 09:34:06 -0700 Subject: [PATCH 156/212] pass rather than raise if no strings_udf --- python/cudf/cudf/core/udf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index 2daa5dfcd78..bce12c8bb16 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -59,6 +59,6 @@ except ImportError as e: # allow cuDF to work without strings_udf - raise + pass masked_typing.register_masked_constructor(supported_masked_types) From 3acc7212890665630df8bc883e822a7993465207 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 11:51:39 -0700 Subject: [PATCH 157/212] skip strings_udf tests in library if not enabled --- python/strings_udf/strings_udf/tests/test_string_udfs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index 29d1b0a8b88..ef437805709 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -11,10 +11,14 @@ import cudf from cudf.testing._utils import assert_eq +import strings_udf from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view +if not strings_udf.ENABLED: + pytest.skip("Strings UDF not enabled.", allow_module_level=True) + def get_kernel(func, dtype): """ From b70e5a0ee27b7ec050ffd7a0bbd6868cbb4bf51e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 11:52:07 -0700 Subject: [PATCH 158/212] debug print to find why files are not being found --- python/strings_udf/strings_udf/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index b48da082f8e..c52e3c4f1b7 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -47,6 +47,10 @@ def compiler_from_ptx_file(path): files = glob.glob( os.path.join(os.path.dirname(__file__), "shim_*.ptx") ) + print("DEBUG strings_udf: files globbed:") + print(files) + print("DEBUG strings_udf: path searched:") + print(os.path.dirname(__file__)) dev = cuda.get_current_device() cc = "".join(str(x) for x in dev.compute_capability) files = glob.glob( From 325abb6a27619aba2c11a724ec6a4c9248f57857 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 12 Sep 2022 15:52:13 -0700 Subject: [PATCH 159/212] Run tests from inside the strings_udf directory. --- ci/gpu/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index c3d0573231d..2630b1b3887 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -247,9 +247,9 @@ cd "$WORKSPACE/python/custreamz" gpuci_logger "Python py.test for cuStreamz" py.test -n 8 --cache-clear --basetemp="$WORKSPACE/custreamz-cuda-tmp" --junitxml="$WORKSPACE/junit-custreamz.xml" -v --cov-config=.coveragerc --cov=custreamz --cov-report=xml:"$WORKSPACE/python/custreamz/custreamz-coverage.xml" --cov-report term custreamz -cd "$WORKSPACE/python/strings_udf" +cd "$WORKSPACE/python/strings_udf/strings_udf" gpuci_logger "Python py.test for strings_udf" -py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term strings_udf +py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term tests # Run benchmarks with both cudf and pandas to ensure compatibility is maintained. From e145105ba6aab6f9473abd1941a402f06abe59ce Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 12 Sep 2022 15:52:28 -0700 Subject: [PATCH 160/212] Remove __init__ file that could be causing file traversal. --- python/strings_udf/strings_udf/tests/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 python/strings_udf/strings_udf/tests/__init__.py diff --git a/python/strings_udf/strings_udf/tests/__init__.py b/python/strings_udf/strings_udf/tests/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 From 12abaf034bc834a6b9aadb0159aa3d89cf3eb3cd Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 12 Sep 2022 15:53:43 -0700 Subject: [PATCH 161/212] Add extra debug print. --- python/strings_udf/strings_udf/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index c52e3c4f1b7..e1c8d568121 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -47,10 +47,12 @@ def compiler_from_ptx_file(path): files = glob.glob( os.path.join(os.path.dirname(__file__), "shim_*.ptx") ) - print("DEBUG strings_udf: files globbed:") - print(files) print("DEBUG strings_udf: path searched:") print(os.path.dirname(__file__)) + print("DEBUG strings_udf: All files in path:") + print(os.listdir(os.path.dirname(__file__))) + print("DEBUG strings_udf: files globbed:") + print(files) dev = cuda.get_current_device() cc = "".join(str(x) for x in dev.compute_capability) files = glob.glob( From 3fbc85b2d24fae968ea2d3fd0f513c92f12c8e55 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 12 Sep 2022 18:00:53 -0700 Subject: [PATCH 162/212] Clean up debug prints and remove unused patch_needed import. --- python/strings_udf/strings_udf/__init__.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index e1c8d568121..84bb8db2ab6 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,5 +1,5 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from ptxcompiler.patch import patch_needed, CMD +from ptxcompiler.patch import CMD import glob import os import sys @@ -47,12 +47,6 @@ def compiler_from_ptx_file(path): files = glob.glob( os.path.join(os.path.dirname(__file__), "shim_*.ptx") ) - print("DEBUG strings_udf: path searched:") - print(os.path.dirname(__file__)) - print("DEBUG strings_udf: All files in path:") - print(os.listdir(os.path.dirname(__file__))) - print("DEBUG strings_udf: files globbed:") - print(files) dev = cuda.get_current_device() cc = "".join(str(x) for x in dev.compute_capability) files = glob.glob( From 52e686cec0a18ae7de7a05132acc9ac4201cdd10 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 18:01:03 -0700 Subject: [PATCH 163/212] only add object to types if strings_udf is enabled --- python/cudf/cudf/core/udf/__init__.py | 2 ++ python/cudf/cudf/core/udf/utils.py | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index bce12c8bb16..eb36dceff02 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -10,6 +10,7 @@ from cudf.core.udf import utils from cudf.core.udf import row_function from cudf.core.dtypes import dtype +from cudf.utils.dtypes import STRING_TYPES import numpy as np units = ["ns", "ms", "us", "s"] @@ -49,6 +50,7 @@ supported_masked_types |= {strings_typing.string_view} utils.launch_arg_getters[dtype("O")] = to_string_view_array utils.masked_array_types[dtype("O")] = string_view + utils.JIT_SUPPORTED_TYPES |= STRING_TYPES utils.files.append(ptxpath) utils.arg_handlers.append(str_view_arg_handler) row_function.itemsizes[dtype("O")] = string_view.size_bytes diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 7ff24f2476e..8844c8325c2 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -18,17 +18,12 @@ BOOL_TYPES, DATETIME_TYPES, NUMERIC_TYPES, - STRING_TYPES, TIMEDELTA_TYPES, ) from cudf.utils.utils import _cudf_nvtx_annotate JIT_SUPPORTED_TYPES = ( - NUMERIC_TYPES - | BOOL_TYPES - | DATETIME_TYPES - | TIMEDELTA_TYPES - | STRING_TYPES + NUMERIC_TYPES | BOOL_TYPES | DATETIME_TYPES | TIMEDELTA_TYPES ) libcudf_bitmask_type = numpy_support.from_dtype(np.dtype("int32")) MASK_BITSIZE = np.dtype("int32").itemsize * 8 @@ -152,6 +147,7 @@ def _construct_signature(frame, return_type, args): return_type = Tuple((return_type[::1], boolean[::1])) offsets = [] sig = [return_type, int64] + breakpoint() for col in _supported_cols_from_frame(frame).values(): sig.append(_masked_array_type_from_col(col)) offsets.append(int64) From faf4878d87a82ab11d37c7ca45be4c1fc2f439f1 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 18:03:29 -0700 Subject: [PATCH 164/212] add strings_udf to cudf conda recipe --- conda/recipes/cudf/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index 6a7554b99aa..803642b5149 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -54,6 +54,7 @@ requirements: - numpy - {{ pin_compatible('pyarrow', max_pin='x.x.x') }} - libcudf {{ version }} + - strings_udf ={{ version }} - fastavro >=0.22.0 - {{ pin_compatible('rmm', max_pin='x.x') }} - fsspec>=0.6.0 From 36f41f6455bdfba9cadcf9799d7fde69886d2bb9 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 12 Sep 2022 18:04:33 -0700 Subject: [PATCH 165/212] cleanup --- python/cudf/cudf/core/udf/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 8844c8325c2..9f5d84d9f6b 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -147,7 +147,6 @@ def _construct_signature(frame, return_type, args): return_type = Tuple((return_type[::1], boolean[::1])) offsets = [] sig = [return_type, int64] - breakpoint() for col in _supported_cols_from_frame(frame).values(): sig.append(_masked_array_type_from_col(col)) offsets.append(int64) From 7ac5b7eab7ef778f13ecc2b1f17389cff599a8d4 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 12 Sep 2022 20:14:09 -0700 Subject: [PATCH 166/212] Remove cudf from strings_udf requirements. --- conda/recipes/strings_udf/meta.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index 0e9d8c56bda..ae5e20f7cf4 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -39,7 +39,6 @@ requirements: - setuptools - numba >=0.54 - libcudf ={{ version }} - - cudf ={{ version }} - cudatoolkit ={{ cuda_version }} run: - python @@ -47,7 +46,6 @@ requirements: - numba >=0.54 - numpy - libcudf {{ version }} - - cudf ={{ version }} - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - cachetools - ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler From 65496686b95ac59a483a8eab1fbd177c470b8103 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 13 Sep 2022 06:30:09 -0700 Subject: [PATCH 167/212] go back to an optional dependency --- conda/recipes/cudf/meta.yaml | 1 - conda/recipes/strings_udf/meta.yaml | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conda/recipes/cudf/meta.yaml b/conda/recipes/cudf/meta.yaml index 803642b5149..6a7554b99aa 100644 --- a/conda/recipes/cudf/meta.yaml +++ b/conda/recipes/cudf/meta.yaml @@ -54,7 +54,6 @@ requirements: - numpy - {{ pin_compatible('pyarrow', max_pin='x.x.x') }} - libcudf {{ version }} - - strings_udf ={{ version }} - fastavro >=0.22.0 - {{ pin_compatible('rmm', max_pin='x.x') }} - fsspec>=0.6.0 diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index ae5e20f7cf4..3d6158f39f3 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -39,13 +39,15 @@ requirements: - setuptools - numba >=0.54 - libcudf ={{ version }} + - cudf = {{ version }} - cudatoolkit ={{ cuda_version }} run: - python - typing_extensions - numba >=0.54 - numpy - - libcudf {{ version }} + - libcudf ={{ version }} + - cudf ={{ version }} - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - cachetools - ptxcompiler # [linux64] # CUDA enhanced compatibility. See https://github.com/rapidsai/ptxcompiler From a7afe7a52dc0d770f3ec2c4fb9544188de92b982 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 13 Sep 2022 07:11:44 -0700 Subject: [PATCH 168/212] fix yaml error --- conda/recipes/strings_udf/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/strings_udf/meta.yaml b/conda/recipes/strings_udf/meta.yaml index 3d6158f39f3..e29fb55ce63 100644 --- a/conda/recipes/strings_udf/meta.yaml +++ b/conda/recipes/strings_udf/meta.yaml @@ -39,7 +39,7 @@ requirements: - setuptools - numba >=0.54 - libcudf ={{ version }} - - cudf = {{ version }} + - cudf ={{ version }} - cudatoolkit ={{ cuda_version }} run: - python From 69813de4a5245c7247775efb9d1e055fffefc721 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 13 Sep 2022 09:21:17 -0700 Subject: [PATCH 169/212] dont directly import ptxpath in tests --- python/strings_udf/strings_udf/tests/test_string_udfs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index ef437805709..84e6f8148a3 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -12,7 +12,6 @@ from cudf.testing._utils import assert_eq import strings_udf -from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view @@ -32,7 +31,9 @@ def get_kernel(func, dtype): outty = numba.np.numpy_support.from_dtype(dtype) sig = nb_signature(void, CPointer(string_view), outty[::1]) - @cuda.jit(sig, link=[ptxpath], extensions=[str_view_arg_handler]) + @cuda.jit( + sig, link=[strings_udf.ptxpath], extensions=[str_view_arg_handler] + ) def kernel(input_strings, output_col): id = cuda.grid(1) if id < len(output_col): From 18bd4bcd2b69ee6969369af9be418aa9c1ff84bf Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 11:33:50 -0700 Subject: [PATCH 170/212] Enable flake8 again. --- .pre-commit-config.yaml | 1 - python/strings_udf/versioneer.py | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29cc0e5396d..4f838ba3f45 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,6 @@ repos: args: ["--config=setup.cfg"] files: python/.*\.(py|pyx|pxd)$ types: [file] - exclude: python/.*/versioneer.py - repo: https://github.com/pre-commit/mirrors-mypy rev: 'v0.782' hooks: diff --git a/python/strings_udf/versioneer.py b/python/strings_udf/versioneer.py index d9e2d619cc3..6194b6a5698 100644 --- a/python/strings_udf/versioneer.py +++ b/python/strings_udf/versioneer.py @@ -792,7 +792,8 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command): pieces["distance"] = len(out.split()) # total number of commits # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = runner(GITS, ["show", "-s", "--format=%%ci", "HEAD"], cwd=root)[0].strip() + date = runner(GITS, ["show", "-s", "--format=%%ci", "HEAD"], + cwd=root)[0].strip() # Use only the last line. Previous lines may contain GPG signature # information. date = date.splitlines()[-1] @@ -882,10 +883,14 @@ def render_pep440_pre(pieces): if pieces["closest-tag"]: if pieces["distance"]: # update the post release segment - tag_version, post_version = pep440_split_post(pieces["closest-tag"]) + tag_version, post_version = pep440_split_post( + pieces["closest-tag"] + ) rendered = tag_version if post_version is not None: - rendered += ".post%%d.dev%%d" %% (post_version + 1, pieces["distance"]) + rendered += ".post%%d.dev%%d" %% ( + post_version + 1, pieces["distance"] + ) else: rendered += ".post0.dev%%d" %% (pieces["distance"]) else: @@ -1834,7 +1839,8 @@ def get_cmdclass(cmdclass=None): # parent is protected against the child's "import versioneer". By # removing ourselves from sys.modules here, before the child build # happens, we protect the child from the parent's versioneer too. - # Also see https://github.com/python-versioneer/python-versioneer/issues/52 + # Also see + # https://github.com/python-versioneer/python-versioneer/issues/52 cmds = {} if cmdclass is None else cmdclass.copy() @@ -1933,8 +1939,8 @@ def run(self): if not os.path.exists(target_versionfile): print( f"Warning: {target_versionfile} does not exist, skipping " - "version update. This can happen if you are running build_ext " - "without first running build_py." + "version update. This can happen if you are running " + "build_ext without first running build_py." ) return print("UPDATING %s" % target_versionfile) From c71c2dd5bb276803b7b39a18b3425f4ea94f9c23 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 12:05:52 -0700 Subject: [PATCH 171/212] Don't return a nonzero exit status when strings_udf tests are all skipped. --- ci/gpu/build.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 2630b1b3887..973d71e2fb8 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -249,8 +249,29 @@ py.test -n 8 --cache-clear --basetemp="$WORKSPACE/custreamz-cuda-tmp" --junitxml cd "$WORKSPACE/python/strings_udf/strings_udf" gpuci_logger "Python py.test for strings_udf" -py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term tests +# This helper function runs the strings_udf tests but ensures that we do not +# return a nonzero exit code in the case where no tests are run because that +# will always happen when the local CUDA version is not 11.5. We need to +# suppress the exit code because this script is run with set -e and we're +# already setting a trap that we don't want to override here. +function run_strings_udf_test() { + py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term tests + + local err=$?; + if [ ${err} -eq 5 ]; then + STRING_UDF_TEST_RUN=0; + return 0; + else + STRING_UDF_TEST_RUN=1; + return ${err}; + fi +} +run_strings_udf_test + +if [ ${STRING_UDF_TEST_RUN} -eq 0 ]; then + echo "No strings UDF tests were run, but this script will continue to execute." +fi # Run benchmarks with both cudf and pandas to ensure compatibility is maintained. # Benchmarks are run in DEBUG_ONLY mode, meaning that only small data sizes are used. From 5b585c72659eaa599ff47b0f766a092b4bec2416 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 12:31:51 -0700 Subject: [PATCH 172/212] Simplify declaration of lowering functions. --- python/cudf/cudf/core/udf/strings_lowering.py | 103 ++++++------------ 1 file changed, 32 insertions(+), 71 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index e1d8ecee4cb..7b6ee2b729a 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -9,33 +9,33 @@ from strings_udf._typing import size_type, string_view from strings_udf.lowering import ( - string_view_contains_impl, - string_view_count_impl, - string_view_endswith_impl, - string_view_find_impl, - string_view_isalnum_impl, - string_view_isalpha_impl, - string_view_isdecimal_impl, - string_view_isdigit_impl, - string_view_islower_impl, - string_view_isspace_impl, - string_view_isupper_impl, - string_view_len_impl, - string_view_rfind_impl, - string_view_startswith_impl, + contains_impl, + count_impl, + endswith_impl, + find_impl, + isalnum_impl, + isalpha_impl, + isdecimal_impl, + isdigit_impl, + islower_impl, + isspace_impl, + isupper_impl, + len_impl, + rfind_impl, + startswith_impl, ) from cudf.core.udf.masked_typing import MaskedType @cuda_lower(len, MaskedType(string_view)) -def masked_string_view_len_impl(context, builder, sig, args): +def masked_len_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_sv_ty = sig.args[0] masked_sv = cgutils.create_struct_proxy(masked_sv_ty)( context, builder, value=args[0] ) - result = string_view_len_impl( + result = len_impl( context, builder, size_type(string_view), (masked_sv.value,) ) ret.value = result @@ -44,7 +44,7 @@ def masked_string_view_len_impl(context, builder, sig, args): return ret._getvalue() -def create_binary_string_func(op, cuda_func, signature): +def create_binary_string_func(op, cuda_func, retty): def masked_binary_func_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) @@ -58,7 +58,7 @@ def masked_binary_func_impl(context, builder, sig, args): result = cuda_func( context, builder, - nb_signature(*signature), + nb_signature(retty, string_view, string_view), (lhs_masked.value, rhs_masked.value), ) @@ -74,39 +74,14 @@ def masked_binary_func_impl(context, builder, sig, args): create_binary_string_func( "MaskedType.startswith", - string_view_startswith_impl, - (types.boolean, string_view, string_view), -) - -create_binary_string_func( - "MaskedType.endswith", - string_view_endswith_impl, - (types.boolean, string_view, string_view), -) - -create_binary_string_func( - "MaskedType.find", - string_view_find_impl, - (size_type, string_view, string_view), -) - -create_binary_string_func( - "MaskedType.rfind", - string_view_rfind_impl, - (size_type, string_view, string_view), -) - -create_binary_string_func( - "MaskedType.count", - string_view_count_impl, - (size_type, string_view, string_view), -) - -create_binary_string_func( - operator.contains, - string_view_contains_impl, - (types.boolean, string_view, string_view), + startswith_impl, + types.boolean, ) +create_binary_string_func("MaskedType.endswith", endswith_impl, types.boolean) +create_binary_string_func("MaskedType.find", find_impl, size_type) +create_binary_string_func("MaskedType.rfind", rfind_impl, size_type) +create_binary_string_func("MaskedType.count", count_impl, size_type) +create_binary_string_func(operator.contains, contains_impl, types.boolean) def create_masked_unary_identifier_func(op, cuda_func): @@ -129,24 +104,10 @@ def masked_unary_func_impl(context, builder, sig, args): cuda_lower(op, MaskedType(string_view))(masked_unary_func_impl) -create_masked_unary_identifier_func( - "MaskedType.isalnum", string_view_isalnum_impl -) -create_masked_unary_identifier_func( - "MaskedType.isalpha", string_view_isalpha_impl -) -create_masked_unary_identifier_func( - "MaskedType.isdigit", string_view_isdigit_impl -) -create_masked_unary_identifier_func( - "MaskedType.isupper", string_view_isupper_impl -) -create_masked_unary_identifier_func( - "MaskedType.islower", string_view_islower_impl -) -create_masked_unary_identifier_func( - "MaskedType.isspace", string_view_isspace_impl -) -create_masked_unary_identifier_func( - "MaskedType.isdecimal", string_view_isdecimal_impl -) +create_masked_unary_identifier_func("MaskedType.isalnum", isalnum_impl) +create_masked_unary_identifier_func("MaskedType.isalpha", isalpha_impl) +create_masked_unary_identifier_func("MaskedType.isdigit", isdigit_impl) +create_masked_unary_identifier_func("MaskedType.isupper", isupper_impl) +create_masked_unary_identifier_func("MaskedType.islower", islower_impl) +create_masked_unary_identifier_func("MaskedType.isspace", isspace_impl) +create_masked_unary_identifier_func("MaskedType.isdecimal", isdecimal_impl) From b86d44e99648fb7d18ed1bf58d6435713691a8be Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 13 Sep 2022 13:00:16 -0700 Subject: [PATCH 173/212] retest with strings_udf after initial tests --- ci/gpu/build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 973d71e2fb8..ea5a0fce1a7 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -180,8 +180,8 @@ else # but because there is no separate python package, we must also build the python on the 11.5 jobs # this means that at this point (on the GPU test jobs) the whole package is already built and has been # copied by CI from the upstream 11.5 jobs into $CONDA_ARTIFACT_PATH - gpuci_logger "Installing cudf, dask-cudf, cudf_kafka, custreamz, and strings_udf" - gpuci_mamba_retry install cudf dask-cudf cudf_kafka custreamz strings_udf -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" + gpuci_logger "Installing cudf, dask-cudf, cudf_kafka, and custreamz" + gpuci_mamba_retry install cudf dask-cudf cudf_kafka custreamz -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" gpuci_logger "GoogleTests" # Run libcudf and libcudf_kafka gtests from libcudf-tests package @@ -247,6 +247,9 @@ cd "$WORKSPACE/python/custreamz" gpuci_logger "Python py.test for cuStreamz" py.test -n 8 --cache-clear --basetemp="$WORKSPACE/custreamz-cuda-tmp" --junitxml="$WORKSPACE/junit-custreamz.xml" -v --cov-config=.coveragerc --cov=custreamz --cov-report=xml:"$WORKSPACE/python/custreamz/custreamz-coverage.xml" --cov-report term custreamz +gpuci_logger "Installing strings_udf" +gpuci_mamba_retry install strings_udf -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT_PATH}" + cd "$WORKSPACE/python/strings_udf/strings_udf" gpuci_logger "Python py.test for strings_udf" @@ -273,6 +276,11 @@ if [ ${STRING_UDF_TEST_RUN} -eq 0 ]; then echo "No strings UDF tests were run, but this script will continue to execute." fi +cd "$WORKSPACE/python/cudf/cudf" +gpuci_logger "Python py.test retest cuDF UDFs" +py.test tests/test_udf_masked_ops.py -n 8 --cache-clear + + # Run benchmarks with both cudf and pandas to ensure compatibility is maintained. # Benchmarks are run in DEBUG_ONLY mode, meaning that only small data sizes are used. # Therefore, these runs only verify that benchmarks are valid. From dadbaa47a6edf666a02ae2258bcc5bbe4b2a71eb Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:01:41 -0700 Subject: [PATCH 174/212] Use more fixtures for the test. --- python/cudf/cudf/tests/test_udf_masked_ops.py | 121 +++++++++--------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index d4de1a1557a..b30becda6be 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -31,33 +31,39 @@ def string_udf_test(f): return pytest.mark.skip(reason="String UDFs not enabled")(f) -string_data = [ - "abc", - "ABC", - "AbC", - "123", - "123aBc", - "123@.!", - "", - "rapids ai", - "gpu", - "True", - "False", - "1.234", - ".123a", - "0.013", - "1.0", - "01", - "20010101", - "cudf", - "cuda", - "gpu", -] +@pytest.fixture(scope="module") +def str_udf_data(): + return cudf.DataFrame( + { + "str_col": [ + "abc", + "ABC", + "AbC", + "123", + "123aBc", + "123@.!", + "", + "rapids ai", + "gpu", + "True", + "False", + "1.234", + ".123a", + "0.013", + "1.0", + "01", + "20010101", + "cudf", + "cuda", + "gpu", + ] + } + ) -@pytest.fixture(scope="module") -def str_data(): - return cudf.DataFrame({"str_col": string_data}) +@pytest.fixture(params=["a", "cu", "2", "gpu", "", " "]) +def substr(request): + return request.param def run_masked_udf_test(func, data, args=(), **kwargs): @@ -720,146 +726,141 @@ def f(x): @string_udf_test -def test_string_udf_len(str_data): +def test_string_udf_len(str_udf_data): def func(row): st = row["str_col"] return len(st) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize("substr", ["a", "cu", "2"]) -def test_string_udf_startswith(str_data, substr): +def test_string_udf_startswith(str_udf_data, substr): def func(row): st = row["str_col"] return st.startswith(substr) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize("substr", ["a", "gpu", "2"]) -def test_string_udf_endswith(str_data, substr): +def test_string_udf_endswith(str_udf_data, substr): def func(row): st = row["str_col"] return st.endswith(substr) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize("substr", ["u", "gpu", "a"]) -def test_string_udf_find(str_data, substr): +def test_string_udf_find(str_udf_data, substr): def func(row): st = row["str_col"] return st.find(substr) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize("substr", ["u", "gpu", "a"]) -def test_string_udf_rfind(str_data, substr): +def test_string_udf_rfind(str_udf_data, substr): def func(row): st = row["str_col"] return st.rfind(substr) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -@pytest.mark.parametrize("substr", ["a", "cu", "", "12"]) -def test_string_udf_contains(str_data, substr): +def test_string_udf_contains(str_udf_data, substr): def func(row): st = row["str_col"] return substr in st - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test @pytest.mark.parametrize("other", ["cudf", "123", "", " "]) @pytest.mark.parametrize("cmpop", comparison_ops) -def test_string_udf_cmpops(str_data, other, cmpop): +def test_string_udf_cmpops(str_udf_data, other, cmpop): def func(row): st = row["str_col"] return cmpop(st, other) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_isalnum(str_data): +def test_string_udf_isalnum(str_udf_data): def func(row): st = row["str_col"] return st.isalnum() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_isalpha(str_data): +def test_string_udf_isalpha(str_udf_data): def func(row): st = row["str_col"] return st.isalpha() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_isdigit(str_data): +def test_string_udf_isdigit(str_udf_data): def func(row): st = row["str_col"] return st.isdigit() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_isdecimal(str_data): +def test_string_udf_isdecimal(str_udf_data): def func(row): st = row["str_col"] return st.isdecimal() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_isupper(str_data): +def test_string_udf_isupper(str_udf_data): def func(row): st = row["str_col"] return st.isupper() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_islower(str_data): +def test_string_udf_islower(str_udf_data): def func(row): st = row["str_col"] return st.islower() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test -def test_string_udf_isspace(str_data): +def test_string_udf_isspace(str_udf_data): def func(row): st = row["str_col"] return st.isspace() - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @string_udf_test @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) -def test_string_udf_count(str_data, substr): +def test_string_udf_count(str_udf_data, substr): def func(row): st = row["str_col"] return st.count(substr) - run_masked_udf_test(func, str_data, check_dtype=False) + run_masked_udf_test(func, str_udf_data, check_dtype=False) @pytest.mark.parametrize( From 243aa7a4285be339158046f6893a224309707751 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:12:22 -0700 Subject: [PATCH 175/212] Minor CMake cleanup. --- python/strings_udf/cpp/CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/python/strings_udf/cpp/CMakeLists.txt b/python/strings_udf/cpp/CMakeLists.txt index 89908698c4c..d157acfefde 100644 --- a/python/strings_udf/cpp/CMakeLists.txt +++ b/python/strings_udf/cpp/CMakeLists.txt @@ -27,11 +27,7 @@ rapids_cuda_init_architectures(STRINGS_UDF) project( strings-udf-cpp VERSION ${strings_udf_version} - LANGUAGES # TODO: Building Python extension modules via the python_extension_module requires the C - # language to be enabled here. The test project that is built in scikit-build to verify - # various linking options for the python library is hardcoded to build with C, so until - # that is fixed we need to keep C. - CUDA + LANGUAGES CUDA ) rapids_find_package( @@ -44,7 +40,9 @@ include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) rapids_cpm_libcudacxx(BUILD_EXPORT_SET strings-udf-exports INSTALL_EXPORT_SET strings-udf-exports) add_library(cudf_strings_udf SHARED src/strings/udf/udf_apis.cu) -target_include_directories(cudf_strings_udf PUBLIC include) +target_include_directories( + cudf_strings_udf PUBLIC "$" +) set_target_properties( cudf_strings_udf From 5514b3e6bb5604c4fe82a52770f431a23f5ad9bc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:15:33 -0700 Subject: [PATCH 176/212] Typo fixes. --- .../strings_udf/cpp/include/cudf/strings/udf/char_types.cuh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh index a006718c35b..e28111fd1f2 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/char_types.cuh @@ -27,7 +27,7 @@ namespace udf { /** * @brief Returns true if all characters in the string are of the type specified. * - * The output will false if the string is empty or has at least one character + * The output will be false if the string is empty or has at least one character * not of the specified type. If all characters fit the type then true is returned. * * To ignore all but specific types, set the `verify_types` to those types @@ -91,11 +91,11 @@ __device__ inline bool is_alpha(cudf::strings::detail::character_flags_table_typ } /** - * @brief Returns true if all characters are alpha-numeric only + * @brief Returns true if all characters are alphanumeric only * * @param flags_table Table required for checking character types * @param d_str Input string to check - * @return True if characters are alpha-numeric + * @return True if characters are alphanumeric */ __device__ inline bool is_alpha_numeric( cudf::strings::detail::character_flags_table_type* flags_table, string_view d_str) From 713f23d6e7baa5af70b55e99d563bff57910f5f8 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:16:28 -0700 Subject: [PATCH 177/212] Switch prefix with postfix. --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index 670c29132a4..0a2f36a812c 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -48,7 +48,7 @@ __device__ inline cudf::size_type count(string_view const source, while (pos != cudf::string_view::npos) { pos = source.find(target, pos, end - pos); if (pos != cudf::string_view::npos) { - count++; + ++count; pos += tgt_length; } } From f324ebc56d21e0a6927f1f211fbecce15171555d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:21:25 -0700 Subject: [PATCH 178/212] Some copyright fixes. --- python/strings_udf/cpp/src/strings/udf/udf_apis.cu | 2 +- python/strings_udf/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu index c06a58d5eb3..1c1f0184c4d 100644 --- a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, NVIDIA CORPORATION. + * Copyright (c) 2022, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index a8a834c0051..d9b96838bb3 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2022, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. import os import re From 313757c3cb18279749816d0e5e5c6871170b687d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:22:58 -0700 Subject: [PATCH 179/212] Remove unnecessary cmdclass modification. --- python/strings_udf/setup.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index d9b96838bb3..8cc9249332a 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -6,7 +6,6 @@ from setuptools import find_packages from skbuild import setup -from skbuild.command.build_ext import build_ext import versioneer @@ -59,9 +58,6 @@ def get_cuda_version_from_header(cuda_include_dir, delimeter=""): cuda_include_dir = os.path.join(CUDA_HOME, "include") -cmdclass = versioneer.get_cmdclass() -cmdclass["build_ext"] = build_ext - setup( name="strings_udf", version=versioneer.get_version(), @@ -82,7 +78,7 @@ def get_cuda_version_from_header(cuda_include_dir, delimeter=""): package_data={ key: ["*.pxd"] for key in find_packages(include=["strings_udf._lib*"]) }, - cmdclass=cmdclass, + cmdclass=versioneer.get_cmdclass(), install_requires=install_requires, extras_require=extras_require, zip_safe=False, From fd1041a17bb7a428b85656b2397e674a6dc3f02d Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:27:14 -0700 Subject: [PATCH 180/212] Improve PTX file handling and error cases. --- python/strings_udf/strings_udf/__init__.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index 84bb8db2ab6..fa67ae053a2 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -10,12 +10,12 @@ from numba import cuda ENABLED = False -ptxpath = None def compiler_from_ptx_file(path): - """ - Example PTX header: + """Parse a PTX file header and extract the CUDA version used to compile it. + + Here is an example PTX header that this function should parse: // Generated by NVIDIA NVVM Compiler // @@ -42,8 +42,8 @@ def compiler_from_ptx_file(path): # CUDA enhanced compatibility not yet enabled if driver_version >= runtime_version: - # Load the highest compute capability file available that is less than the - # current device's. + # Load the highest compute capability file available that is less than + # the current device's. files = glob.glob( os.path.join(os.path.dirname(__file__), "shim_*.ptx") ) @@ -52,6 +52,12 @@ def compiler_from_ptx_file(path): files = glob.glob( os.path.join(os.path.dirname(__file__), "shim_*.ptx") ) + if len(files) == 0: + raise RuntimeError( + "This strings_udf installation is missing the necessary PTX " + "files. Please file an issue reporting this error and how you " + "installed cudf and strings_udf." + ) sms = [ os.path.basename(f).rstrip(".ptx").lstrip("shim_") for f in files ] @@ -62,8 +68,7 @@ def compiler_from_ptx_file(path): if driver_version >= compiler_from_ptx_file(ptxpath): ENABLED = True - -if not ENABLED: - del ptxpath + else: + del ptxpath __version__ = _version.get_versions()["version"] From 0e177de77bf3cba45760f7713f2e5c52b9f88bdc Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:28:15 -0700 Subject: [PATCH 181/212] Fix issue with rapids-cmake changing the variable name. --- python/strings_udf/strings_udf/_lib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/strings_udf/_lib/CMakeLists.txt b/python/strings_udf/strings_udf/_lib/CMakeLists.txt index 3cd81d884c0..424edce0c18 100644 --- a/python/strings_udf/strings_udf/_lib/CMakeLists.txt +++ b/python/strings_udf/strings_udf/_lib/CMakeLists.txt @@ -20,7 +20,7 @@ rapids_cython_create_modules( LINKED_LIBRARIES "${linked_libraries}" ) -foreach(cython_module IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) +foreach(cython_module IN LISTS _RAPIDS_CYTHON_CREATED_TARGETS) set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/cpp") set_target_properties( ${cython_module} PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/include From 267c5af143174917eebea58a15db74ce2443bfe6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:29:20 -0700 Subject: [PATCH 182/212] More copyright fixes. --- python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd | 2 +- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index a8886501ac8..ef2f5e4da48 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. from libc.stdint cimport uint8_t from libcpp.memory cimport unique_ptr diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index 75224d036b6..ddc7febc061 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# Copyright (c) 2022, NVIDIA CORPORATION. from libcpp.memory cimport unique_ptr from libcpp.utility cimport move From 5bb80ffa47bb5913ec73491f0a3b27b5b5a2ca72 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 13:31:11 -0700 Subject: [PATCH 183/212] Remove unnecessary temp variable. --- python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx index ddc7febc061..bb1892a4d26 100644 --- a/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx +++ b/python/strings_udf/strings_udf/_lib/cudf_jit_udf.pyx @@ -21,5 +21,4 @@ def to_string_view_array(Column strings_col): c_buffer = move(cpp_to_string_view_array(input_view)) device_buffer = DeviceBuffer.c_from_unique_ptr(move(c_buffer)) - buffer = Buffer(device_buffer) - return buffer + return Buffer(device_buffer) From b30ca2fc7279e207980030d9e579cbb651ec8365 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Tue, 13 Sep 2022 17:05:23 -0400 Subject: [PATCH 184/212] Add missing @param --- python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp index 7b64e43b056..358c5f86be6 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -25,6 +25,7 @@ /** * @brief Return a cudf::string_view array for the given strings column * + * @param input Strings column to convert to a string_view array. * @throw cudf::logic_error if input is not a strings column. */ std::unique_ptr to_string_view_array(cudf::column_view const input); From 7c1851ca00c1170fd39bf51d2ab418e73c7975c5 Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Tue, 13 Sep 2022 19:00:37 -0500 Subject: [PATCH 185/212] Update python/cudf/cudf/core/udf/row_function.py Co-authored-by: Vyas Ramasubramani --- python/cudf/cudf/core/udf/row_function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 818cd7a2f1a..04d99f4e6b1 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -47,7 +47,7 @@ def _get_frame_row_type(dtype): offset = 0 sizes = [ - itemsizes.get(val[0]) or val[0].itemsize + itemsizes.get(val[0], val[0].itemsize) for val in dtype.fields.values() ] for i, (name, info) in enumerate(dtype.fields.items()): From 5ca6abc8e51d96aab0c3b2c9ccb41932543cd3d6 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:01:59 -0700 Subject: [PATCH 186/212] Remove extraneous include. --- python/strings_udf/strings_udf/_lib/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/CMakeLists.txt b/python/strings_udf/strings_udf/_lib/CMakeLists.txt index 424edce0c18..91069a43891 100644 --- a/python/strings_udf/strings_udf/_lib/CMakeLists.txt +++ b/python/strings_udf/strings_udf/_lib/CMakeLists.txt @@ -22,7 +22,4 @@ rapids_cython_create_modules( foreach(cython_module IN LISTS _RAPIDS_CYTHON_CREATED_TARGETS) set_target_properties(${cython_module} PROPERTIES INSTALL_RPATH "\$ORIGIN;\$ORIGIN/cpp") - set_target_properties( - ${cython_module} PROPERTIES INCLUDE_DIRECTORIES ${CMAKE_INSTALL_PREFIX}/include - ) endforeach() From c0ce94a57d221efd70e90960586a87373dd2c0b5 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:09:37 -0700 Subject: [PATCH 187/212] Move to_string_view_array into the appropriate namespaces. --- .../cpp/include/cudf/strings/udf/udf_apis.hpp | 8 ++++++++ python/strings_udf/cpp/src/strings/udf/udf_apis.cu | 13 ++++++++++++- .../strings_udf/_lib/cpp/strings_udf.pxd | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp index 358c5f86be6..6de9b91de08 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/udf_apis.hpp @@ -22,6 +22,10 @@ #include +namespace cudf { +namespace strings { +namespace udf { + /** * @brief Return a cudf::string_view array for the given strings column * @@ -29,3 +33,7 @@ * @throw cudf::logic_error if input is not a strings column. */ std::unique_ptr to_string_view_array(cudf::column_view const input); + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu index 1c1f0184c4d..693b23bb406 100644 --- a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -28,6 +28,11 @@ #include +namespace cudf { +namespace strings { +namespace udf { +namespace detail { + std::unique_ptr to_string_view_array(cudf::column_view const input, rmm::cuda_stream_view stream) { @@ -37,7 +42,13 @@ std::unique_ptr to_string_view_array(cudf::column_view const .release())); } +} // namespace detail + std::unique_ptr to_string_view_array(cudf::column_view const input) { - return to_string_view_array(input, rmm::cuda_stream_default); + return detail::to_string_view_array(input, rmm::cuda_stream_default); } + +} // namespace udf +} // namespace strings +} // namespace cudf diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index ef2f5e4da48..a7cb871df7b 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -11,7 +11,8 @@ from cudf._lib.cpp.types cimport size_type from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer -cdef extern from "cudf/strings/udf/udf_apis.hpp" nogil: +cdef extern from "cudf/strings/udf/udf_apis.hpp" namespace \ + "cudf::strings::udf" nogil: cdef unique_ptr[device_buffer] to_string_view_array(column_view) cdef extern from "cudf/strings/detail/char_tables.hpp" namespace \ From 08672053c3cd34164ac19ba5b50f0b2826577be8 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:10:40 -0700 Subject: [PATCH 188/212] Add missing nogil and except +. --- python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd index a7cb871df7b..fb8e3a949bf 100644 --- a/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd +++ b/python/strings_udf/strings_udf/_lib/cpp/strings_udf.pxd @@ -13,8 +13,8 @@ from rmm._lib.device_buffer cimport DeviceBuffer, device_buffer cdef extern from "cudf/strings/udf/udf_apis.hpp" namespace \ "cudf::strings::udf" nogil: - cdef unique_ptr[device_buffer] to_string_view_array(column_view) + cdef unique_ptr[device_buffer] to_string_view_array(column_view) except + cdef extern from "cudf/strings/detail/char_tables.hpp" namespace \ - "cudf::strings::detail": + "cudf::strings::detail" nogil: cdef const uint8_t* get_character_flags_table() except + From c4f91337243cca6d701c4eafec536947f5131475 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:14:06 -0700 Subject: [PATCH 189/212] Use auto. --- .../strings_udf/cpp/src/strings/udf/shim.cu | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu index 862f462d840..bfbde3d3ff9 100644 --- a/python/strings_udf/cpp/src/strings/udf/shim.cu +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -22,15 +22,15 @@ using namespace cudf::strings::udf; extern "C" __device__ int len(int* nb_retval, void* str) { - cudf::string_view* sv = reinterpret_cast(str); - *nb_retval = sv->length(); + auto sv = reinterpret_cast(str); + *nb_retval = sv->length(); return 0; } extern "C" __device__ int startswith(bool* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = starts_with(*str_view, *substr_view); return 0; @@ -38,8 +38,8 @@ extern "C" __device__ int startswith(bool* nb_retval, void* str, void* substr) extern "C" __device__ int endswith(bool* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = ends_with(*str_view, *substr_view); return 0; @@ -47,8 +47,8 @@ extern "C" __device__ int endswith(bool* nb_retval, void* str, void* substr) extern "C" __device__ int contains(bool* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = (str_view->find(*substr_view) != cudf::string_view::npos); return 0; @@ -56,8 +56,8 @@ extern "C" __device__ int contains(bool* nb_retval, void* str, void* substr) extern "C" __device__ int find(int* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = str_view->find(*substr_view); return 0; @@ -65,8 +65,8 @@ extern "C" __device__ int find(int* nb_retval, void* str, void* substr) extern "C" __device__ int rfind(int* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = str_view->rfind(*substr_view); return 0; @@ -74,8 +74,8 @@ extern "C" __device__ int rfind(int* nb_retval, void* str, void* substr) extern "C" __device__ int eq(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view == *rhs_view); return 0; @@ -83,8 +83,8 @@ extern "C" __device__ int eq(bool* nb_retval, void* str, void* rhs) extern "C" __device__ int ne(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view != *rhs_view); return 0; @@ -92,8 +92,8 @@ extern "C" __device__ int ne(bool* nb_retval, void* str, void* rhs) extern "C" __device__ int ge(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view >= *rhs_view); return 0; @@ -101,8 +101,8 @@ extern "C" __device__ int ge(bool* nb_retval, void* str, void* rhs) extern "C" __device__ int le(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view <= *rhs_view); return 0; @@ -110,8 +110,8 @@ extern "C" __device__ int le(bool* nb_retval, void* str, void* rhs) extern "C" __device__ int gt(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view > *rhs_view); return 0; @@ -119,8 +119,8 @@ extern "C" __device__ int gt(bool* nb_retval, void* str, void* rhs) extern "C" __device__ int lt(bool* nb_retval, void* str, void* rhs) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view < *rhs_view); return 0; @@ -128,7 +128,7 @@ extern "C" __device__ int lt(bool* nb_retval, void* str, void* rhs) extern "C" __device__ int pyislower(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_lower( reinterpret_cast(chars_table), *str_view); @@ -137,7 +137,7 @@ extern "C" __device__ int pyislower(bool* nb_retval, void* str, std::int64_t cha extern "C" __device__ int pyisupper(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_upper( reinterpret_cast(chars_table), *str_view); @@ -146,7 +146,7 @@ extern "C" __device__ int pyisupper(bool* nb_retval, void* str, std::int64_t cha extern "C" __device__ int pyisspace(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_space( reinterpret_cast(chars_table), *str_view); @@ -155,7 +155,7 @@ extern "C" __device__ int pyisspace(bool* nb_retval, void* str, std::int64_t cha extern "C" __device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_decimal( reinterpret_cast(chars_table), *str_view); @@ -164,7 +164,7 @@ extern "C" __device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t c extern "C" __device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_numeric( reinterpret_cast(chars_table), *str_view); @@ -173,7 +173,7 @@ extern "C" __device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t c extern "C" __device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_digit( reinterpret_cast(chars_table), *str_view); @@ -182,7 +182,7 @@ extern "C" __device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t cha extern "C" __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_alpha_numeric( reinterpret_cast(chars_table), *str_view); @@ -191,7 +191,7 @@ extern "C" __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t cha extern "C" __device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t chars_table) { - cudf::string_view* str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_alpha( reinterpret_cast(chars_table), *str_view); @@ -200,8 +200,8 @@ extern "C" __device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t cha extern "C" __device__ int pycount(int* nb_retval, void* str, void* substr) { - cudf::string_view* str_view = reinterpret_cast(str); - cudf::string_view* substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = count(*str_view, *substr_view); return 0; From 23b3020a837d4a5818856921e9de28922ff07198 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:16:44 -0700 Subject: [PATCH 190/212] Add consts. --- .../strings_udf/cpp/src/strings/udf/shim.cu | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/python/strings_udf/cpp/src/strings/udf/shim.cu b/python/strings_udf/cpp/src/strings/udf/shim.cu index bfbde3d3ff9..656861f9cd6 100644 --- a/python/strings_udf/cpp/src/strings/udf/shim.cu +++ b/python/strings_udf/cpp/src/strings/udf/shim.cu @@ -20,188 +20,188 @@ using namespace cudf::strings::udf; -extern "C" __device__ int len(int* nb_retval, void* str) +extern "C" __device__ int len(int* nb_retval, void const* str) { - auto sv = reinterpret_cast(str); + auto sv = reinterpret_cast(str); *nb_retval = sv->length(); return 0; } -extern "C" __device__ int startswith(bool* nb_retval, void* str, void* substr) +extern "C" __device__ int startswith(bool* nb_retval, void const* str, void const* substr) { - auto str_view = reinterpret_cast(str); - auto substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = starts_with(*str_view, *substr_view); return 0; } -extern "C" __device__ int endswith(bool* nb_retval, void* str, void* substr) +extern "C" __device__ int endswith(bool* nb_retval, void const* str, void const* substr) { - auto str_view = reinterpret_cast(str); - auto substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = ends_with(*str_view, *substr_view); return 0; } -extern "C" __device__ int contains(bool* nb_retval, void* str, void* substr) +extern "C" __device__ int contains(bool* nb_retval, void const* str, void const* substr) { - auto str_view = reinterpret_cast(str); - auto substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = (str_view->find(*substr_view) != cudf::string_view::npos); return 0; } -extern "C" __device__ int find(int* nb_retval, void* str, void* substr) +extern "C" __device__ int find(int* nb_retval, void const* str, void const* substr) { - auto str_view = reinterpret_cast(str); - auto substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = str_view->find(*substr_view); return 0; } -extern "C" __device__ int rfind(int* nb_retval, void* str, void* substr) +extern "C" __device__ int rfind(int* nb_retval, void const* str, void const* substr) { - auto str_view = reinterpret_cast(str); - auto substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = str_view->rfind(*substr_view); return 0; } -extern "C" __device__ int eq(bool* nb_retval, void* str, void* rhs) +extern "C" __device__ int eq(bool* nb_retval, void const* str, void const* rhs) { - auto str_view = reinterpret_cast(str); - auto rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view == *rhs_view); return 0; } -extern "C" __device__ int ne(bool* nb_retval, void* str, void* rhs) +extern "C" __device__ int ne(bool* nb_retval, void const* str, void const* rhs) { - auto str_view = reinterpret_cast(str); - auto rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view != *rhs_view); return 0; } -extern "C" __device__ int ge(bool* nb_retval, void* str, void* rhs) +extern "C" __device__ int ge(bool* nb_retval, void const* str, void const* rhs) { - auto str_view = reinterpret_cast(str); - auto rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view >= *rhs_view); return 0; } -extern "C" __device__ int le(bool* nb_retval, void* str, void* rhs) +extern "C" __device__ int le(bool* nb_retval, void const* str, void const* rhs) { - auto str_view = reinterpret_cast(str); - auto rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view <= *rhs_view); return 0; } -extern "C" __device__ int gt(bool* nb_retval, void* str, void* rhs) +extern "C" __device__ int gt(bool* nb_retval, void const* str, void const* rhs) { - auto str_view = reinterpret_cast(str); - auto rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view > *rhs_view); return 0; } -extern "C" __device__ int lt(bool* nb_retval, void* str, void* rhs) +extern "C" __device__ int lt(bool* nb_retval, void const* str, void const* rhs) { - auto str_view = reinterpret_cast(str); - auto rhs_view = reinterpret_cast(rhs); + auto str_view = reinterpret_cast(str); + auto rhs_view = reinterpret_cast(rhs); *nb_retval = (*str_view < *rhs_view); return 0; } -extern "C" __device__ int pyislower(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyislower(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_lower( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisupper(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisupper(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_upper( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisspace(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisspace(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_space( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisdecimal(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisdecimal(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_decimal( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisnumeric(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisnumeric(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_numeric( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisdigit(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisdigit(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_digit( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisalnum(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisalnum(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_alpha_numeric( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pyisalpha(bool* nb_retval, void* str, std::int64_t chars_table) +extern "C" __device__ int pyisalpha(bool* nb_retval, void const* str, std::int64_t chars_table) { - auto str_view = reinterpret_cast(str); + auto str_view = reinterpret_cast(str); *nb_retval = is_alpha( reinterpret_cast(chars_table), *str_view); return 0; } -extern "C" __device__ int pycount(int* nb_retval, void* str, void* substr) +extern "C" __device__ int pycount(int* nb_retval, void const* str, void const* substr) { - auto str_view = reinterpret_cast(str); - auto substr_view = reinterpret_cast(substr); + auto str_view = reinterpret_cast(str); + auto substr_view = reinterpret_cast(substr); *nb_retval = count(*str_view, *substr_view); return 0; From 51ac69376b8d5496f1ae11017be12e74c82ed76c Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:21:34 -0700 Subject: [PATCH 191/212] Commit missed detail header with detail::to_string_view_array declaration. --- .../cudf/strings/udf/detail/udf_apis.hpp | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp new file mode 100644 index 00000000000..6ba765078cd --- /dev/null +++ b/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022, NVIDIA CORPORATION. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include + +#include + +namespace cudf { +namespace strings { +namespace udf { +namespace detail { + +/** + * @brief Return a cudf::string_view array for the given strings column + * + * @param input Strings column to convert to a string_view array. + * @throw cudf::logic_error if input is not a strings column. + */ +std::unique_ptr to_string_view_array(cudf::column_view const input); + +} // namespace detail +} // namespace udf +} // namespace strings +} // namespace cudf From 84b4d4b22f700a9ab91eb5416282090cff0a75df Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:22:49 -0700 Subject: [PATCH 192/212] Add missing stream parameter. --- .../cpp/include/cudf/strings/udf/detail/udf_apis.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp index 6ba765078cd..4d61835f193 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp +++ b/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp @@ -18,6 +18,7 @@ #include +#include #include #include @@ -33,7 +34,8 @@ namespace detail { * @param input Strings column to convert to a string_view array. * @throw cudf::logic_error if input is not a strings column. */ -std::unique_ptr to_string_view_array(cudf::column_view const input); +std::unique_ptr to_string_view_array(cudf::column_view const input, + rmm::cuda_stream_view stream); } // namespace detail } // namespace udf From f2e52cf80799331ceab12dd888ce81241c5de634 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 13 Sep 2022 17:22:56 -0700 Subject: [PATCH 193/212] fix bugs with imported implementation names --- python/strings_udf/strings_udf/lowering.py | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index df2c921456a..3413f2f5ffa 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -112,7 +112,7 @@ def call_len_string_view(st): @cuda_lower(len, string_view) -def string_view_len_impl(context, builder, sig, args): +def len_impl(context, builder, sig, args): sv_ptr = builder.alloca(args[0].type) builder.store(args[0], sv_ptr) result = context.compile_internal( @@ -149,62 +149,62 @@ def binary_func_impl(context, builder, sig, args): @create_binary_string_func(operator.contains, types.boolean) -def string_view_contains_impl(st, substr): +def contains_impl(st, substr): return _string_view_contains(st, substr) @create_binary_string_func(operator.eq, types.boolean) -def string_view_eq_impl(st, rhs): +def eq_impl(st, rhs): return _string_view_eq(st, rhs) @create_binary_string_func(operator.ne, types.boolean) -def string_view_ne_impl(st, rhs): +def ne_impl(st, rhs): return _string_view_ne(st, rhs) @create_binary_string_func(operator.ge, types.boolean) -def string_view_ge_impl(st, rhs): +def ge_impl(st, rhs): return _string_view_ge(st, rhs) @create_binary_string_func(operator.le, types.boolean) -def string_view_le_impl(st, rhs): +def le_impl(st, rhs): return _string_view_le(st, rhs) @create_binary_string_func(operator.gt, types.boolean) -def string_view_gt_impl(st, rhs): +def gt_impl(st, rhs): return _string_view_gt(st, rhs) @create_binary_string_func(operator.lt, types.boolean) -def string_view_lt_impl(st, rhs): +def lt_impl(st, rhs): return _string_view_lt(st, rhs) @create_binary_string_func("StringView.startswith", types.boolean) -def string_view_startswith_impl(sv, substr): +def startswith_impl(sv, substr): return _string_view_startswith(sv, substr) @create_binary_string_func("StringView.endswith", types.boolean) -def string_view_endswith_impl(sv, substr): +def endswith_impl(sv, substr): return _string_view_endswith(sv, substr) @create_binary_string_func("StringView.count", size_type) -def string_view_count_impl(st, substr): +def count_impl(st, substr): return _string_view_count(st, substr) @create_binary_string_func("StringView.find", size_type) -def string_view_find_impl(sv, substr): +def find_impl(sv, substr): return _string_view_find(sv, substr) @create_binary_string_func("StringView.rfind", size_type) -def string_view_rfind_impl(sv, substr): +def rfind_impl(sv, substr): return _string_view_rfind(sv, substr) @@ -232,40 +232,40 @@ def id_func_impl(context, builder, sig, args): @create_unary_identifier_func("StringView.isdigit") -def string_view_isdigit_impl(st, tbl): +def isdigit_impl(st, tbl): return _string_view_isdigit(st, tbl) @create_unary_identifier_func("StringView.isalnum") -def string_view_isalnum_impl(st, tbl): +def isalnum_impl(st, tbl): return _string_view_isalnum(st, tbl) @create_unary_identifier_func("StringView.isalpha") -def string_view_isalpha_impl(st, tbl): +def isalpha_impl(st, tbl): return _string_view_isalpha(st, tbl) @create_unary_identifier_func("StringView.isnumeric") -def string_view_isnumeric_impl(st, tbl): +def isnumeric_impl(st, tbl): return _string_view_isnumeric(st, tbl) @create_unary_identifier_func("StringView.isdecimal") -def string_view_isdecimal_impl(st, tbl): +def isdecimal_impl(st, tbl): return _string_view_isdecimal(st, tbl) @create_unary_identifier_func("StringView.isspace") -def string_view_isspace_impl(st, tbl): +def isspace_impl(st, tbl): return _string_view_isspace(st, tbl) @create_unary_identifier_func("StringView.isupper") -def string_view_isupper_impl(st, tbl): +def isupper_impl(st, tbl): return _string_view_isupper(st, tbl) @create_unary_identifier_func("StringView.islower") -def string_view_islower_impl(st, tbl): +def islower_impl(st, tbl): return _string_view_islower(st, tbl) From 2f47e9fc15f340164ef83dbe9f11c6e29cff6d5a Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:27:32 -0700 Subject: [PATCH 194/212] Remove header exposing detail API. --- .../cudf/strings/udf/detail/udf_apis.hpp | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp b/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp deleted file mode 100644 index 4d61835f193..00000000000 --- a/python/strings_udf/cpp/include/cudf/strings/udf/detail/udf_apis.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022, NVIDIA CORPORATION. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include -#include - -#include - -namespace cudf { -namespace strings { -namespace udf { -namespace detail { - -/** - * @brief Return a cudf::string_view array for the given strings column - * - * @param input Strings column to convert to a string_view array. - * @throw cudf::logic_error if input is not a strings column. - */ -std::unique_ptr to_string_view_array(cudf::column_view const input, - rmm::cuda_stream_view stream); - -} // namespace detail -} // namespace udf -} // namespace strings -} // namespace cudf From ab87921aaad4c5b3dbb1045af22422120e441eca Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 13 Sep 2022 17:54:24 -0700 Subject: [PATCH 195/212] Fix style. --- python/cudf/cudf/core/udf/row_function.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/udf/row_function.py b/python/cudf/cudf/core/udf/row_function.py index 04d99f4e6b1..8d887a37706 100644 --- a/python/cudf/cudf/core/udf/row_function.py +++ b/python/cudf/cudf/core/udf/row_function.py @@ -47,8 +47,7 @@ def _get_frame_row_type(dtype): offset = 0 sizes = [ - itemsizes.get(val[0], val[0].itemsize) - for val in dtype.fields.values() + itemsizes.get(val[0], val[0].itemsize) for val in dtype.fields.values() ] for i, (name, info) in enumerate(dtype.fields.items()): # *info* consists of the element dtype, its offset from the beginning From 07dbded3814e29b6129c7a9cbeae1b81d52d3350 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 13 Sep 2022 18:45:06 -0700 Subject: [PATCH 196/212] address other reviews --- python/cudf/cudf/core/indexed_frame.py | 4 +- python/cudf/cudf/core/udf/__init__.py | 18 +- python/cudf/cudf/core/udf/strings_typing.py | 212 ++++++++---------- python/cudf/cudf/core/udf/utils.py | 6 +- python/cudf/cudf/tests/test_udf_masked_ops.py | 45 ++-- python/strings_udf/setup.py | 5 +- 6 files changed, 120 insertions(+), 170 deletions(-) diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 2de6fa3d3a6..0b94c0e6861 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -55,7 +55,7 @@ _compile_or_get, _get_input_args_from_frame, _post_process_output_col, - _return_col_from_dtype, + _return_arr_from_dtype, ) from cudf.utils import docutils from cudf.utils.utils import _cudf_nvtx_annotate @@ -1804,7 +1804,7 @@ def _apply(self, func, kernel_getter, *args, **kwargs): ) from e # Mask and data column preallocated - ans_col = _return_col_from_dtype(retty, len(self)) + ans_col = _return_arr_from_dtype(retty, len(self)) ans_mask = cudf.core.column.column_empty(len(self), dtype="bool") output_args = [(ans_col, ans_mask), len(self)] input_args = _get_input_args_from_frame(self) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index eb36dceff02..f7b231e4e27 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -13,16 +13,16 @@ from cudf.utils.dtypes import STRING_TYPES import numpy as np -units = ["ns", "ms", "us", "s"] -datetime_cases = {types.NPDatetime(u) for u in units} -timedelta_cases = {types.NPTimedelta(u) for u in units} +_units = ["ns", "ms", "us", "s"] +_datetime_cases = {types.NPDatetime(u) for u in _units} +_timedelta_cases = {types.NPTimedelta(u) for u in _units} -supported_masked_types = ( +_supported_masked_types = ( types.integer_domain | types.real_domain - | datetime_cases - | timedelta_cases + | _datetime_cases + | _timedelta_cases | {types.boolean} ) @@ -47,11 +47,11 @@ masked_lowering.pack_return_scalar_impl ) - supported_masked_types |= {strings_typing.string_view} + _supported_masked_types |= {strings_typing.string_view} utils.launch_arg_getters[dtype("O")] = to_string_view_array utils.masked_array_types[dtype("O")] = string_view utils.JIT_SUPPORTED_TYPES |= STRING_TYPES - utils.files.append(ptxpath) + utils.ptx_files.append(ptxpath) utils.arg_handlers.append(str_view_arg_handler) row_function.itemsizes[dtype("O")] = string_view.size_bytes @@ -63,4 +63,4 @@ # allow cuDF to work without strings_udf pass -masked_typing.register_masked_constructor(supported_masked_types) +masked_typing.register_masked_constructor(_supported_masked_types) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index b436c2d2eaa..bf6461c9045 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -23,77 +23,41 @@ def _is_valid_string_arg(ty): ) or isinstance(ty, types.StringLiteral) -# String functions -@cuda_decl_registry.register_global(len) -class MaskedStringViewLength(AbstractTemplate): - """ - provide the length of a cudf::string_view like struct - """ - - def generic(self, args, kws): - if isinstance(args[0], MaskedType) and isinstance( - args[0].value_type, StringView - ): - return nb_signature(MaskedType(size_type), args[0]) - - -@cuda_decl_registry.register_global(operator.contains) -class MaskedStringViewContains(AbstractTemplate): - """ - return a boolean indicating if a substring is found in a string - """ +def register_string_function(func): + def deco(generic): + class MaskedStringFunction(AbstractTemplate): + pass - def generic(self, args, kws): - if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): - return nb_signature( - MaskedType(types.boolean), - MaskedType(string_view), - MaskedType(string_view), - ) + MaskedStringFunction.generic = generic + cuda_decl_registry.register_global(func)(MaskedStringFunction) + return deco -class MaskedStringViewCmpOp(AbstractTemplate): - """ - return the boolean result of `cmpop` between to strings - since the typing is the same for every comparison operator, - we can reuse this class for all of them. - """ - def generic(self, args, kws): - if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): - return nb_signature( - MaskedType(types.boolean), - MaskedType(string_view), - MaskedType(string_view), - ) - - -for op in comparison_ops: - cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) - - -@cuda_decl_registry.register_global(len) -class StringLiteralLength(AbstractTemplate): - """ - provide the length of a python string literal by first - converting to a cudf::string_view first - """ - - def generic(self, args, kws): - if isinstance(args[0], types.StringLiteral) and len(args) == 1: - return nb_signature(size_type, args[0]) +@register_string_function(len) +def len_typing(self, args, kws): + if isinstance(args[0], MaskedType) and isinstance( + args[0].value_type, StringView + ): + return nb_signature(MaskedType(size_type), args[0]) + elif isinstance(args[0], types.StringLiteral) and len(args) == 1: + # literal is always valid + return nb_signature(size_type, args[0]) def create_masked_binary_attr(attrname, retty): class MaskedStringViewBinaryAttr(AbstractTemplate): - key = attrname + key = f"MaskedType.{attrname}" def generic(self, args, kws): return nb_signature( MaskedType(retty), MaskedType(string_view), recvr=self.this ) - return MaskedStringViewBinaryAttr + return types.BoundFunction( + MaskedStringViewBinaryAttr, + MaskedType(string_view), + ) def create_masked_identifier_attr(attrname): @@ -106,6 +70,32 @@ def generic(self, args, kws): return MaskedStringViewIdentifierAttr +@register_string_function(operator.contains) +def contains_typing(self, args, kws): + if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): + return nb_signature( + MaskedType(types.boolean), + MaskedType(string_view), + MaskedType(string_view), + ) + + +class MaskedStringViewCmpOp(AbstractTemplate): + """ + return the boolean result of `cmpop` between to strings + since the typing is the same for every comparison operator, + we can reuse this class for all of them. + """ + + def generic(self, args, kws): + if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): + return nb_signature( + MaskedType(types.boolean), + MaskedType(string_view), + MaskedType(string_view), + ) + + class MaskedStringViewCount(AbstractTemplate): key = "MaskedType.count" @@ -115,83 +105,61 @@ def generic(self, args, kws): ) -@cuda_decl_registry.register_attr class MaskedStringViewAttrs(AttributeTemplate): key = MaskedType(string_view) - def resolve_startswith(self, mod): - return types.BoundFunction( - create_masked_binary_attr("MaskedType.startswith", types.boolean), - MaskedType(string_view), - ) - - def resolve_endswith(self, mod): - return types.BoundFunction( - create_masked_binary_attr("MaskedType.endswith", types.boolean), - MaskedType(string_view), - ) - - def resolve_find(self, mod): - return types.BoundFunction( - create_masked_binary_attr("MaskedType.find", size_type), - MaskedType(string_view), - ) - - def resolve_rfind(self, mod): - return types.BoundFunction( - create_masked_binary_attr("MaskedType.rfind", size_type), - MaskedType(string_view), - ) - def resolve_count(self, mod): return types.BoundFunction( MaskedStringViewCount, MaskedType(string_view) ) - def resolve_isalnum(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.isalnum"), - MaskedType(string_view), - ) - - def resolve_isalpha(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.isalpha"), - MaskedType(string_view), - ) - - def resolve_isdecimal(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.isdecimal"), - MaskedType(string_view), - ) + def resolve_value(self, mod): + return string_view - def resolve_isdigit(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.isdigit"), - MaskedType(string_view), - ) + def resolve_valid(self, mod): + return types.boolean - def resolve_islower(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.islower"), - MaskedType(string_view), - ) - def resolve_isupper(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.isupper"), +identifier_functions = [ + "isupper", + "islower", + "isdecimal", + "isdigit", + "isspace", + "isalnum", + "isalpha", + "isalnum", +] + +binary_bool_funcs = ["startswith", "endswith"] +integer_bool_funcs = ["find", "rfind"] + +for func in identifier_functions: + setattr( + MaskedStringViewAttrs, + f"resolve_{func}", + types.BoundFunction( + create_masked_identifier_attr(func), MaskedType(string_view), - ) + ), + ) + +for func in binary_bool_funcs: + setattr( + MaskedStringViewAttrs, + f"resolve_{func}", + create_masked_binary_attr(func, types.boolean), + ) + +for func in integer_bool_funcs: + setattr( + MaskedStringViewAttrs, + f"resolve_{func}", + create_masked_binary_attr(func, size_type), + ) - def resolve_isspace(self, mod): - return types.BoundFunction( - create_masked_identifier_attr("MaskedType.isspace"), - MaskedType(string_view), - ) +for op in comparison_ops: + cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) - def resolve_value(self, mod): - return string_view - def resolve_valid(self, mod): - return types.boolean +cuda_decl_registry.register_attr(MaskedStringViewAttrs) diff --git a/python/cudf/cudf/core/udf/utils.py b/python/cudf/cudf/core/udf/utils.py index 9f5d84d9f6b..fa79088046c 100644 --- a/python/cudf/cudf/core/udf/utils.py +++ b/python/cudf/cudf/core/udf/utils.py @@ -30,7 +30,7 @@ precompiled: cachetools.LRUCache = cachetools.LRUCache(maxsize=32) arg_handlers: List[Any] = [] -files: List[Any] = [] +ptx_files: List[Any] = [] @_cudf_nvtx_annotate @@ -225,7 +225,7 @@ def _get_kernel(kernel_string, globals_, sig, func): globals_["f_"] = f_ exec(kernel_string, globals_) _kernel = globals_["_kernel"] - kernel = cuda.jit(sig, link=files, extensions=arg_handlers)(_kernel) + kernel = cuda.jit(sig, link=ptx_files, extensions=arg_handlers)(_kernel) return kernel @@ -253,7 +253,7 @@ def _get_input_args_from_frame(fr): return args + offsets -def _return_col_from_dtype(dt, size): +def _return_arr_from_dtype(dt, size): return cp.empty(size, dtype=dt) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index b30becda6be..abd67e8348e 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -728,8 +728,7 @@ def f(x): @string_udf_test def test_string_udf_len(str_udf_data): def func(row): - st = row["str_col"] - return len(st) + len(row["str_col"]) run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -737,8 +736,7 @@ def func(row): @string_udf_test def test_string_udf_startswith(str_udf_data, substr): def func(row): - st = row["str_col"] - return st.startswith(substr) + return row["str_col"].startswith(substr) run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -746,8 +744,7 @@ def func(row): @string_udf_test def test_string_udf_endswith(str_udf_data, substr): def func(row): - st = row["str_col"] - return st.endswith(substr) + return row["str_col"].endswith(substr) run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -755,8 +752,7 @@ def func(row): @string_udf_test def test_string_udf_find(str_udf_data, substr): def func(row): - st = row["str_col"] - return st.find(substr) + return row["str_col"].find(substr) run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -764,8 +760,7 @@ def func(row): @string_udf_test def test_string_udf_rfind(str_udf_data, substr): def func(row): - st = row["str_col"] - return st.rfind(substr) + return row["str_col"].rfind(substr) run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -773,8 +768,7 @@ def func(row): @string_udf_test def test_string_udf_contains(str_udf_data, substr): def func(row): - st = row["str_col"] - return substr in st + return substr in row["str_col"] run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -784,8 +778,7 @@ def func(row): @pytest.mark.parametrize("cmpop", comparison_ops) def test_string_udf_cmpops(str_udf_data, other, cmpop): def func(row): - st = row["str_col"] - return cmpop(st, other) + return cmpop(row["str_col"], other) run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -793,8 +786,7 @@ def func(row): @string_udf_test def test_string_udf_isalnum(str_udf_data): def func(row): - st = row["str_col"] - return st.isalnum() + return row["str_col"].isalnum() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -802,8 +794,7 @@ def func(row): @string_udf_test def test_string_udf_isalpha(str_udf_data): def func(row): - st = row["str_col"] - return st.isalpha() + return row["str_col"].isalpha() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -811,8 +802,7 @@ def func(row): @string_udf_test def test_string_udf_isdigit(str_udf_data): def func(row): - st = row["str_col"] - return st.isdigit() + return row["str_col"].isdigit() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -820,8 +810,7 @@ def func(row): @string_udf_test def test_string_udf_isdecimal(str_udf_data): def func(row): - st = row["str_col"] - return st.isdecimal() + return row["str_col"].isdecimal() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -829,8 +818,7 @@ def func(row): @string_udf_test def test_string_udf_isupper(str_udf_data): def func(row): - st = row["str_col"] - return st.isupper() + return row["str_col"].isupper() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -838,8 +826,7 @@ def func(row): @string_udf_test def test_string_udf_islower(str_udf_data): def func(row): - st = row["str_col"] - return st.islower() + return row["str_col"].islower() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -847,8 +834,7 @@ def func(row): @string_udf_test def test_string_udf_isspace(str_udf_data): def func(row): - st = row["str_col"] - return st.isspace() + return row["str_col"].isspace() run_masked_udf_test(func, str_udf_data, check_dtype=False) @@ -857,8 +843,7 @@ def func(row): @pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(str_udf_data, substr): def func(row): - st = row["str_col"] - return st.count(substr) + return row["str_col"].count(substr) run_masked_udf_test(func, str_udf_data, check_dtype=False) diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index 8cc9249332a..71072875a00 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -9,10 +9,7 @@ import versioneer -install_requires = [ - "numba>=0.53.1", - "numpy", -] +install_requires = ["numba>=0.53.1", "numpy", "cudf"] extras_require = { "test": [ From c1f686d5aac70fa9d664f53f53596da56511096e Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 07:50:44 -0700 Subject: [PATCH 197/212] refactor _typing and strings_typing --- python/cudf/cudf/core/udf/strings_typing.py | 112 ++++++++------------ python/strings_udf/strings_udf/_typing.py | 91 +++++----------- 2 files changed, 70 insertions(+), 133 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index bf6461c9045..1286d4246ab 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -27,13 +27,10 @@ def register_string_function(func): def deco(generic): class MaskedStringFunction(AbstractTemplate): pass - MaskedStringFunction.generic = generic cuda_decl_registry.register_global(func)(MaskedStringFunction) - return deco - @register_string_function(len) def len_typing(self, args, kws): if isinstance(args[0], MaskedType) and isinstance( @@ -41,35 +38,9 @@ def len_typing(self, args, kws): ): return nb_signature(MaskedType(size_type), args[0]) elif isinstance(args[0], types.StringLiteral) and len(args) == 1: - # literal is always valid return nb_signature(size_type, args[0]) -def create_masked_binary_attr(attrname, retty): - class MaskedStringViewBinaryAttr(AbstractTemplate): - key = f"MaskedType.{attrname}" - - def generic(self, args, kws): - return nb_signature( - MaskedType(retty), MaskedType(string_view), recvr=self.this - ) - - return types.BoundFunction( - MaskedStringViewBinaryAttr, - MaskedType(string_view), - ) - - -def create_masked_identifier_attr(attrname): - class MaskedStringViewIdentifierAttr(AbstractTemplate): - key = attrname - - def generic(self, args, kws): - return nb_signature(MaskedType(types.boolean), recvr=self.this) - - return MaskedStringViewIdentifierAttr - - @register_string_function(operator.contains) def contains_typing(self, args, kws): if _is_valid_string_arg(args[0]) and _is_valid_string_arg(args[1]): @@ -79,7 +50,6 @@ def contains_typing(self, args, kws): MaskedType(string_view), ) - class MaskedStringViewCmpOp(AbstractTemplate): """ return the boolean result of `cmpop` between to strings @@ -95,6 +65,35 @@ def generic(self, args, kws): MaskedType(string_view), ) +def create_masked_binary_attr(attrname, retty): + class MaskedStringViewBinaryAttr(AbstractTemplate): + key = attrname + + def generic(self, args, kws): + return nb_signature( + MaskedType(retty), MaskedType(string_view), recvr=self.this + ) + + def attr(self, mod): + return types.BoundFunction( + MaskedStringViewBinaryAttr, + MaskedType(string_view), + ) + return attr + +def create_masked_identifier_attr(attrname): + class MaskedStringViewIdentifierAttr(AbstractTemplate): + key = attrname + + def generic(self, args, kws): + return nb_signature(MaskedType(types.boolean), recvr=self.this) + + def attr(self, mod): + return types.BoundFunction( + MaskedStringViewIdentifierAttr, + MaskedType(string_view), + ) + return attr class MaskedStringViewCount(AbstractTemplate): key = "MaskedType.count" @@ -120,46 +119,21 @@ def resolve_valid(self, mod): return types.boolean -identifier_functions = [ - "isupper", - "islower", - "isdecimal", - "isdigit", - "isspace", - "isalnum", - "isalpha", - "isalnum", -] - -binary_bool_funcs = ["startswith", "endswith"] -integer_bool_funcs = ["find", "rfind"] - -for func in identifier_functions: - setattr( - MaskedStringViewAttrs, - f"resolve_{func}", - types.BoundFunction( - create_masked_identifier_attr(func), - MaskedType(string_view), - ), - ) - -for func in binary_bool_funcs: - setattr( - MaskedStringViewAttrs, - f"resolve_{func}", - create_masked_binary_attr(func, types.boolean), - ) - -for func in integer_bool_funcs: - setattr( - MaskedStringViewAttrs, - f"resolve_{func}", - create_masked_binary_attr(func, size_type), - ) +# Build attributes for `MaskedType(string_view)` +bool_binary_funcs = ['startswith', 'endswith'] +int_binary_funcs = ['find', 'rfind'] +id_unary_funcs = ['isalpha', 'isalnum', 'isdecimal', 'isdigit', 'isupper', 'islower', 'isspace', 'isnumeric'] -for op in comparison_ops: - cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) +for func in bool_binary_funcs: + setattr(MaskedStringViewAttrs, f"resolve_{func}", create_masked_binary_attr(f"MaskedType.{func}", types.boolean)) + +for func in int_binary_funcs: + setattr(MaskedStringViewAttrs, f"resolve_{func}", create_masked_binary_attr(f"MaskedType.{func}", size_type)) +for func in id_unary_funcs: + setattr(MaskedStringViewAttrs, f"resolve_{func}", create_masked_identifier_attr(f"MaskedType.{func}")) cuda_decl_registry.register_attr(MaskedStringViewAttrs) + +for op in comparison_ops: + cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index 73b9580863f..c2cabd7f6e6 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -140,23 +140,32 @@ def generic(self, args, kws): def create_binary_attr(attrname, retty): class StringViewBinaryAttr(AbstractTemplate): - key = attrname + key = f"StringView.{attrname}" def generic(self, args, kws): return nb_signature(retty, string_view, recvr=self.this) - return StringViewBinaryAttr + def attr(self, mod): + return types.BoundFunction( + StringViewBinaryAttr, + string_view + ) + return attr def create_identifier_attr(attrname): class StringViewIdentifierAttr(AbstractTemplate): - key = attrname + key = f"StringView.{attrname}" def generic(self, args, kws): return nb_signature(types.boolean, recvr=self.this) - return StringViewIdentifierAttr - + def attr(self, mod): + return types.BoundFunction( + StringViewIdentifierAttr, + string_view + ) + return attr class StringViewCount(AbstractTemplate): key = "StringView.count" @@ -169,67 +178,21 @@ def generic(self, args, kws): class StringViewAttrs(AttributeTemplate): key = string_view - def resolve_startswith(self, mod): - return types.BoundFunction( - create_binary_attr("StringView.startswith", types.boolean), - string_view, - ) - - def resolve_endswith(self, mod): - return types.BoundFunction( - create_binary_attr("StringView.endswith", types.boolean), - string_view, - ) - - def resolve_find(self, mod): - return types.BoundFunction( - create_binary_attr("StringView.find", size_type), string_view - ) - - def resolve_rfind(self, mod): - return types.BoundFunction( - create_binary_attr("StringView.rfind", size_type), string_view - ) - - def resolve_isalnum(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isalnum"), string_view - ) - - def resolve_isalpha(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isalpha"), string_view - ) - - def resolve_isdecimal(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isdecimal"), string_view - ) - - def resolve_isdigit(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isdigit"), string_view - ) + def resolve_count(self, mod): + return types.BoundFunction(StringViewCount, string_view) - def resolve_isnumeric(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isnumeric"), string_view - ) +# Build attributes for `MaskedType(string_view)` +bool_binary_funcs = ['startswith', 'endswith'] +int_binary_funcs = ['find', 'rfind'] +id_unary_funcs = ['isalpha', 'isalnum', 'isdecimal', 'isdigit', 'isupper', 'islower', 'isspace', 'isnumeric'] - def resolve_islower(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.islower"), string_view - ) +for func in bool_binary_funcs: + setattr(StringViewAttrs, f"resolve_{func}", create_binary_attr(func, types.boolean)) - def resolve_isupper(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isupper"), string_view - ) +for func in int_binary_funcs: + setattr(StringViewAttrs, f"resolve_{func}", create_binary_attr(func, size_type)) - def resolve_isspace(self, mod): - return types.BoundFunction( - create_identifier_attr("StringView.isspace"), string_view - ) +for func in id_unary_funcs: + setattr(StringViewAttrs, f"resolve_{func}", create_identifier_attr(func)) - def resolve_count(self, mod): - return types.BoundFunction(StringViewCount, string_view) +cuda_decl_registry.register_attr(StringViewAttrs) From 79756064d79659bd1434a20f03ec464867503f74 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 07:52:22 -0700 Subject: [PATCH 198/212] style --- python/cudf/cudf/core/udf/strings_typing.py | 48 +++++++++++++++++---- python/strings_udf/strings_udf/_typing.py | 39 +++++++++++------ 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 1286d4246ab..ca2bb82b0ed 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -27,10 +27,13 @@ def register_string_function(func): def deco(generic): class MaskedStringFunction(AbstractTemplate): pass + MaskedStringFunction.generic = generic cuda_decl_registry.register_global(func)(MaskedStringFunction) + return deco + @register_string_function(len) def len_typing(self, args, kws): if isinstance(args[0], MaskedType) and isinstance( @@ -50,6 +53,7 @@ def contains_typing(self, args, kws): MaskedType(string_view), ) + class MaskedStringViewCmpOp(AbstractTemplate): """ return the boolean result of `cmpop` between to strings @@ -65,6 +69,7 @@ def generic(self, args, kws): MaskedType(string_view), ) + def create_masked_binary_attr(attrname, retty): class MaskedStringViewBinaryAttr(AbstractTemplate): key = attrname @@ -76,11 +81,13 @@ def generic(self, args, kws): def attr(self, mod): return types.BoundFunction( - MaskedStringViewBinaryAttr, - MaskedType(string_view), - ) + MaskedStringViewBinaryAttr, + MaskedType(string_view), + ) + return attr + def create_masked_identifier_attr(attrname): class MaskedStringViewIdentifierAttr(AbstractTemplate): key = attrname @@ -93,8 +100,10 @@ def attr(self, mod): MaskedStringViewIdentifierAttr, MaskedType(string_view), ) + return attr + class MaskedStringViewCount(AbstractTemplate): key = "MaskedType.count" @@ -120,18 +129,39 @@ def resolve_valid(self, mod): # Build attributes for `MaskedType(string_view)` -bool_binary_funcs = ['startswith', 'endswith'] -int_binary_funcs = ['find', 'rfind'] -id_unary_funcs = ['isalpha', 'isalnum', 'isdecimal', 'isdigit', 'isupper', 'islower', 'isspace', 'isnumeric'] +bool_binary_funcs = ["startswith", "endswith"] +int_binary_funcs = ["find", "rfind"] +id_unary_funcs = [ + "isalpha", + "isalnum", + "isdecimal", + "isdigit", + "isupper", + "islower", + "isspace", + "isnumeric", +] for func in bool_binary_funcs: - setattr(MaskedStringViewAttrs, f"resolve_{func}", create_masked_binary_attr(f"MaskedType.{func}", types.boolean)) + setattr( + MaskedStringViewAttrs, + f"resolve_{func}", + create_masked_binary_attr(f"MaskedType.{func}", types.boolean), + ) for func in int_binary_funcs: - setattr(MaskedStringViewAttrs, f"resolve_{func}", create_masked_binary_attr(f"MaskedType.{func}", size_type)) + setattr( + MaskedStringViewAttrs, + f"resolve_{func}", + create_masked_binary_attr(f"MaskedType.{func}", size_type), + ) for func in id_unary_funcs: - setattr(MaskedStringViewAttrs, f"resolve_{func}", create_masked_identifier_attr(f"MaskedType.{func}")) + setattr( + MaskedStringViewAttrs, + f"resolve_{func}", + create_masked_identifier_attr(f"MaskedType.{func}"), + ) cuda_decl_registry.register_attr(MaskedStringViewAttrs) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index c2cabd7f6e6..4fba833c99c 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -146,10 +146,8 @@ def generic(self, args, kws): return nb_signature(retty, string_view, recvr=self.this) def attr(self, mod): - return types.BoundFunction( - StringViewBinaryAttr, - string_view - ) + return types.BoundFunction(StringViewBinaryAttr, string_view) + return attr @@ -161,12 +159,11 @@ def generic(self, args, kws): return nb_signature(types.boolean, recvr=self.this) def attr(self, mod): - return types.BoundFunction( - StringViewIdentifierAttr, - string_view - ) + return types.BoundFunction(StringViewIdentifierAttr, string_view) + return attr + class StringViewCount(AbstractTemplate): key = "StringView.count" @@ -181,16 +178,32 @@ class StringViewAttrs(AttributeTemplate): def resolve_count(self, mod): return types.BoundFunction(StringViewCount, string_view) + # Build attributes for `MaskedType(string_view)` -bool_binary_funcs = ['startswith', 'endswith'] -int_binary_funcs = ['find', 'rfind'] -id_unary_funcs = ['isalpha', 'isalnum', 'isdecimal', 'isdigit', 'isupper', 'islower', 'isspace', 'isnumeric'] +bool_binary_funcs = ["startswith", "endswith"] +int_binary_funcs = ["find", "rfind"] +id_unary_funcs = [ + "isalpha", + "isalnum", + "isdecimal", + "isdigit", + "isupper", + "islower", + "isspace", + "isnumeric", +] for func in bool_binary_funcs: - setattr(StringViewAttrs, f"resolve_{func}", create_binary_attr(func, types.boolean)) + setattr( + StringViewAttrs, + f"resolve_{func}", + create_binary_attr(func, types.boolean), + ) for func in int_binary_funcs: - setattr(StringViewAttrs, f"resolve_{func}", create_binary_attr(func, size_type)) + setattr( + StringViewAttrs, f"resolve_{func}", create_binary_attr(func, size_type) + ) for func in id_unary_funcs: setattr(StringViewAttrs, f"resolve_{func}", create_identifier_attr(func)) From 6080e2535f9cac27a4945dcbf226a7cec0be662a Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 07:59:18 -0700 Subject: [PATCH 199/212] import funcs from strings_udf --- python/cudf/cudf/core/udf/strings_typing.py | 22 ++++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index ca2bb82b0ed..717290206d6 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -7,7 +7,14 @@ from numba.core.typing.templates import AbstractTemplate, AttributeTemplate from numba.cuda.cudadecl import registry as cuda_decl_registry -from strings_udf._typing import StringView, size_type, string_view +from strings_udf._typing import ( + StringView, + bool_binary_funcs, + id_unary_funcs, + int_binary_funcs, + size_type, + string_view, +) from cudf.core.udf import masked_typing from cudf.core.udf._ops import comparison_ops @@ -129,19 +136,6 @@ def resolve_valid(self, mod): # Build attributes for `MaskedType(string_view)` -bool_binary_funcs = ["startswith", "endswith"] -int_binary_funcs = ["find", "rfind"] -id_unary_funcs = [ - "isalpha", - "isalnum", - "isdecimal", - "isdigit", - "isupper", - "islower", - "isspace", - "isnumeric", -] - for func in bool_binary_funcs: setattr( MaskedStringViewAttrs, From b2062ea7ab56186f869615b3037ff06ad360622d Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 09:25:12 -0700 Subject: [PATCH 200/212] fix len test --- python/cudf/cudf/tests/test_udf_masked_ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index abd67e8348e..fccc55b08d8 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -728,7 +728,7 @@ def f(x): @string_udf_test def test_string_udf_len(str_udf_data): def func(row): - len(row["str_col"]) + return len(row["str_col"]) run_masked_udf_test(func, str_udf_data, check_dtype=False) From f964da4763097cc87eef54d8fd5d8a0bebd57964 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:18:19 -0400 Subject: [PATCH 201/212] add more doxygen to count() --- python/strings_udf/cpp/include/cudf/strings/udf/search.cuh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh index 0a2f36a812c..ef15886f1f5 100644 --- a/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh +++ b/python/strings_udf/cpp/include/cudf/strings/udf/search.cuh @@ -25,6 +25,10 @@ namespace udf { * @brief Returns the number of times that the target string appears * in the source string. * + * If `start <= 0` the search begins at the beginning of the `source` string. + * If `end <=0` or `end` is greater the length of the `source` string, + * the search stops at the end of the string. + * * @param source Source string to search * @param target String to match within source * @param start First character position within source to start the search From 2e19a66237b12ad84cc9272e142360e31cd80041 Mon Sep 17 00:00:00 2001 From: David Wendt <45795991+davidwendt@users.noreply.github.com> Date: Wed, 14 Sep 2022 13:34:52 -0400 Subject: [PATCH 202/212] Remove unneeded header includes --- python/strings_udf/cpp/src/strings/udf/udf_apis.cu | 6 ------ 1 file changed, 6 deletions(-) diff --git a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu index 693b23bb406..dfef1be39f5 100644 --- a/python/strings_udf/cpp/src/strings/udf/udf_apis.cu +++ b/python/strings_udf/cpp/src/strings/udf/udf_apis.cu @@ -19,14 +19,8 @@ #include #include #include -#include #include -#include - -#include - -#include namespace cudf { namespace strings { From b7ad6c98deccdf15edd9da41032a3ef7073019ee Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:56:26 -0500 Subject: [PATCH 203/212] Update python/strings_udf/strings_udf/tests/test_string_udfs.py Co-authored-by: Vyas Ramasubramani --- python/strings_udf/strings_udf/tests/test_string_udfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/strings_udf/strings_udf/tests/test_string_udfs.py b/python/strings_udf/strings_udf/tests/test_string_udfs.py index 84e6f8148a3..9038f4cc79a 100644 --- a/python/strings_udf/strings_udf/tests/test_string_udfs.py +++ b/python/strings_udf/strings_udf/tests/test_string_udfs.py @@ -54,7 +54,7 @@ def run_udf_test(data, func, dtype): comparing it with the equivalent pandas result """ dtype = np.dtype(dtype) - cudf_column = cudf.Series(data)._column + cudf_column = cudf.core.column.as_column(data) str_view_ary = to_string_view_array(cudf_column) output_ary = cudf.core.column.column_empty(len(data), dtype=dtype) From 345e417f523d0aed51e5ddc6d7d4d7ca2e900b58 Mon Sep 17 00:00:00 2001 From: brandon-b-miller <53796099+brandon-b-miller@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:57:31 -0500 Subject: [PATCH 204/212] Update python/cudf/cudf/tests/test_udf_masked_ops.py Co-authored-by: Vyas Ramasubramani --- python/cudf/cudf/tests/test_udf_masked_ops.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/cudf/cudf/tests/test_udf_masked_ops.py b/python/cudf/cudf/tests/test_udf_masked_ops.py index fccc55b08d8..2b96c920765 100644 --- a/python/cudf/cudf/tests/test_udf_masked_ops.py +++ b/python/cudf/cudf/tests/test_udf_masked_ops.py @@ -840,7 +840,6 @@ def func(row): @string_udf_test -@pytest.mark.parametrize("substr", ["c", "cu", "2", "abc", ""]) def test_string_udf_count(str_udf_data, substr): def func(row): return row["str_col"].count(substr) From b8fe76f1b9ea4833343f1e8d6a14be9142a5c818 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 11:10:03 -0700 Subject: [PATCH 205/212] docs --- python/cudf/cudf/core/udf/strings_lowering.py | 12 +++++++++ python/cudf/cudf/core/udf/strings_typing.py | 25 ++++++++++++++++--- python/strings_udf/strings_udf/_typing.py | 18 +++++++++++++ python/strings_udf/strings_udf/lowering.py | 12 +++++++++ 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/python/cudf/cudf/core/udf/strings_lowering.py b/python/cudf/cudf/core/udf/strings_lowering.py index 7b6ee2b729a..5b69d1a9da3 100644 --- a/python/cudf/cudf/core/udf/strings_lowering.py +++ b/python/cudf/cudf/core/udf/strings_lowering.py @@ -45,6 +45,12 @@ def masked_len_impl(context, builder, sig, args): def create_binary_string_func(op, cuda_func, retty): + """ + Provide a wrapper around numba's low-level extension API which + produces the boilerplate needed to implement a binary function + of two masked strings. + """ + def masked_binary_func_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) @@ -85,6 +91,12 @@ def masked_binary_func_impl(context, builder, sig, args): def create_masked_unary_identifier_func(op, cuda_func): + """ + Provide a wrapper around numba's low-level extension API which + produces the boilerplate needed to implement a unary function + of a masked string. + """ + def masked_unary_func_impl(context, builder, sig, args): ret = cgutils.create_struct_proxy(sig.return_type)(context, builder) masked_str = cgutils.create_struct_proxy(sig.args[0])( diff --git a/python/cudf/cudf/core/udf/strings_typing.py b/python/cudf/cudf/core/udf/strings_typing.py index 717290206d6..1179688651f 100644 --- a/python/cudf/cudf/core/udf/strings_typing.py +++ b/python/cudf/cudf/core/udf/strings_typing.py @@ -31,6 +31,12 @@ def _is_valid_string_arg(ty): def register_string_function(func): + """ + Helper function wrapping numba's low level extension API. Provides + the boilerplate needed to associate a signature with a function or + operator to be overloaded. + """ + def deco(generic): class MaskedStringFunction(AbstractTemplate): pass @@ -77,7 +83,17 @@ def generic(self, args, kws): ) +for op in comparison_ops: + cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) + + def create_masked_binary_attr(attrname, retty): + """ + Helper function wrapping numba's low level extension API. Provides + the boilerplate needed to register a binary function of two masked + string objects as an attribute of one, e.g. `string.func(other)`. + """ + class MaskedStringViewBinaryAttr(AbstractTemplate): key = attrname @@ -96,6 +112,12 @@ def attr(self, mod): def create_masked_identifier_attr(attrname): + """ + Helper function wrapping numba's low level extension API. Provides + the boilerplate needed to register a unary function of a masked + string object as an attribute, e.g. `string.func()`. + """ + class MaskedStringViewIdentifierAttr(AbstractTemplate): key = attrname @@ -158,6 +180,3 @@ def resolve_valid(self, mod): ) cuda_decl_registry.register_attr(MaskedStringViewAttrs) - -for op in comparison_ops: - cuda_decl_registry.register_global(op)(MaskedStringViewCmpOp) diff --git a/python/strings_udf/strings_udf/_typing.py b/python/strings_udf/strings_udf/_typing.py index 4fba833c99c..2e4519a01fe 100644 --- a/python/strings_udf/strings_udf/_typing.py +++ b/python/strings_udf/strings_udf/_typing.py @@ -119,6 +119,12 @@ def generic(self, args, kws): def register_stringview_binaryop(op, retty): + """ + Helper function wrapping numba's low level extension API. Provides + the boilerplate needed to associate a signature with a function or + operator expecting a string. + """ + class StringViewBinaryOp(AbstractTemplate): def generic(self, args, kws): if isinstance(args[0], any_string_ty) and isinstance( @@ -139,6 +145,12 @@ def generic(self, args, kws): def create_binary_attr(attrname, retty): + """ + Helper function wrapping numba's low level extension API. Provides + the boilerplate needed to register a binary function of two string + objects as an attribute of one, e.g. `string.func(other)`. + """ + class StringViewBinaryAttr(AbstractTemplate): key = f"StringView.{attrname}" @@ -152,6 +164,12 @@ def attr(self, mod): def create_identifier_attr(attrname): + """ + Helper function wrapping numba's low level extension API. Provides + the boilerplate needed to register a unary function of a string + object as an attribute, e.g. `string.func()`. + """ + class StringViewIdentifierAttr(AbstractTemplate): key = f"StringView.{attrname}" diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 3413f2f5ffa..3e7068bd92d 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -126,6 +126,12 @@ def len_impl(context, builder, sig, args): def create_binary_string_func(binary_func, retty): + """ + Provide a wrapper around numba's low-level extension API which + produces the boilerplate needed to implement a binary function + of two strings. + """ + def deco(cuda_func): @cuda_lower(binary_func, string_view, string_view) def binary_func_impl(context, builder, sig, args): @@ -209,6 +215,12 @@ def rfind_impl(sv, substr): def create_unary_identifier_func(id_func): + """ + Provide a wrapper around numba's low-level extension API which + produces the boilerplate needed to implement a unary function + of a string. + """ + def deco(cuda_func): @cuda_lower(id_func, string_view) def id_func_impl(context, builder, sig, args): From c2b126793514fd4dd4c04140e16fe939367d847b Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 11:15:26 -0700 Subject: [PATCH 206/212] elaborate on table_ptr --- python/strings_udf/strings_udf/lowering.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/strings_udf/strings_udf/lowering.py b/python/strings_udf/strings_udf/lowering.py index 3e7068bd92d..fd965a7a187 100644 --- a/python/strings_udf/strings_udf/lowering.py +++ b/python/strings_udf/strings_udf/lowering.py @@ -226,6 +226,10 @@ def deco(cuda_func): def id_func_impl(context, builder, sig, args): str_ptr = builder.alloca(args[0].type) builder.store(args[0], str_ptr) + + # Lookup table required for conversion functions + # must be resolved at runtime after context initialization, + # therefore cannot be a global variable tbl_ptr = context.get_constant( types.int64, character_flags_table_ptr ) From 1f8cb3baacc823a5fce6fa2f9342a75bc361e9fd Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 13:37:41 -0700 Subject: [PATCH 207/212] use in ci/cpu/build.sh --- ci/cpu/build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 5739ed4f659..2ad471b3a87 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -83,10 +83,8 @@ if [ "$BUILD_LIBCUDF" == '1' ]; then # BUILD_LIBCUDF == 1 means this job is being run on the cpu_build jobs # that is where we must also build the strings_udf package - gpuci_logger "Build conda pkg for strings_udf (python 3.8)" - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=3.8 - gpuci_logger "Build conda pkg for strings_udf (python 3.9)" - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=3.9 + gpuci_logger "Build conda pkg for strings_udf" + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=$PYTHON mkdir -p ${CONDA_BLD_DIR}/libcudf/work From 78e107802fed0698ab5c0f54d8502fd819b054f0 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Wed, 14 Sep 2022 13:44:16 -0700 Subject: [PATCH 208/212] add strings_udf to upload.sh --- ci/cpu/upload.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/cpu/upload.sh b/ci/cpu/upload.sh index 29f6265ec63..771b7853ade 100755 --- a/ci/cpu/upload.sh +++ b/ci/cpu/upload.sh @@ -33,6 +33,12 @@ if [[ "$BUILD_LIBCUDF" == "1" && "$UPLOAD_LIBCUDF" == "1" ]]; then export LIBCUDF_FILES=$(conda build --no-build-id --croot "${CONDA_BLD_DIR}" conda/recipes/libcudf --output) LIBCUDF_FILES=$(echo "$LIBCUDF_FILES" | sed 's/.*libcudf-example.*//') # skip libcudf-example pkg upload gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing --no-progress $LIBCUDF_FILES + + # also build strings_udf on cpu machines + export STRINGS_UDF_FILE=$(conda build --croot "${CONDA_BLD_DIR}" conda/recipes/strings_udf --python=$PYTHON --output) + test -e ${STRINGS_UDF_FILE} + echo "Upload strings_udf: ${STRINGS_UDF_FILE}" + gpuci_retry anaconda -t ${MY_UPLOAD_KEY} upload -u ${CONDA_USERNAME:-rapidsai} ${LABEL_OPTION} --skip-existing ${STRINGS_UDF_FILE} --no-progress fi if [[ "$BUILD_CUDF" == "1" && "$UPLOAD_CUDF" == "1" ]]; then From db0c5896e088db42994d9c0f874ed23b2b4fec57 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Mon, 19 Sep 2022 08:32:27 -0700 Subject: [PATCH 209/212] revert to building package for different python versions manually --- ci/cpu/build.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci/cpu/build.sh b/ci/cpu/build.sh index 2ad471b3a87..a931546292e 100755 --- a/ci/cpu/build.sh +++ b/ci/cpu/build.sh @@ -83,9 +83,10 @@ if [ "$BUILD_LIBCUDF" == '1' ]; then # BUILD_LIBCUDF == 1 means this job is being run on the cpu_build jobs # that is where we must also build the strings_udf package - gpuci_logger "Build conda pkg for strings_udf" - gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=$PYTHON - + gpuci_logger "Build conda pkg for strings_udf (python 3.8)" + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=3.8 + gpuci_logger "Build conda pkg for strings_udf (python 3.9)" + gpuci_conda_retry mambabuild --no-build-id --croot ${CONDA_BLD_DIR} conda/recipes/strings_udf $CONDA_BUILD_ARGS --python=3.9 mkdir -p ${CONDA_BLD_DIR}/libcudf/work cp -r ${CONDA_BLD_DIR}/work/* ${CONDA_BLD_DIR}/libcudf/work From cf0ae5b85064a61b1fc793612e2e682d75f7fb28 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Mon, 19 Sep 2022 11:37:26 -0700 Subject: [PATCH 210/212] Explicitly catch return code instead of relying on a function. --- ci/gpu/build.sh | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/ci/gpu/build.sh b/ci/gpu/build.sh index 98931e6b8ff..ae19362ca11 100755 --- a/ci/gpu/build.sh +++ b/ci/gpu/build.sh @@ -268,34 +268,25 @@ gpuci_mamba_retry install strings_udf -c "${CONDA_BLD_DIR}" -c "${CONDA_ARTIFACT cd "$WORKSPACE/python/strings_udf/strings_udf" gpuci_logger "Python py.test for strings_udf" -# This helper function runs the strings_udf tests but ensures that we do not -# return a nonzero exit code in the case where no tests are run because that -# will always happen when the local CUDA version is not 11.5. We need to -# suppress the exit code because this script is run with set -e and we're -# already setting a trap that we don't want to override here. -function run_strings_udf_test() { - py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term tests - - local err=$?; - if [ ${err} -eq 5 ]; then - STRING_UDF_TEST_RUN=0; - return 0; - else - STRING_UDF_TEST_RUN=1; - return ${err}; - fi -} -run_strings_udf_test +# We do not want to exit with a nonzero exit code in the case where no +# strings_udf tests are run because that will always happen when the local CUDA +# version is not 11.5. We need to suppress the exit code because this script is +# run with set -e and we're already setting a trap that we don't want to +# override here. + +STRINGS_UDF_PYTEST_RETCODE=0 +py.test -n 8 --cache-clear --basetemp="$WORKSPACE/strings-udf-cuda-tmp" --junitxml="$WORKSPACE/junit-strings-udf.xml" -v --cov-config=.coveragerc --cov=strings_udf --cov-report=xml:"$WORKSPACE/python/strings_udf/strings-udf-coverage.xml" --cov-report term tests || STRINGS_UDF_PYTEST_RETCODE=$? -if [ ${STRING_UDF_TEST_RUN} -eq 0 ]; then +if [ ${STRINGS_UDF_PYTEST_RETCODE} -eq 5 ]; then echo "No strings UDF tests were run, but this script will continue to execute." +elif [ ${STRINGS_UDF_PYTEST_RETCODE} -ne 0 ]; then + exit ${STRINGS_UDF_PYTEST_RETCODE} +else + cd "$WORKSPACE/python/cudf/cudf" + gpuci_logger "Python py.test retest cuDF UDFs" + py.test tests/test_udf_masked_ops.py -n 8 --cache-clear fi -cd "$WORKSPACE/python/cudf/cudf" -gpuci_logger "Python py.test retest cuDF UDFs" -py.test tests/test_udf_masked_ops.py -n 8 --cache-clear - - # Run benchmarks with both cudf and pandas to ensure compatibility is maintained. # Benchmarks are run in DEBUG_ONLY mode, meaning that only small data sizes are used. # Therefore, these runs only verify that benchmarks are valid. From 40e6cd6c33ba133f3c801240d7bc53a6081025cf Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 20 Sep 2022 07:37:10 -0700 Subject: [PATCH 211/212] style --- python/strings_udf/setup.py | 3 +-- python/strings_udf/strings_udf/__init__.py | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/strings_udf/setup.py b/python/strings_udf/setup.py index 71072875a00..c8cafe978f7 100644 --- a/python/strings_udf/setup.py +++ b/python/strings_udf/setup.py @@ -4,11 +4,10 @@ import re import shutil +import versioneer from setuptools import find_packages from skbuild import setup -import versioneer - install_requires = ["numba>=0.53.1", "numpy", "cudf"] extras_require = { diff --git a/python/strings_udf/strings_udf/__init__.py b/python/strings_udf/strings_udf/__init__.py index fa67ae053a2..94bd2531779 100644 --- a/python/strings_udf/strings_udf/__init__.py +++ b/python/strings_udf/strings_udf/__init__.py @@ -1,13 +1,14 @@ # Copyright (c) 2022, NVIDIA CORPORATION. -from ptxcompiler.patch import CMD import glob import os -import sys -import subprocess import re -from . import _version +import subprocess +import sys from numba import cuda +from ptxcompiler.patch import CMD + +from . import _version ENABLED = False From 036eeec3ddc18e0f2c0768234459d2579fc91570 Mon Sep 17 00:00:00 2001 From: brandon-b-miller Date: Tue, 20 Sep 2022 08:50:55 -0700 Subject: [PATCH 212/212] cudf/core/udf/__init__.py is sensitive to import order, skip on isort --- python/cudf/cudf/core/udf/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/cudf/cudf/core/udf/__init__.py b/python/cudf/cudf/core/udf/__init__.py index af5e9f9ce56..c128bc2436c 100644 --- a/python/cudf/cudf/core/udf/__init__.py +++ b/python/cudf/cudf/core/udf/__init__.py @@ -30,12 +30,12 @@ import strings_udf if strings_udf.ENABLED: + from . import strings_typing # isort: skip + from . import strings_lowering # isort: skip from strings_udf import ptxpath from strings_udf._lib.cudf_jit_udf import to_string_view_array from strings_udf._typing import str_view_arg_handler, string_view - from . import strings_lowering, strings_typing - # add an overload of MaskedType.__init__(string_view, bool) cuda_lower(api.Masked, strings_typing.string_view, types.boolean)( masked_lowering.masked_constructor