Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

MAINT: Implement new casting loops based on NEP 42 and 43 #17863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions 10 numpy/core/include/numpy/npy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
#include <npy_config.h>
#endif

// compile time environment variables
#ifndef NPY_RELAXED_STRIDES_CHECKING
#define NPY_RELAXED_STRIDES_CHECKING 0
#endif
#ifndef NPY_RELAXED_STRIDES_DEBUG
#define NPY_RELAXED_STRIDES_DEBUG 0
#endif
#ifndef NPY_USE_NEW_CASTINGIMPL
#define NPY_USE_NEW_CASTINGIMPL 0
#endif
/*
* using static inline modifiers when defining npy_math functions
* allows the compiler to make optimizations when possible
Expand Down
7 changes: 7 additions & 0 deletions 7 numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,20 @@ def generate_config_h(ext, build_dir):
# Use relaxed stride checking
if NPY_RELAXED_STRIDES_CHECKING:
moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 1))
else:
moredefs.append(('NPY_RELAXED_STRIDES_CHECKING', 0))

# Use bogus stride debug aid when relaxed strides are enabled
if NPY_RELAXED_STRIDES_DEBUG:
moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 1))
else:
moredefs.append(('NPY_RELAXED_STRIDES_DEBUG', 0))

# Use the new experimental casting implementation in NumPy 1.20:
if NPY_USE_NEW_CASTINGIMPL:
moredefs.append(('NPY_USE_NEW_CASTINGIMPL', 1))
else:
moredefs.append(('NPY_USE_NEW_CASTINGIMPL', 0))

# Get long double representation
rep = check_long_double_representation(config_cmd)
Expand Down Expand Up @@ -788,6 +794,7 @@ def get_mathlib_info(*args):
join('src', 'multiarray', 'ctors.h'),
join('src', 'multiarray', 'descriptor.h'),
join('src', 'multiarray', 'dtypemeta.h'),
join('src', 'multiarray', 'dtype_transfer.h'),
join('src', 'multiarray', 'dragon4.h'),
join('src', 'multiarray', 'einsum_debug.h'),
join('src', 'multiarray', 'einsum_sumprod.h'),
Expand Down
82 changes: 82 additions & 0 deletions 82 numpy/core/src/common/lowlevel_strided_loops.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,88 @@ PyArray_GetDTypeTransferFunction(int aligned,
NpyAuxData **out_transferdata,
int *out_needs_api);


/* Same as above, but only wraps copyswapn or legacy cast functions */
NPY_NO_EXPORT int
PyArray_GetLegacyDTypeTransferFunction(int aligned,
npy_intp src_stride, npy_intp dst_stride,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
int move_references,
PyArray_StridedUnaryOp **out_stransfer,
NpyAuxData **out_transferdata,
int *out_needs_api, int wrap_if_unaligned);

/* Specialized dtype transfer functions */
NPY_NO_EXPORT int
get_nbo_cast_datetime_transfer_function(int aligned,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
PyArray_StridedUnaryOp **out_stransfer,
NpyAuxData **out_transferdata);

NPY_NO_EXPORT int
get_nbo_datetime_to_string_transfer_function(
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
PyArray_StridedUnaryOp **out_stransfer, NpyAuxData **out_transferdata);

NPY_NO_EXPORT int
get_datetime_to_unicode_transfer_function(int aligned,
npy_intp src_stride, npy_intp dst_stride,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
PyArray_StridedUnaryOp **out_stransfer,
NpyAuxData **out_transferdata,
int *out_needs_api);

NPY_NO_EXPORT int
get_nbo_string_to_datetime_transfer_function(
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
PyArray_StridedUnaryOp **out_stransfer, NpyAuxData **out_transferdata);

NPY_NO_EXPORT int
get_unicode_to_datetime_transfer_function(int aligned,
npy_intp src_stride, npy_intp dst_stride,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
PyArray_StridedUnaryOp **out_stransfer,
NpyAuxData **out_transferdata,
int *out_needs_api);

NPY_NO_EXPORT int
get_fields_transfer_function(int aligned,
npy_intp src_stride, npy_intp dst_stride,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
int move_references,
PyArray_StridedUnaryOp **out_stransfer,
NpyAuxData **out_transferdata,
int *out_needs_api);

NPY_NO_EXPORT int
get_subarray_transfer_function(int aligned,
npy_intp src_stride, npy_intp dst_stride,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
int move_references,
PyArray_StridedUnaryOp **out_stransfer,
NpyAuxData **out_transferdata,
int *out_needs_api);

NPY_NO_EXPORT int
_strided_to_strided_move_references(char *dst, npy_intp dst_stride,
char *src, npy_intp src_stride,
npy_intp N, npy_intp src_itemsize,
NpyAuxData *data);

NPY_NO_EXPORT int
_strided_to_strided_copy_references(char *dst, npy_intp dst_stride,
char *src, npy_intp src_stride,
npy_intp N, npy_intp src_itemsize,
NpyAuxData *data);

NPY_NO_EXPORT int
wrap_aligned_contig_transfer_function_with_copyswapn(
int aligned, npy_intp src_stride, npy_intp dst_stride,
PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype,
PyArray_StridedUnaryOp **out_stransfer, NpyAuxData **out_transferdata,
int *out_needs_api,
PyArray_StridedUnaryOp *caststransfer, NpyAuxData *castdata);

/*
* This is identical to PyArray_GetDTypeTransferFunction, but returns a
* transfer function which also takes a mask as a parameter. The mask is used
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.